Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Classroom Monitor): Update workgroup name on previous/next click #1389

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { filter, map, startWith } from 'rxjs/operators';
import { ConfigService } from '../../../../assets/wise5/services/configService';
import { TeacherDataService } from '../../../../assets/wise5/services/teacherDataService';
import { copy } from '../../../../assets/wise5/common/object/object';
import { EventEmitter } from 'stream';

@Component({
selector: 'workgroup-select-autocomplete',
Expand All @@ -17,20 +16,20 @@ import { EventEmitter } from 'stream';
encapsulation: ViewEncapsulation.None
})
export class WorkgroupSelectAutocompleteComponent extends WorkgroupSelectComponent {
myControl = new FormControl();
filteredWorkgroups: Observable<any>;
myControl = new FormControl();

constructor(
protected ConfigService: ConfigService,
protected TeacherDataService: TeacherDataService
protected configService: ConfigService,
protected teacherDataService: TeacherDataService
) {
super(ConfigService, TeacherDataService);
super(configService, teacherDataService);
}

ngOnInit() {
super.ngOnInit();
this.updateFilteredWorkgroups();
const currentWorkgroup = this.TeacherDataService.getCurrentWorkgroup();
const currentWorkgroup = this.teacherDataService.getCurrentWorkgroup();
if (currentWorkgroup) {
this.myControl.setValue(currentWorkgroup.displayNames);
}
Expand Down Expand Up @@ -67,6 +66,10 @@ export class WorkgroupSelectAutocompleteComponent extends WorkgroupSelectCompone
this.updateFilteredWorkgroups();
}

protected setWorkgroup(workgroup: any): void {
this.updateWorkgroupDisplay(workgroup);
}

getStudentsFromWorkgroups() {
const students = [];
for (const workgroup of this.workgroups) {
Expand All @@ -93,6 +96,10 @@ export class WorkgroupSelectAutocompleteComponent extends WorkgroupSelectCompone

itemSelected(workgroup: any) {
this.setCurrentWorkgroup(workgroup);
this.updateWorkgroupDisplay(workgroup);
}

private updateWorkgroupDisplay(workgroup: any): void {
if (workgroup) {
this.myControl.setValue(workgroup.displayNames);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ import { TeacherDataService } from '../../../assets/wise5/services/teacherDataSe

@Directive({ selector: 'workgroup-select' })
export class WorkgroupSelectComponent {
@Input()
customClass: string;
@Input() customClass: string;
canViewStudentNames: boolean;
periodId: number;
selectedItem: any;
workgroups: any;
subscriptions: Subscription = new Subscription();
workgroups: any;

constructor(
protected ConfigService: ConfigService,
protected TeacherDataService: TeacherDataService
protected configService: ConfigService,
protected teacherDataService: TeacherDataService
) {}

ngOnInit() {
this.canViewStudentNames = this.ConfigService.getPermissions().canViewStudentNames;
this.periodId = this.TeacherDataService.getCurrentPeriod().periodId;
this.canViewStudentNames = this.configService.getPermissions().canViewStudentNames;
this.periodId = this.teacherDataService.getCurrentPeriod().periodId;
this.setWorkgroups();
this.subscriptions.add(
this.TeacherDataService.currentWorkgroupChanged$.subscribe(({ currentWorkgroup }) => {
this.teacherDataService.currentWorkgroupChanged$.subscribe(({ currentWorkgroup }) => {
if (currentWorkgroup != null) {
this.setWorkgroups();
this.setWorkgroup(currentWorkgroup);
}
})
);
this.subscriptions.add(
this.TeacherDataService.currentPeriodChanged$.subscribe(({ currentPeriod }) => {
this.teacherDataService.currentPeriodChanged$.subscribe(({ currentPeriod }) => {
this.periodId = currentPeriod.periodId;
this.setWorkgroups();
this.currentPeriodChanged();
Expand All @@ -46,6 +46,8 @@ export class WorkgroupSelectComponent {

setWorkgroups() {}

protected setWorkgroup(workgroup: any): void {}

currentPeriodChanged() {}

sortByField(arr: any[], field: string): any[] {
Expand All @@ -61,7 +63,7 @@ export class WorkgroupSelectComponent {
}

filterWorkgroupsBySelectedPeriod() {
this.workgroups = this.ConfigService.getClassmateUserInfos().filter((workgroup) => {
this.workgroups = this.configService.getClassmateUserInfos().filter((workgroup) => {
return (
(this.periodId === -1 || workgroup.periodId === this.periodId) &&
workgroup.workgroupId != null
Expand All @@ -70,6 +72,6 @@ export class WorkgroupSelectComponent {
}

setCurrentWorkgroup(workgroup) {
this.TeacherDataService.setCurrentWorkgroup(workgroup);
this.teacherDataService.setCurrentWorkgroup(workgroup);
}
}
Loading