From e467edbe9e8a626feaa7c1731d7f19ceff44d0b3 Mon Sep 17 00:00:00 2001 From: amriith Date: Thu, 29 Aug 2024 17:06:19 +1000 Subject: [PATCH 1/2] refactor: migrated group-set-selector --- src/app/doubtfire-angular.module.ts | 3 +++ src/app/doubtfire-angularjs.module.ts | 9 +++++-- .../group-selector/group-selector.tpl.html | 8 +++---- .../group-set-selector.coffee | 18 -------------- .../group-set-selector.component.html | 3 +++ .../group-set-selector.component.ts | 24 +++++++++++++++++++ .../group-set-selector.tpl.html | 6 ----- src/app/groups/groups.coffee | 2 +- 8 files changed, 42 insertions(+), 31 deletions(-) delete mode 100644 src/app/groups/group-set-selector/group-set-selector.coffee create mode 100644 src/app/groups/group-set-selector/group-set-selector.component.html create mode 100644 src/app/groups/group-set-selector/group-set-selector.component.ts delete mode 100644 src/app/groups/group-set-selector/group-set-selector.tpl.html diff --git a/src/app/doubtfire-angular.module.ts b/src/app/doubtfire-angular.module.ts index 928474598..7f7c53b45 100644 --- a/src/app/doubtfire-angular.module.ts +++ b/src/app/doubtfire-angular.module.ts @@ -225,6 +225,7 @@ import {TasksViewerComponent} from './units/states/tasks/tasks-viewer/tasks-view import {UnitCodeComponent} from './common/unit-code/unit-code.component'; import {GradeService} from './common/services/grade.service'; +import {GroupSetSelectorComponent} from '/workspace/doubtfire-web/src/app/groups/group-set-selector/group-set-selector.component'; @NgModule({ // Components we declare declarations: [ @@ -325,6 +326,7 @@ import {GradeService} from './common/services/grade.service'; FUsersComponent, FTaskBadgeComponent, FUnitsComponent, + GroupSetSelectorComponent, ], // Services we provide providers: [ @@ -348,6 +350,7 @@ import {GradeService} from './common/services/grade.service'; UserService, TaskService, GradeService, + TaskSimilarityService, WebcalService, ActivityTypeService, diff --git a/src/app/doubtfire-angularjs.module.ts b/src/app/doubtfire-angularjs.module.ts index 868e38121..6aa06c3f7 100644 --- a/src/app/doubtfire-angularjs.module.ts +++ b/src/app/doubtfire-angularjs.module.ts @@ -91,7 +91,7 @@ import 'build/src/app/groups/group-set-manager/group-set-manager.js'; import 'build/src/app/groups/groups.js'; import 'build/src/app/groups/group-member-contribution-assigner/group-member-contribution-assigner.js'; import 'build/src/app/groups/group-member-list/group-member-list.js'; -import 'build/src/app/groups/group-set-selector/group-set-selector.js'; + import 'build/src/app/units/modals/unit-student-enrolment-modal/unit-student-enrolment-modal.js'; import 'build/src/app/units/modals/unit-ilo-edit-modal/unit-ilo-edit-modal.js'; import 'build/src/app/units/modals/modals.js'; @@ -220,7 +220,7 @@ import {FUnitTaskListComponent} from './units/states/tasks/viewer/directives/f-u import {FTaskDetailsViewComponent} from './units/states/tasks/viewer/directives/f-task-details-view/f-task-details-view.component'; import {FTaskSheetViewComponent} from './units/states/tasks/viewer/directives/f-task-sheet-view/f-task-sheet-view.component'; import {TasksViewerComponent} from './units/states/tasks/tasks-viewer/tasks-viewer.component'; - +import {GroupSetSelectorComponent} from '/workspace/doubtfire-web/src/app/groups/group-set-selector/group-set-selector.component'; import {FUnitsComponent} from './admin/states/f-units/f-units.component'; import {MarkedPipe} from './common/pipes/marked.pipe'; import {AlertService} from './common/services/alert.service'; @@ -235,6 +235,7 @@ export const DoubtfireAngularJSModule = angular.module('doubtfire', [ 'doubtfire.projects', 'doubtfire.groups', 'doubtfire.visualisations', + ]); // Downgrade angular modules that we need... @@ -321,6 +322,10 @@ DoubtfireAngularJSModule.directive( 'splashScreen', downgradeComponent({component: SplashScreenComponent}), ); +DoubtfireAngularJSModule.directive( + 'groupSetSelector', + downgradeComponent({component: GroupSetSelectorComponent}), +); DoubtfireAngularJSModule.directive( 'userBadge', downgradeComponent({component: UserBadgeComponent}), diff --git a/src/app/groups/group-selector/group-selector.tpl.html b/src/app/groups/group-selector/group-selector.tpl.html index 3e52cc440..02c420f97 100644 --- a/src/app/groups/group-selector/group-selector.tpl.html +++ b/src/app/groups/group-selector/group-selector.tpl.html @@ -3,10 +3,10 @@

Groups for {{selectedGroupSet.name}}

diff --git a/src/app/groups/group-set-selector/group-set-selector.coffee b/src/app/groups/group-set-selector/group-set-selector.coffee deleted file mode 100644 index 62e99b74d..000000000 --- a/src/app/groups/group-set-selector/group-set-selector.coffee +++ /dev/null @@ -1,18 +0,0 @@ -angular.module('doubtfire.groups.group-set-selector', []) - -# -# Directive that can switch context of a specific group set -# -.directive('groupSetSelector', -> - restrict: 'E' - templateUrl: 'groups/group-set-selector/group-set-selector.tpl.html' - scope: - unit: '=' - selectedGroupSet: '=ngModel' - onSelectGroupSet: '=onChange' - controller: ($scope) -> - unless $scope.unit? - throw Error "Unit not supplied to group set selector" - $scope.selectGroupSet = -> - $scope.onSelectGroupSet?($scope.selectedGroupSet) -) diff --git a/src/app/groups/group-set-selector/group-set-selector.component.html b/src/app/groups/group-set-selector/group-set-selector.component.html new file mode 100644 index 000000000..98d05e0c5 --- /dev/null +++ b/src/app/groups/group-set-selector/group-set-selector.component.html @@ -0,0 +1,3 @@ + diff --git a/src/app/groups/group-set-selector/group-set-selector.component.ts b/src/app/groups/group-set-selector/group-set-selector.component.ts new file mode 100644 index 000000000..465f9c2ff --- /dev/null +++ b/src/app/groups/group-set-selector/group-set-selector.component.ts @@ -0,0 +1,24 @@ +import {Component, Input, Output, EventEmitter, OnInit} from '@angular/core'; +import {Unit, GroupSet} from '/workspace/doubtfire-web/src/app/api/models/doubtfire-model'; + +@Component({ + // eslint-disable-next-line @angular-eslint/component-selector + selector: 'group-set-selector', + templateUrl: './group-set-selector.component.html', +}) +export class GroupSetSelectorComponent implements OnInit { + @Input() unit: Unit; + @Input() selectedGroupSet: GroupSet; + @Output() selectGroupSet = new EventEmitter(); // Renamed to follow Angular conventions + + ngOnInit() { + if (!this.unit) { + throw new Error('Unit not supplied to group set selector'); + } + } + + onGroupSetSelect() { + // Method name changed to be more descriptive and avoid confusion with the @Output name + this.selectGroupSet.emit(this.selectedGroupSet); + } +} diff --git a/src/app/groups/group-set-selector/group-set-selector.tpl.html b/src/app/groups/group-set-selector/group-set-selector.tpl.html deleted file mode 100644 index e735686bb..000000000 --- a/src/app/groups/group-set-selector/group-set-selector.tpl.html +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/src/app/groups/groups.coffee b/src/app/groups/groups.coffee index 031080f0b..9f50709bc 100644 --- a/src/app/groups/groups.coffee +++ b/src/app/groups/groups.coffee @@ -3,5 +3,5 @@ angular.module('doubtfire.groups', [ 'doubtfire.groups.group-member-list' 'doubtfire.groups.group-selector' 'doubtfire.groups.group-set-manager' - 'doubtfire.groups.group-set-selector' + ]) From 3a4e8b55c260b1fbf5677ac2f75a899098101e60 Mon Sep 17 00:00:00 2001 From: amriith Date: Tue, 24 Sep 2024 12:19:35 +1000 Subject: [PATCH 2/2] refactor: migrated group-set-selector --- src/app/doubtfire-angular.module.ts | 2 +- src/app/doubtfire-angularjs.module.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/doubtfire-angular.module.ts b/src/app/doubtfire-angular.module.ts index 7f7c53b45..5297e541d 100644 --- a/src/app/doubtfire-angular.module.ts +++ b/src/app/doubtfire-angular.module.ts @@ -225,7 +225,7 @@ import {TasksViewerComponent} from './units/states/tasks/tasks-viewer/tasks-view import {UnitCodeComponent} from './common/unit-code/unit-code.component'; import {GradeService} from './common/services/grade.service'; -import {GroupSetSelectorComponent} from '/workspace/doubtfire-web/src/app/groups/group-set-selector/group-set-selector.component'; +import {GroupSetSelectorComponent} from './groups/group-set-selector/group-set-selector.component'; @NgModule({ // Components we declare declarations: [ diff --git a/src/app/doubtfire-angularjs.module.ts b/src/app/doubtfire-angularjs.module.ts index 6aa06c3f7..3e56581e6 100644 --- a/src/app/doubtfire-angularjs.module.ts +++ b/src/app/doubtfire-angularjs.module.ts @@ -220,7 +220,7 @@ import {FUnitTaskListComponent} from './units/states/tasks/viewer/directives/f-u import {FTaskDetailsViewComponent} from './units/states/tasks/viewer/directives/f-task-details-view/f-task-details-view.component'; import {FTaskSheetViewComponent} from './units/states/tasks/viewer/directives/f-task-sheet-view/f-task-sheet-view.component'; import {TasksViewerComponent} from './units/states/tasks/tasks-viewer/tasks-viewer.component'; -import {GroupSetSelectorComponent} from '/workspace/doubtfire-web/src/app/groups/group-set-selector/group-set-selector.component'; +import {GroupSetSelectorComponent} from './groups/group-set-selector/group-set-selector.component'; import {FUnitsComponent} from './admin/states/f-units/f-units.component'; import {MarkedPipe} from './common/pipes/marked.pipe'; import {AlertService} from './common/services/alert.service';