Skip to content

Commit 9cd6f44

Browse files
Upgraded ComponentSelect to Angular. #2846
1 parent d30c066 commit 9cd6f44

8 files changed

Lines changed: 112 additions & 93 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<mat-select *ngIf="components.length > 1"
2+
class="md-no-underline md-button mat-button-raised md-raised"
3+
[(ngModel)]="selectedComponents"
4+
(selectionChange)="selectedComponentsChange()"
5+
placeholder="{{getSelectedText()}}"
6+
multiple>
7+
<mat-select-trigger>{{getSelectedText()}}</mat-select-trigger>
8+
<mat-optgroup label="Assessment items to show" i18n-label>
9+
<mat-option value="{{component.id}}" *ngFor="let component of components; let i = index">
10+
{{ i+1 }}: {{ getComponentTypeLabel(component.type) }}
11+
</mat-option>
12+
</mat-optgroup>
13+
</mat-select>
14+
<button mat-button class="md-body-1 mat-button-raised"
15+
*ngIf="components.length == 1"
16+
aria-label="Assessment items to show"
17+
i18n-aria-label
18+
disabled
19+
i18n>
20+
1 assessment item
21+
</button>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mat-select {
2+
min-width: 150px;
3+
}
4+
5+
mat-select, mat-select-trigger {
6+
text-transform: none;
7+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { Component, EventEmitter, Input, Output } from "@angular/core";
2+
import { UpgradeModule } from "@angular/upgrade/static";
3+
import { TeacherProjectService } from "../../../../../wise5/services/teacherProjectService";
4+
import { UtilService } from "../../../../../wise5/services/utilService";
5+
6+
@Component({
7+
selector: 'component-select',
8+
styleUrls: ['component-select.component.scss'],
9+
templateUrl: 'component-select.component.html'
10+
})
11+
export class ComponentSelectComponent {
12+
13+
components: any[];
14+
15+
@Output()
16+
modelChange: EventEmitter<any> = new EventEmitter<any>();
17+
18+
@Input()
19+
nodeId: string;
20+
21+
selectedComponents: any[];
22+
23+
constructor(private upgrade: UpgradeModule, private ProjectService: TeacherProjectService,
24+
private UtilService: UtilService) {
25+
}
26+
27+
ngOnInit() {
28+
this.components = this.ProjectService.getComponentsByNodeId(this.nodeId).filter(component => {
29+
return this.ProjectService.componentHasWork(component);
30+
});
31+
this.selectedComponents = this.components.map(component => {
32+
return component.id;
33+
});
34+
}
35+
36+
getComponentTypeLabel(componentType) {
37+
return this.UtilService.getComponentTypeLabel(componentType);
38+
}
39+
40+
getSelectedText() {
41+
let nComponents = this.components.length;
42+
return this.upgrade.$injector.get('$filter')('translate')('selectedComponentsLabel', {
43+
selected: this.selectedComponents.length,
44+
total: nComponents
45+
});
46+
}
47+
48+
selectedComponentsChange() {
49+
const hiddenComponents = [];
50+
for (const component of this.components) {
51+
const id = component.id;
52+
if (this.selectedComponents.indexOf(id) < 0) {
53+
hiddenComponents.push(id);
54+
}
55+
}
56+
this.modelChange.emit(hiddenComponents);
57+
}
58+
}

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
@@ -22,6 +22,7 @@ import { ChooseNewComponentLocation } from './authoring-tool/add-component/choos
2222
import { ChooseImportStepComponent } from './authoring-tool/import-step/choose-import-step/choose-import-step.component';
2323
import { ChooseImportStepLocationComponent } from './authoring-tool/import-step/choose-import-step-location/choose-import-step-location.component';
2424
import { ComponentNewWorkBadgeComponent } from './classroom-monitor/component-new-work-badge/component-new-work-badge.component';
25+
import { ComponentSelectComponent } from './classroom-monitor/component-select/component-select.component';
2526
import { StatusIconComponent } from './classroom-monitor/status-icon/status-icon.component';
2627
import { AngularJSModule } from './common-hybrid-angular.module';
2728
import { NodeAdvancedJsonAuthoringComponent } from '../../../wise5/authoringTool/node/advanced/json/node-advanced-json-authoring.component';
@@ -43,6 +44,7 @@ import { RubricAuthoringComponent } from '../../../wise5/authoringTool/rubric/ru
4344
ChooseNewComponent,
4445
ChooseNewComponentLocation,
4546
ComponentNewWorkBadgeComponent,
47+
ComponentSelectComponent,
4648
EditComponentRubricComponent,
4749
EditComponentJsonComponent,
4850
EditComponentMaxScoreComponent,

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5968,6 +5968,24 @@
59685968
<context context-type="linenumber">36</context>
59695969
</context-group>
59705970
</trans-unit>
5971+
<trans-unit datatype="html" id="92159486420caf44d25e4f85cb0ed4f105d9c854">
5972+
<source>Assessment items to show</source>
5973+
<context-group purpose="location">
5974+
<context context-type="sourcefile">app/classroom-monitor/component-select/component-select.component.html</context>
5975+
<context context-type="linenumber">8</context>
5976+
</context-group>
5977+
<context-group purpose="location">
5978+
<context context-type="sourcefile">app/classroom-monitor/component-select/component-select.component.html</context>
5979+
<context context-type="linenumber">16</context>
5980+
</context-group>
5981+
</trans-unit>
5982+
<trans-unit datatype="html" id="6b8ecc745edb25da9e81cee606a8cae77549dde2">
5983+
<source> 1 assessment item </source>
5984+
<context-group purpose="location">
5985+
<context context-type="sourcefile">app/classroom-monitor/component-select/component-select.component.html</context>
5986+
<context context-type="linenumber">19</context>
5987+
</context-group>
5988+
</trans-unit>
59715989
<trans-unit datatype="html" id="7affaae0e14529c0192d5a4bfabd6fcb1ea27529">
59725990
<source>Rubric</source>
59735991
<context-group purpose="location">

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/componentSelect/componentSelect.ts

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

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

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

3+
import { ComponentSelectComponent } from '../../../../site/src/app/classroom-monitor/component-select/component-select.component';
34
import NodeGradingView from './nodeGradingView/nodeGradingView';
4-
import ComponentSelect from './componentSelect/componentSelect';
55
import StepTools from './stepTools/stepTools';
66
import WorkgroupItem from './workgroupItem/workgroupItem';
77
import * as angular from 'angular';
@@ -11,7 +11,8 @@ import { downgradeComponent } from '@angular/upgrade/static';
1111
const NodeGrading = angular
1212
.module('nodeGrading', [])
1313
.component('nodeGradingView', NodeGradingView)
14-
.component('componentSelect', ComponentSelect)
14+
.directive('componentSelect',
15+
downgradeComponent({ component: ComponentSelectComponent }) as angular.IDirectiveFactory)
1516
.component('cmStepTools', StepTools)
1617
.directive('workgroupInfo',
1718
downgradeComponent({ component: WorkgroupInfoComponent }) as angular.IDirectiveFactory)

src/main/webapp/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/nodeGradingView/nodeGradingView.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ <h2 class="content-head__item" ng-if="$ctrl.nodeHasWork">
1313
</div>
1414
<span flex></span>
1515
<div class="content-head__more" layout="row" layout-align="center center" layout-wrap>
16-
<component-select node-id="{{ ::$ctrl.nodeId }}" custom-class="'md-no-underline md-button'"
17-
on-change="$ctrl.onUpdateHiddenComponents(value)"></component-select>
16+
<component-select node-id="{{::$ctrl.nodeId}}"
17+
class="md-button md-no-underline"
18+
(model-change)="$ctrl.onUpdateHiddenComponents($event)"></component-select>
1819
<md-button ng-if="$ctrl.milestoneReport" ng-click="$ctrl.showReport($event)"
1920
class="md-raised info">
2021
<md-icon class="info"> flag </md-icon>

0 commit comments

Comments
 (0)