Skip to content

Commit 3dce635

Browse files
authored
Merge pull request #2864 from WISE-Community/issue-2859-upgrade-alertStatusCorner-to-angular
Upgraded AlertStatusCorner to Angular component
2 parents 58037de + 6780fc6 commit 3dce635

8 files changed

Lines changed: 38 additions & 76 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div *ngIf="hasAlert" class="status-corner-wrapper status-corner-top-right">
2+
<div class="status-corner"
3+
[ngClass]="{'status-corner--warn': hasNewAlert}"
4+
matTooltip="{{message}}"
5+
matTooltipPosition="above"></div>
6+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Component, Input } from '@angular/core';
2+
3+
@Component({
4+
selector: 'alert-status-corner',
5+
templateUrl: 'alert-status-corner.component.html'
6+
})
7+
export class AlertStatusCornerComponent {
8+
@Input()
9+
hasNewAlert: boolean;
10+
11+
@Input()
12+
hasAlert: boolean;
13+
14+
@Input()
15+
message: string;
16+
}

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
@@ -1,6 +1,7 @@
11
import { NgModule } from '@angular/core';
22

33
import '../../../wise5/teacher/teacher-angular-js-module';
4+
import { AlertStatusCornerComponent } from './classroom-monitor/alert-status-corner/alert-status-corner.component';
45
import { UpgradeModule } from '@angular/upgrade/static';
56
import { setUpLocationSync } from '@angular/router/upgrade';
67
import { ProjectService } from '../../../wise5/services/projectService';
@@ -47,6 +48,7 @@ import { HtmlAuthoring } from '../../../wise5/components/html/html-authoring/htm
4748
@NgModule({
4849
declarations: [
4950
AdvancedProjectAuthoringComponent,
51+
AlertStatusCornerComponent,
5052
ChooseImportStepComponent,
5153
ChooseImportStepLocationComponent,
5254
ChooseNewComponent,

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/navItem/navItem.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
aria-label="collapse">remove
1414
</md-icon>
1515
</div>
16-
<alert-status-corner has-alert="$ctrl.newAlert" has-new-alert="$ctrl.newAlert"
17-
message="$ctrl.alertIconLabel">
16+
<alert-status-corner [has-alert]="$ctrl.newAlert" [has-new-alert]="$ctrl.newAlert"
17+
[message]="$ctrl.alertIconLabel">
1818
</alert-status-corner>
1919
</md-card-content>
2020
<md-card-content ng-if="$ctrl.isGroup && $ctrl.expanded"

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/nodeProgress/navItem/navItem.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ class NavItemController {
2323
currentPeriod: any;
2424
currentWorkgroup: any;
2525
expanded: boolean = false;
26-
hasAlert: boolean;
26+
hasAlert: boolean = false;
2727
hasRubrics: boolean;
2828
icon: any;
2929
isCurrentNode: boolean;
3030
isGroup: boolean;
3131
item: any;
3232
maxScore: number;
33-
newAlert: any;
33+
newAlert: boolean = false;;
3434
nodeHasWork: boolean;
3535
nodeId: string;
3636
nodeTitle: string;
@@ -108,13 +108,8 @@ class NavItemController {
108108
this.parentGroupId = parentGroup.id;
109109
}
110110
this.setWorkgroupsOnNodeData();
111-
112-
this.hasAlert = false;
113-
this.newAlert = false;
114111
this.alertNotifications = [];
115-
116112
this.getAlertNotifications();
117-
118113
this.hasRubrics = this.ProjectService.getNumberOfRubricsByNodeId(this.nodeId) > 0;
119114
this.alertIconLabel = this.$translate('HAS_ALERTS_NEW');
120115
this.alertIconClass = 'warn';
@@ -448,29 +443,23 @@ class NavItemController {
448443
}
449444

450445
getAlertNotifications() {
451-
let periodId = this.currentPeriod.periodId;
452-
let workgroupId = this.currentWorkgroup ? this.currentWorkgroup.workgroupId : null;
453-
let args = {
446+
const args = {
454447
nodeId: this.nodeId,
455-
periodId: periodId,
456-
toWorkgroupId: workgroupId
448+
periodId: this.currentPeriod.periodId,
449+
toWorkgroupId: this.currentWorkgroup ? this.currentWorkgroup.workgroupId : null
457450
};
458451
this.alertNotifications = this.NotificationService.getAlertNotifications(args);
459452
this.hasAlert = this.alertNotifications.length > 0;
460453
this.newAlert = this.hasNewAlert();
461454
}
462455

463-
hasNewAlert() {
464-
let result = false;
465-
let nAlerts = this.alertNotifications.length;
466-
for (let i = 0; i < nAlerts; i++) {
467-
let alert = this.alertNotifications[i];
456+
hasNewAlert(): boolean {
457+
for (const alert of this.alertNotifications) {
468458
if (!alert.timeDismissed) {
469-
result = true;
470-
break;
459+
return true;
471460
}
472461
}
473-
return result;
462+
return false;
474463
}
475464

476465
getPeriodLabel() {

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/shared/alertStatusCorner/alertStatusCorner.ts

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

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/shared/alertStatusIcon/alertStatusIcon.ts

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

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
import AlertStatusCorner from './alertStatusCorner/alertStatusCorner';
4-
import AlertStatusIcon from './alertStatusIcon/alertStatusIcon';
53
import ComponentGrading from './componentGrading/componentGrading';
64
import { ComponentNewWorkBadgeComponent } from '../../../../site/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component';
75
import ComponentRevisionsInfo from './componentRevisionsInfo/componentRevisionsInfo';
@@ -16,15 +14,16 @@ import TopBar from './topBar/topBar';
1614
import WorkgroupComponentRevisions from './workgroupComponentRevisions/workgroupComponentRevisions';
1715
import WorkgroupNodeGrading from './workgroupNodeGrading/workgroupNodeGrading';
1816
import { WorkgroupNodeStatusComponent } from '../../../../site/src/app/classroom-monitor/workgroup-node-status/workgroup-node-status.component';
17+
import { AlertStatusCornerComponent } from '../../../../site/src/app/classroom-monitor/alert-status-corner/alert-status-corner.component';
1918
import WorkgroupSelect from './workgroupSelect/workgroupSelect';
2019
import * as angular from 'angular';
2120
import { WorkgroupNodeScoreComponent } from './workgroupNodeScore/workgroup-node-score.component';
2221
import { downgradeComponent } from '@angular/upgrade/static';
2322

2423
const Shared = angular
2524
.module('cmShared', [])
26-
.component('alertStatusCorner', AlertStatusCorner)
27-
.component('alertStatusIcon', AlertStatusIcon)
25+
.directive('alertStatusCorner',
26+
downgradeComponent({ component: AlertStatusCornerComponent }) as angular.IDirectiveFactory)
2827
.component('componentGrading', ComponentGrading)
2928
.directive('componentNewWorkBadge',
3029
downgradeComponent({ component: ComponentNewWorkBadgeComponent }) as angular.IDirectiveFactory)

0 commit comments

Comments
 (0)