Skip to content

Commit 76fa91a

Browse files
authored
Merge pull request #2853 from WISE-Community/issue-2532-upgrade-stepInfo-to-angular
Upgraded StepInfo to Angular component
2 parents 1870140 + 4cf59b9 commit 76fa91a

7 files changed

Lines changed: 80 additions & 112 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div fxLayout="row" fxLayoutAlign="start center">
2+
<node-icon [nodeId]="nodeId" size="18" fxHide.xs></node-icon>
3+
<span fxHide.xs>&nbsp;&nbsp;</span>
4+
<div class="heavy">
5+
{{ stepTitle }}
6+
<status-icon *ngIf="hasAlert"
7+
[iconClass]="alertIconClass"
8+
[iconName]="alertIconName"
9+
[iconLabel]="alertIconLabel"
10+
[iconTooltip]="alertIconLabel"></status-icon>
11+
<status-icon *ngIf="hasRubrics"
12+
iconClass="info"
13+
iconName="info"
14+
[iconLabel]="rubricIconLabel"
15+
[iconTooltip]="rubricIconLabel"></status-icon>
16+
<span *ngIf="hasNewWork" class="badge badge--info animate-fade" i18n>New</span>
17+
</div>
18+
</div>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Component, Input } from '@angular/core';
2+
import { TeacherProjectService } from '../../../../../wise5/services/teacherProjectService';
3+
4+
@Component({
5+
selector: 'step-info',
6+
templateUrl: 'step-info.component.html'
7+
})
8+
export class StepInfoComponent {
9+
$translate: any;
10+
alertIconClass: string;
11+
alertIconLabel: string;
12+
alertIconName: string;
13+
@Input()
14+
hasAlert: boolean;
15+
@Input()
16+
hasNewAlert: boolean;
17+
@Input()
18+
hasNewWork: boolean;
19+
hasRubrics: boolean;
20+
@Input()
21+
nodeId: string;
22+
rubricIconLabel: string;
23+
stepTitle: string;
24+
25+
constructor(private ProjectService: TeacherProjectService) {
26+
}
27+
28+
ngOnInit() {
29+
this.stepTitle = this.ProjectService.getNodePositionAndTitleByNodeId(this.nodeId);
30+
if (this.hasAlert) {
31+
this.alertIconClass = this.hasNewAlert ? 'warn' : 'text-disabled';
32+
this.alertIconName = 'notifications';
33+
this.alertIconLabel = this.hasNewAlert ? $localize`Has new alert(s)`:
34+
$localize`Has dismissed alert(s)`;
35+
}
36+
this.hasRubrics = this.ProjectService.getNumberOfRubricsByNodeId(this.nodeId) > 0;
37+
this.rubricIconLabel = $localize`Step has rubrics/teaching tips`;
38+
}
39+
}

src/main/webapp/site/src/app/teacher-hybrid-angular.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { ChooseImportStepLocationComponent } from './authoring-tool/import-step/
2626
import { ComponentNewWorkBadgeComponent } from './classroom-monitor/component-new-work-badge/component-new-work-badge.component';
2727
import { ComponentSelectComponent } from './classroom-monitor/component-select/component-select.component';
2828
import { StatusIconComponent } from './classroom-monitor/status-icon/status-icon.component';
29+
import { StepInfoComponent } from './classroom-monitor/step-info/step-info.component';
2930
import { AngularJSModule } from './common-hybrid-angular.module';
3031
import { NodeAdvancedJsonAuthoringComponent } from '../../../wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component';
3132
import { WorkgroupInfoComponent } from '../../../wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/workgroupInfo/workgroup-info.component';
@@ -61,6 +62,7 @@ import { NavItemProgressComponent } from './classroom-monitor/nav-item-progress/
6162
NodeAdvancedJsonAuthoringComponent,
6263
RubricAuthoringComponent,
6364
StatusIconComponent,
65+
StepInfoComponent,
6466
WorkgroupInfoComponent,
6567
WorkgroupNodeScoreComponent,
6668
NavItemScoreComponent,

src/main/webapp/site/src/messages.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5313,6 +5313,10 @@
53135313
<context context-type="sourcefile">app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts</context>
53145314
<context context-type="linenumber">1</context>
53155315
</context-group>
5316+
<context-group purpose="location">
5317+
<context context-type="sourcefile">app/classroom-monitor/step-info/step-info.component.html</context>
5318+
<context context-type="linenumber">16</context>
5319+
</context-group>
53165320
<context-group purpose="location">
53175321
<context context-type="sourcefile">../../wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/workgroupInfo/workgroup-info.component.html</context>
53185322
<context context-type="linenumber">10</context>

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/stepInfo/stepInfo.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/stepItem/stepItem.ts

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ class StepItemController {
2727

2828
$onChanges(changesObj) {
2929
if (changesObj.maxScore) {
30-
this.maxScore =
31-
typeof changesObj.maxScore.currentValue === 'number' ? changesObj.maxScore.currentValue : 0;
30+
this.maxScore = typeof changesObj.maxScore.currentValue === 'number' ?
31+
changesObj.maxScore.currentValue : 0;
3232
}
33-
3433
if (changesObj.stepData) {
3534
let stepData = angular.copy(changesObj.stepData.currentValue);
3635
this.title = stepData.title;
@@ -39,7 +38,6 @@ class StepItemController {
3938
this.status = stepData.completionStatus;
4039
this.score = stepData.score >= 0 ? stepData.score : '-';
4140
}
42-
4341
this.update();
4442
}
4543

@@ -51,7 +49,6 @@ class StepItemController {
5149
break;
5250
case 2:
5351
this.statusClass = 'success';
54-
5552
if (this.showScore) {
5653
this.statusText = this.$translate('completed');
5754
} else {
@@ -60,23 +57,19 @@ class StepItemController {
6057
break;
6158
case 1:
6259
this.statusClass = 'text';
63-
6460
this.statusText = this.$translate('partiallyCompleted');
6561
break;
6662
default:
6763
this.statusClass = 'text-secondary';
68-
6964
if (this.showScore) {
7065
this.statusText = this.$translate('noWork');
7166
} else {
7267
this.statusText = this.$translate('notVisited');
7368
}
7469
}
75-
7670
if (this.hasNewAlert) {
7771
this.statusClass = 'warn';
7872
}
79-
8073
this.disabled = this.status === -1;
8174
}
8275

@@ -100,42 +93,31 @@ const StepItem = {
10093
},
10194
controller: StepItemController,
10295
template: `<div class="md-whiteframe-1dp"
103-
ng-class="{ 'list-item--warn': $ctrl.statusClass === 'warn',
104-
'list-item--info': $ctrl.statusClass === 'info' }">
96+
ng-class="{ 'list-item--warn': $ctrl.statusClass === 'warn', 'list-item--info': $ctrl.statusClass === 'info' }">
10597
<md-subheader class="list-item md-whiteframe-1dp">
10698
<button class="md-button md-ink-ripple list-item__subheader-button"
10799
aria-label="{{ ::toggleTeamWorkDisplay | translate }}"
108-
ng-class="{ 'list-item--noclick': !$ctrl.showScore ||
109-
$ctrl.disabled }"
100+
ng-class="{ 'list-item--noclick': !$ctrl.showScore || $ctrl.disabled }"
110101
ng-click="$ctrl.toggleExpand()"
111102
ng-disabled="$ctrl.disabled"
112103
layout-wrap>
113104
<div layout="row" flex>
114105
<div flex layout="row" layout-align="start center">
115-
<step-info has-alert="$ctrl.hasAlert"
116-
has-new-alert="$ctrl.hasNewAlert"
117-
has-new-work="$ctrl.hasNewWork"
118-
node-id="::$ctrl.nodeId"
119-
node-title="{{ ::$ctrl.title }}"
120-
show-position="true"></step-info>
106+
<step-info [has-alert]="$ctrl.hasAlert"
107+
[has-new-alert]="$ctrl.hasNewAlert"
108+
[has-new-work]="$ctrl.hasNewWork"
109+
[node-id]="::$ctrl.nodeId"></step-info>
121110
</div>
122-
<div flex="{{ $ctrl.showScore ? 30 : 20 }}" layout="row"
123-
layout-align="center center">
124-
<workgroup-node-status [status-text]="$ctrl.statusText"
125-
[status-class]="$ctrl.statusClass">
126-
</workgroup-node-status>
111+
<div flex="{{ $ctrl.showScore ? 30 : 20 }}" layout="row" layout-align="center center">
112+
<workgroup-node-status [status-text]="$ctrl.statusText" [status-class]="$ctrl.statusClass"></workgroup-node-status>
127113
</div>
128-
<div ng-if="$ctrl.showScore" flex="20" layout="row"
129-
layout-align="center center">
130-
<workgroup-node-score [score]="$ctrl.score"
131-
[max-score]="$ctrl.maxScore">
132-
</workgroup-node-score>
114+
<div ng-if="$ctrl.showScore" flex="20" layout="row" layout-align="center center">
115+
<workgroup-node-score [score]="$ctrl.score" [max-score]="$ctrl.maxScore"></workgroup-node-score>
133116
</div>
134117
</div>
135118
</button>
136119
</md-subheader>
137-
<md-list-item ng-if="$ctrl.expand && !$ctrl.disabled"
138-
class="grading__item-container">
120+
<md-list-item ng-if="$ctrl.expand && !$ctrl.disabled" class="grading__item-container">
139121
<workgroup-node-grading workgroup-id="::$ctrl.workgroupId"
140122
class="workgroup-node-grading"
141123
node-id="{{ ::$ctrl.nodeId }}"

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/studentGrading.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
'use strict';
22

3-
import StepInfo from './stepInfo/stepInfo';
43
import StepItem from './stepItem/stepItem';
54
import StudentGradingTools from './studentGradingTools/studentGradingTools';
65
import * as angular from 'angular';
6+
import { StepInfoComponent } from '../../../../site/src/app/classroom-monitor/step-info/step-info.component';
7+
import { downgradeComponent } from '@angular/upgrade/static';
78

89
const StudentGrading = angular
910
.module('studentGrading', [])
10-
.component('stepInfo', StepInfo)
11+
.directive('stepInfo',
12+
downgradeComponent({ component: StepInfoComponent }) as angular.IDirectiveFactory)
1113
.component('stepItem', StepItem)
1214
.component('studentGradingTools', StudentGradingTools);
1315

0 commit comments

Comments
 (0)