From 0a0b7f5c5d3f2628f932262f3deda2c4a0cc2401 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Fri, 2 Apr 2021 16:14:00 -0700 Subject: [PATCH] Converted remaining AT controllers into components. Worked on info, asset, notebook, milestones, wiselink, and authoringTool controllers. Some of them (e.g. assetController) could not fully be converted because it is being used in mdDialog. Removed unnecessary variables. Changed let to const where applicable. #36 --- src/app/services/projectAssetService.ts | 6 +- .../wise5/authoringTool/asset/asset.html | 105 ------------- .../authoringTool/asset/assetAuthoring.html | 100 +++++++++++++ ...r.ts => projectAssetAuthoringComponent.ts} | 35 ++--- .../wise5/authoringTool/authoringTool.html | 36 ++--- ...ontroller.ts => authoringToolComponent.ts} | 74 +++------ src/assets/wise5/authoringTool/info/info.html | 58 -------- .../authoringTool/info/infoAuthoring.html | 58 ++++++++ ...er.ts => projectInfoAuthoringComponent.ts} | 30 ++-- .../milestones/milestonesAuthoring.html | 140 +++++++++--------- ...ler.ts => milestonesAuthoringComponent.ts} | 35 +++-- .../notebook/notebookAuthoring.html | 132 ++++++++--------- ...oller.ts => notebookAuthoringComponent.ts} | 24 +-- .../wiseLink/wiseLinkAuthoring.html | 28 ++-- .../wise5/services/teacherProjectService.ts | 2 +- .../teacher/teacher-angular-js-module.ts | 49 +++--- 16 files changed, 415 insertions(+), 497 deletions(-) delete mode 100644 src/assets/wise5/authoringTool/asset/asset.html create mode 100644 src/assets/wise5/authoringTool/asset/assetAuthoring.html rename src/assets/wise5/authoringTool/asset/{projectAssetController.ts => projectAssetAuthoringComponent.ts} (94%) rename src/assets/wise5/authoringTool/{authoringToolController.ts => authoringToolComponent.ts} (87%) delete mode 100644 src/assets/wise5/authoringTool/info/info.html create mode 100644 src/assets/wise5/authoringTool/info/infoAuthoring.html rename src/assets/wise5/authoringTool/info/{projectInfoController.ts => projectInfoAuthoringComponent.ts} (89%) rename src/assets/wise5/authoringTool/milestones/{milestonesAuthoringController.ts => milestonesAuthoringComponent.ts} (98%) rename src/assets/wise5/authoringTool/notebook/{authorNotebookController.ts => notebookAuthoringComponent.ts} (89%) diff --git a/src/app/services/projectAssetService.ts b/src/app/services/projectAssetService.ts index 679c7e0ed5..efbbc30d3f 100644 --- a/src/app/services/projectAssetService.ts +++ b/src/app/services/projectAssetService.ts @@ -235,9 +235,9 @@ export class ProjectAssetService { openAssetChooser(params: any) { return this.upgrade.$injector.get('$mdDialog').show({ - templateUrl: 'assets/wise5/authoringTool/asset/asset.html', - controller: 'ProjectAssetController', - controllerAs: 'projectAssetController', + templateUrl: 'assets/wise5/authoringTool/asset/assetAuthoring.html', + controller: 'ProjectAssetAuthoringController', + controllerAs: '$ctrl', $stateParams: params, clickOutsideToClose: true, escapeToClose: true diff --git a/src/assets/wise5/authoringTool/asset/asset.html b/src/assets/wise5/authoringTool/asset/asset.html deleted file mode 100644 index 23446473df..0000000000 --- a/src/assets/wise5/authoringTool/asset/asset.html +++ /dev/null @@ -1,105 +0,0 @@ - - -
- -({{ ::'unusedFiles' | translate }} {{projectAssetController.totalUnusedFilesSize | appropriateSizeText}} ({{projectAssetController.unusedFilesPercentage | roundToDecimal:0}}%)) - -
- {{projectAssetController.uploadSuccessMessage}} -
- {{::successFile.filename}} -
-
-
- {{projectAssetController.uploadErrorMessage}} -
- {{::errorFile.filename}} {{::errorFile.message}} -
-
-: -
-
-
    -
  • - {{::assetItem.fileName}} ({{::assetItem.fileSize | appropriateSizeText}}) - - - - file_download - - delete - - ({{ ::'notUsed' | translate }}) - -
  • -
-
-
-
- - -
-
-
diff --git a/src/assets/wise5/authoringTool/asset/assetAuthoring.html b/src/assets/wise5/authoringTool/asset/assetAuthoring.html new file mode 100644 index 0000000000..63f70f4062 --- /dev/null +++ b/src/assets/wise5/authoringTool/asset/assetAuthoring.html @@ -0,0 +1,100 @@ + + +
+ +({{ ::'unusedFiles' | translate }} {{$ctrl.totalUnusedFilesSize | appropriateSizeText}} ({{$ctrl.unusedFilesPercentage | roundToDecimal:0}}%)) + +
+ {{$ctrl.uploadSuccessMessage}} +
+ {{::successFile.filename}} +
+
+
+ {{$ctrl.uploadErrorMessage}} +
+ {{::errorFile.filename}} {{::errorFile.message}} +
+
+: +
+
+
    +
  • + {{::assetItem.fileName}} ({{::assetItem.fileSize | appropriateSizeText}}) + + + + file_download + + delete + + ({{ ::'notUsed' | translate }}) + +
  • +
+
+
+
+ + +
+
+
diff --git a/src/assets/wise5/authoringTool/asset/projectAssetController.ts b/src/assets/wise5/authoringTool/asset/projectAssetAuthoringComponent.ts similarity index 94% rename from src/assets/wise5/authoringTool/asset/projectAssetController.ts rename to src/assets/wise5/authoringTool/asset/projectAssetAuthoringComponent.ts index c60673ba5e..18b1050b36 100644 --- a/src/assets/wise5/authoringTool/asset/projectAssetController.ts +++ b/src/assets/wise5/authoringTool/asset/projectAssetAuthoringComponent.ts @@ -5,7 +5,7 @@ import { ConfigService } from '../../services/configService'; import { ProjectAssetService } from '../../../../app/services/projectAssetService'; import * as $ from 'jquery'; -class ProjectAssetController { +export class ProjectAssetAuthoringController { $translate: any; projectId: number; projectAssets: any; @@ -36,10 +36,8 @@ class ProjectAssetController { static $inject = [ '$filter', '$mdDialog', - '$rootScope', '$state', '$stateParams', - '$scope', '$timeout', 'ConfigService', 'ProjectAssetService', @@ -49,16 +47,17 @@ class ProjectAssetController { constructor( $filter: any, private $mdDialog: any, - private $rootScope: any, private $state: any, private $stateParams: any, - private $scope: any, private $timeout: any, private ConfigService: ConfigService, private ProjectAssetService: ProjectAssetService, private UtilService: UtilService ) { this.$translate = $filter('translate'); + } + + $onInit() { this.projectId = this.$stateParams.projectId; this.totalFileSize = 0; this.totalUnusedFilesSize = 0; @@ -69,27 +68,21 @@ class ProjectAssetController { if (stateParams.isPopup != null) { this.isPopup = true; } - if (stateParams.projectId != null) { this.projectId = stateParams.projectId; } - if (stateParams.nodeId != null) { this.nodeId = stateParams.nodeId; } - if (stateParams.componentId != null) { this.componentId = stateParams.componentId; } - if (stateParams.target != null) { this.target = stateParams.target; } - if (stateParams.targetObject != null) { this.targetObject = stateParams.targetObject; } - if (stateParams.allowedFileTypes != null) { this.allowedFileTypes = this.$stateParams.allowedFileTypes; } @@ -120,13 +113,9 @@ class ProjectAssetController { if (this.ProjectAssetService.isProjectAssetsAvailable()) { this.ProjectAssetService.calculateAssetUsage(); } - - this.$scope.$on('$destroy', () => { - this.unsubscribeAll(); - }); } - unsubscribeAll() { + $onDestory() { this.getProjectAssetsSubscription.unsubscribe(); this.getTotalFileSizeSubscription.unsubscribe(); this.getTotalUnusedFileSizeSubscription.unsubscribe(); @@ -172,10 +161,6 @@ class ProjectAssetController { return 0; } - /** - * Delete an asset from the project after confirming with the user - * @param assetItem the asset to delete - */ deleteAsset(assetItem) { const message = `${this.$translate('areYouSureYouWantToDeleteThisFile')}\n\n${ assetItem.fileName @@ -201,11 +186,6 @@ class ProjectAssetController { this.$mdDialog.hide(params); } - /** - * Upload all the small files. If there are any large files, we will confirm with the author - * that they want to upload those files. - * @param files An array of file objects. - */ uploadAssetItems(files) { let performUploadOfAllFiles = true; const largeAndSmallFiles = this.separateLargeAndSmallFiles(files); @@ -341,4 +321,7 @@ class ProjectAssetController { } } -export default ProjectAssetController; +export const ProjectAssetAuthoringComponent = { + templateUrl: `/wise5/authoringTool/asset/assetAuthoring.html`, + controller: ProjectAssetAuthoringController +}; diff --git a/src/assets/wise5/authoringTool/authoringTool.html b/src/assets/wise5/authoringTool/authoringTool.html index 35454a4ca8..a8ff15add2 100644 --- a/src/assets/wise5/authoringTool/authoringTool.html +++ b/src/assets/wise5/authoringTool/authoringTool.html @@ -8,31 +8,25 @@
- - - - + + + +
- - +
diff --git a/src/assets/wise5/authoringTool/authoringToolController.ts b/src/assets/wise5/authoringTool/authoringToolComponent.ts similarity index 87% rename from src/assets/wise5/authoringTool/authoringToolController.ts rename to src/assets/wise5/authoringTool/authoringToolComponent.ts index 41bfcba15f..7d46e01e76 100644 --- a/src/assets/wise5/authoringTool/authoringToolController.ts +++ b/src/assets/wise5/authoringTool/authoringToolComponent.ts @@ -10,15 +10,7 @@ import { TeacherProjectService } from '../services/teacherProjectService'; @Directive() class AuthoringToolController { - $anchorScroll: any; - $filter: any; - $mdDialog: any; - $rootScope: any; - $scope: any; - $state: any; - $transitions: any; $translate: any; - $timeout: any; currentViewName: string; isMenuOpen: boolean = false; logoPath: string; @@ -30,11 +22,6 @@ class AuthoringToolController { showStepTools: boolean = false; showToolbar: boolean = true; views: any; - ConfigService: ConfigService; - NotificationService: NotificationService; - ProjectService: TeacherProjectService; - SessionService: SessionService; - TeacherDataService: TeacherDataService; errorSavingProjectSubscription: Subscription; notAllowedToEditThisProjectSubscription: Subscription; notLoggedInProjectNotSavedSubscription: Subscription; @@ -46,8 +33,6 @@ class AuthoringToolController { '$anchorScroll', '$filter', '$mdDialog', - '$rootScope', - '$scope', '$state', '$transitions', '$timeout', @@ -59,35 +44,23 @@ class AuthoringToolController { ]; constructor( - $anchorScroll, + private $anchorScroll: any, $filter, - $mdDialog, - $rootScope, - $scope, - $state, - $transitions, - $timeout, - ConfigService, - NotificationService, - ProjectService, - SessionService, - TeacherDataService + private $mdDialog: any, + private $state: any, + private $transitions: any, + private $timeout: any, + private ConfigService: ConfigService, + private NotificationService: NotificationService, + private ProjectService: TeacherProjectService, + private SessionService: SessionService, + private TeacherDataService: TeacherDataService ) { - this.$anchorScroll = $anchorScroll; - this.$filter = $filter; - this.$mdDialog = $mdDialog; - this.$rootScope = $rootScope; - this.$scope = $scope; - this.$state = $state; - this.$transitions = $transitions; - this.$timeout = $timeout; - this.$translate = this.$filter('translate'); - this.ConfigService = ConfigService; - this.NotificationService = NotificationService; - this.ProjectService = ProjectService; - this.SessionService = SessionService; - this.TeacherDataService = TeacherDataService; - this.logoPath = ProjectService.getThemePath() + '/images/WISE-logo-ffffff.svg'; + this.$translate = $filter('translate'); + } + + $onInit() { + this.logoPath = this.ProjectService.getThemePath() + '/images/WISE-logo-ffffff.svg'; this.views = { 'root.at.project': { id: 'projectHomeButton', @@ -226,7 +199,7 @@ class AuthoringToolController { }; this.processUI(); - $transitions.onSuccess({}, ($transition) => { + this.$transitions.onSuccess({}, ($transition) => { this.isMenuOpen = false; this.processUI(); if ($transition.name === 'root.at.main') { @@ -300,17 +273,9 @@ class AuthoringToolController { this.setGlobalMessage(this.$translate('notAllowedToEditThisProject'), false, null); }, 1000); } - - this.$scope.$on('$destroy', () => { - this.ngOnDestroy(); - }); - } - - ngOnDestroy() { - this.unsubscribeAll(); } - unsubscribeAll() { + $onDestroy() { this.errorSavingProjectSubscription.unsubscribe(); this.notAllowedToEditThisProjectSubscription.unsubscribe(); this.notLoggedInProjectNotSavedSubscription.unsubscribe(); @@ -407,4 +372,7 @@ class AuthoringToolController { } } -export default AuthoringToolController; +export const AuthoringToolComponent = { + templateUrl: `/wise5/authoringTool/authoringTool.html`, + controller: AuthoringToolController +}; diff --git a/src/assets/wise5/authoringTool/info/info.html b/src/assets/wise5/authoringTool/info/info.html deleted file mode 100644 index dfe0b6a6b1..0000000000 --- a/src/assets/wise5/authoringTool/info/info.html +++ /dev/null @@ -1,58 +0,0 @@ -

{{ ::'projectIcon' | translate }}

-
-
-
- -
-
-

{{ ::'thisProjectDoesNotHaveAProjectIcon' | translate }}

-
-

{{ ::'clickTheEditButtonToSetOne' | translate }}

-
-
- -
-
-
-
- {{ ::'chooseANewProjectIcon' | translate }} -
-
- -
-
-
-
- {{ metadataField.name }}: - - -
- - {{ projectInfoController.getMetadataChoiceText(choice) }} -
-
- -
-
-
diff --git a/src/assets/wise5/authoringTool/info/infoAuthoring.html b/src/assets/wise5/authoringTool/info/infoAuthoring.html new file mode 100644 index 0000000000..95163c9503 --- /dev/null +++ b/src/assets/wise5/authoringTool/info/infoAuthoring.html @@ -0,0 +1,58 @@ +

{{ ::'projectIcon' | translate }}

+
+
+
+ +
+
+

{{ ::'thisProjectDoesNotHaveAProjectIcon' | translate }}

+
+

{{ ::'clickTheEditButtonToSetOne' | translate }}

+
+
+ +
+
+
+
+ {{ ::'chooseANewProjectIcon' | translate }} +
+
+ +
+
+
+
+ {{ metadataField.name }}: + + +
+ + {{ $ctrl.getMetadataChoiceText(choice) }} +
+
+ +
+
+
diff --git a/src/assets/wise5/authoringTool/info/projectInfoController.ts b/src/assets/wise5/authoringTool/info/projectInfoAuthoringComponent.ts similarity index 89% rename from src/assets/wise5/authoringTool/info/projectInfoController.ts rename to src/assets/wise5/authoringTool/info/projectInfoAuthoringComponent.ts index 4258210a40..59b32fced7 100644 --- a/src/assets/wise5/authoringTool/info/projectInfoController.ts +++ b/src/assets/wise5/authoringTool/info/projectInfoAuthoringComponent.ts @@ -4,7 +4,7 @@ import { ProjectAssetService } from '../../../../app/services/projectAssetServic import { ConfigService } from '../../services/configService'; import { TeacherProjectService } from '../../services/teacherProjectService'; -class ProjectInfoController { +class ProjectInfoAuthoringController { $translate: any; isEditingProjectIcon: boolean = false; isShowProjectIcon: boolean = false; @@ -18,8 +18,6 @@ class ProjectInfoController { static $inject = [ '$filter', '$mdDialog', - '$rootScope', - '$scope', '$timeout', 'ConfigService', 'ProjectAssetService', @@ -29,14 +27,15 @@ class ProjectInfoController { constructor( $filter, private $mdDialog: any, - private $rootScope: any, - private $scope: any, private $timeout: any, private ConfigService: ConfigService, private ProjectAssetService: ProjectAssetService, private ProjectService: TeacherProjectService ) { this.$translate = $filter('translate'); + } + + $onInit() { this.metadata = this.ProjectService.getProjectMetadata(); this.metadataAuthoring = JSON.parse( this.ConfigService.getConfigParam('projectMetadataSettings') @@ -47,7 +46,7 @@ class ProjectInfoController { processMetadata() { if (this.metadataAuthoring != null) { - for (let field of this.metadataAuthoring.fields) { + for (const field of this.metadataAuthoring.fields) { this.processMetadataAuthoringField(field); } } @@ -85,11 +84,10 @@ class ProjectInfoController { } // returns the choice text that is appropriate for user's locale - getMetadataChoiceText(choice) { + getMetadataChoiceText(choice: string): string { let choiceText = choice; - let userLocale = this.ConfigService.getLocale(); - let i18nMapping = this.metadataAuthoring.i18n; - let i18nMappingContainingChoiceTextArray = Object.values(i18nMapping).filter( + const i18nMapping = this.metadataAuthoring.i18n; + const i18nMappingContainingChoiceTextArray = Object.values(i18nMapping).filter( (onei18nMapping) => { return Object.values(onei18nMapping).indexOf(choice) != -1; } @@ -99,7 +97,8 @@ class ProjectInfoController { i18nMappingContainingChoiceTextArray.length > 0 ) { // shouldn't be more than one, but if so, use the first one we find - let i18nMappingContainingChoiceText = i18nMappingContainingChoiceTextArray[0]; + const i18nMappingContainingChoiceText = i18nMappingContainingChoiceTextArray[0]; + const userLocale = this.ConfigService.getLocale(); if (i18nMappingContainingChoiceText[userLocale] != null) { choiceText = i18nMappingContainingChoiceText[userLocale]; } @@ -114,10 +113,10 @@ class ProjectInfoController { ); } - metadataCheckboxClicked(metadataField, choice) { + metadataCheckboxClicked(metadataField) { const checkedChoices = []; for (const choice of metadataField.choices) { - let isChoiceChecked = metadataField.choicesMapping[choice]; + const isChoiceChecked = metadataField.choicesMapping[choice]; if (isChoiceChecked) { checkedChoices.push(this.getMetadataChoiceText(choice)); } @@ -230,4 +229,7 @@ class ProjectInfoController { } } -export default ProjectInfoController; +export const ProjectInfoAuthoringComponent = { + templateUrl: `/wise5/authoringTool/info/infoAuthoring.html`, + controller: ProjectInfoAuthoringController +}; diff --git a/src/assets/wise5/authoringTool/milestones/milestonesAuthoring.html b/src/assets/wise5/authoringTool/milestones/milestonesAuthoring.html index 8cc00ba0cd..52ad75865b 100644 --- a/src/assets/wise5/authoringTool/milestones/milestonesAuthoring.html +++ b/src/assets/wise5/authoringTool/milestones/milestonesAuthoring.html @@ -3,44 +3,44 @@

{{ ::'MILESTONES_AUTHORING' | translate }}

- + ng-change="$ctrl.save()"> {{ ::'enableMilestones' | translate }} -
- + add {{ ::'addMilestone' | translate }} -
+
+ ng-if="$ctrl.idToExpanded[item.id]" + ng-click="$ctrl.collapse(item.id)"> keyboard_arrow_down {{ ::'clickToCollapse' | translate }} + ng-if="!$ctrl.idToExpanded[item.id]" + ng-click="$ctrl.expand(item.id)"> keyboard_arrow_right {{ ::'clickToExpand' | translate }}
{{ ::'milestone' | translate }} {{ $index + 1 }}
+ ng-click="$ctrl.deleteMilestone($index)"> delete {{ ::'deleteMilestone' | translate }} -
+ ng-change="$ctrl.save()"> @@ -48,13 +48,13 @@
{{ ::'milestone' | translate }} {{ $index + 1 }} + ng-change="$ctrl.save()"> + ng-change="$ctrl.save()"> {{ ::'enableSatisfyCriteria' | translate }}
@@ -64,7 +64,7 @@
{{ ::'satisfyCriteria' | translate }}
+ ng-change="$ctrl.save()"> @@ -72,25 +72,25 @@
{{ ::'satisfyCriteria' | translate }}
+ ng-change="$ctrl.save()">
+ ng-change="$ctrl.save()"> {{ ::'any' | translate }} {{ ::'all' | translate }} - + add {{ ::'addMilestoneSatisfyCriteria' | translate }}
{{ ::'milestoneSatisfyCriteria' | translate }} {{ $index + 1 }}
+ ng-click="$ctrl.deleteMilestoneSatisfyCriteria(item, $index)"> delete {{ ::'deleteMilestoneSatisfyCriteria' | translate }} @@ -98,19 +98,19 @@
{{ ::'milestoneSatisfyCriteria' | translate }} {{ $ - + - {{milestonesAuthoringController.getNodePositionAndTitleByNodeId(nodeItem.$key)}} + ng-if="$ctrl.isApplicationNode(nodeItem.$key)"> + {{$ctrl.getNodePositionAndTitleByNodeId(nodeItem.$key)}} - + {{ componentIndex + 1 }}. {{component.type}} @@ -119,18 +119,18 @@
{{ ::'milestoneSatisfyCriteria' | translate }} {{ $ - + {{availableSatisfyCriteria.text}} + ng-click="$ctrl.copySatisfyCriteriaToMilestone(item, satisfyCriteria.nodeId, satisfyCriteria.componentId)"> content_copy {{ ::'copyNodeIdAndComponentIdToMilestone' | translate }}
- + add {{ ::'addMilestoneSatisfyCriteria' | translate }} @@ -140,7 +140,7 @@
{{ ::'milestoneSatisfyCriteria' | translate }} {{ $
{{ ::'report' | translate }}
- add {{ ::'addReportLocation' | translate }} @@ -152,31 +152,31 @@
{{ ::'location' | translate }} {{ $index + 1 }}
- + - {{milestonesAuthoringController.getNodePositionAndTitleByNodeId(nodeItem.$key)}} + ng-if="$ctrl.isApplicationNode(nodeItem.$key)"> + {{$ctrl.getNodePositionAndTitleByNodeId(nodeItem.$key)}} - + {{ componentIndex + 1 }}. {{component.type}} + ng-click="$ctrl.deleteLocation(item.report, $index)"> delete {{ ::'deleteLocation' | translate }}
- add {{ ::'addReportLocation' | translate }} @@ -188,27 +188,27 @@
{{ ::'customScoreValues' | translate }}
style="margin-left: 20px;"> {{ key }}: {{ value }} + ng-click="$ctrl.deleteCustomScoreValues(item.report, key)"> delete {{ ::'deleteCustomScoreValues' | translate }}
- + - - add {{ ::'addCustomScoreValues' | translate }}
- add {{ ::'addTemplate' | translate }} @@ -216,36 +216,36 @@
{{ ::'customScoreValues' | translate }}
+ ng-if="$ctrl.idToExpanded[template.id]" + ng-click="$ctrl.collapse(template.id)"> keyboard_arrow_down {{ ::'clickToCollapse' | translate }} + ng-if="!$ctrl.idToExpanded[template.id]" + ng-click="$ctrl.expand(template.id)"> keyboard_arrow_right {{ ::'clickToExpand' | translate }}
{{ ::'template' | translate }} {{ $index + 1 }}
- delete {{ ::'deleteTemplate' | translate }} -
+ ng-change="$ctrl.save()"> {{ ::'any' | translate }} {{ ::'all' | translate }}
- add {{ ::'addTemplateSatisfyCriteria' | translate }} @@ -253,7 +253,7 @@
{{ ::'template' | translate }} {{ $index + 1 }}
{{ ::'templateSatisfyCriteria' | translate }} {{ $index + 1 }}
- delete {{ ::'deleteTemplateSatisfyCriteria' | translate }} @@ -262,19 +262,19 @@
{{ ::'templateSatisfyCriteria' | translate }} {{ $ - + - {{milestonesAuthoringController.getNodePositionAndTitleByNodeId(nodeItem.$key)}} + ng-if="$ctrl.isApplicationNode(nodeItem.$key)"> + {{$ctrl.getNodePositionAndTitleByNodeId(nodeItem.$key)}} - + {{ componentIndex + 1 }}. {{component.type}} @@ -284,8 +284,8 @@
{{ ::'templateSatisfyCriteria' | translate }} {{ $ - + {{ availableSatisfyCriteriaFunction.text }} @@ -296,30 +296,30 @@
{{ ::'templateSatisfyCriteria' | translate }} {{ $ + ng-change="$ctrl.save()"/>
+ ng-change="$ctrl.save()"/> + ng-change="$ctrl.save()"/> + ng-change="$ctrl.save()"/>
- add {{ ::'addTemplateSatisfyCriteria' | translate }} @@ -331,7 +331,7 @@
{{ ::'templateSatisfyCriteria' | translate }} {{ $ ng-model-options="{ debounce: 1000 }" class="ng-pristine ng-untouched ng-valid md-input ng-not-empty" style="border: 1px solid black;" - ng-change="milestonesAuthoringController.save()"> + ng-change="$ctrl.save()"> @@ -340,7 +340,7 @@
{{ ::'templateSatisfyCriteria' | translate }} {{ $ ng-model-options="{ debounce: 1000 }" class="ng-pristine ng-untouched ng-valid md-input ng-not-empty" style="border: 1px solid black;" - ng-change="milestonesAuthoringController.save()"> + ng-change="$ctrl.save()"> {{ ::'contentPreview' | translate }} @@ -356,7 +356,7 @@
{{ ::'templateSatisfyCriteria' | translate }} {{ $ ng-model-options="{ debounce: 1000 }" class="ng-pristine ng-untouched ng-valid md-input ng-not-empty" style="border: 1px solid black;" - ng-change="milestonesAuthoringController.save()"> + ng-change="$ctrl.save()"> {{ ::'recommendationsPreview' | translate }} @@ -368,7 +368,7 @@
{{ ::'templateSatisfyCriteria' | translate }} {{ $
- add {{ ::'addTemplate' | translate }} @@ -379,7 +379,7 @@
{{ ::'templateSatisfyCriteria' | translate }} {{ $
- + add {{ ::'addMilestone' | translate }} diff --git a/src/assets/wise5/authoringTool/milestones/milestonesAuthoringController.ts b/src/assets/wise5/authoringTool/milestones/milestonesAuthoringComponent.ts similarity index 98% rename from src/assets/wise5/authoringTool/milestones/milestonesAuthoringController.ts rename to src/assets/wise5/authoringTool/milestones/milestonesAuthoringComponent.ts index 5b1093ee95..a5bfc626a2 100644 --- a/src/assets/wise5/authoringTool/milestones/milestonesAuthoringController.ts +++ b/src/assets/wise5/authoringTool/milestones/milestonesAuthoringComponent.ts @@ -34,6 +34,21 @@ class MilestonesAuthoringController { private UtilService: UtilService ) { this.$translate = this.$filter('translate'); + } + + $onInit() { + this.project = this.ProjectService.project; + this.idToOrder = this.ProjectService.idToOrder; + this.nodeIds = this.getStepNodeIds(); + if (this.project.achievements == null) { + this.initializeMilestones(); + } + this.milestoneIds = this.getMilestoneIds(); + this.milestoneSatisfyCriteriaIds = this.getMilestoneSatisfyCriteriaIds(); + this.reportIds = this.getReportIds(); + this.templateIds = this.getTemplateIds(); + this.templateSatisfyCriteriaIds = this.getTemplateSatisfyCriteriaIds(); + this.populateIdToExpanded(); this.availableSatisfyCriteriaFunctions = [ { value: 'percentOfScoresLessThan', @@ -58,21 +73,6 @@ class MilestonesAuthoringController { ]; } - $onInit() { - this.project = this.ProjectService.project; - this.idToOrder = this.ProjectService.idToOrder; - this.nodeIds = this.getStepNodeIds(); - if (this.project.achievements == null) { - this.initializeMilestones(); - } - this.milestoneIds = this.getMilestoneIds(); - this.milestoneSatisfyCriteriaIds = this.getMilestoneSatisfyCriteriaIds(); - this.reportIds = this.getReportIds(); - this.templateIds = this.getTemplateIds(); - this.templateSatisfyCriteriaIds = this.getTemplateSatisfyCriteriaIds(); - this.populateIdToExpanded(); - } - initializeMilestones() { this.project.achievements = { isEnabled: false, @@ -464,4 +464,7 @@ class MilestonesAuthoringController { } } -export default MilestonesAuthoringController; +export const MilestonesAuthoringComponent = { + templateUrl: `/wise5/authoringTool/milestones/milestonesAuthoring.html`, + controller: MilestonesAuthoringController +}; diff --git a/src/assets/wise5/authoringTool/notebook/notebookAuthoring.html b/src/assets/wise5/authoringTool/notebook/notebookAuthoring.html index f79877ac3a..faf6073878 100644 --- a/src/assets/wise5/authoringTool/notebook/notebookAuthoring.html +++ b/src/assets/wise5/authoringTool/notebook/notebookAuthoring.html @@ -2,133 +2,117 @@

{{ ::'notebookSettings' | translate }}

-
-
- - visibility - {{ ::'previewProject' | translate }} - - - visibility_off - {{ ::'previewProjectWithoutConstraints' | translate }} - -
- + ng-change="$ctrl.componentChanged()"> Student Notebook -
+
- + - Enable Note -
- + ng-change="$ctrl.componentChanged()"/> - + ng-change="$ctrl.componentChanged()"/> - + ng-change="$ctrl.componentChanged()"/>
- {{ ::'enableAddNoteButton' | translate }}
- {{ ::'requireTextOnEveryNote' | translate }}
- {{ ::'enableClipping' | translate }}
- {{ ::'enableStudentUploads' | translate }}
- Enable Report -
- + ng-change="$ctrl.componentChanged()"/> - + ng-change="$ctrl.componentChanged()"/> - + ng-change="$ctrl.componentChanged()"/> -
+
+ ng-change="$ctrl.componentChanged()"/>
@@ -138,7 +122,7 @@

{{ ::'notebookSettings' | translate }}

+ ng-change="$ctrl.componentChanged()"/>

@@ -147,7 +131,7 @@

{{ ::'notebookSettings' | translate }}

+ ng-change="$ctrl.componentChanged()">

@@ -156,73 +140,73 @@

{{ ::'notebookSettings' | translate }}

+ ng-change="$ctrl.componentChanged()">

+ [(model)]="$ctrl.reportIdToAuthoringNote[reportNote.reportId].html" + (model-change)="$ctrl.reportStarterTextChanged(reportNote.reportId)">
- + ng-change="$ctrl.componentChanged()"> Teacher Notebook -
- + - Enable Report -
- + ng-change="$ctrl.componentChanged()"/> - + ng-change="$ctrl.componentChanged()"/> - + ng-change="$ctrl.componentChanged()"/> -
+
+ ng-change="$ctrl.componentChanged()"/>
@@ -231,7 +215,7 @@

{{ ::'notebookSettings' | translate }}

+ ng-change="$ctrl.componentChanged()">

@@ -240,15 +224,15 @@

{{ ::'notebookSettings' | translate }}

+ ng-change="$ctrl.componentChanged()">

+ [(model)]="$ctrl.reportIdToAuthoringNote[reportNote.reportId].html" + (model-change)="$ctrl.reportStarterTextChanged(reportNote.reportId)">
diff --git a/src/assets/wise5/authoringTool/notebook/authorNotebookController.ts b/src/assets/wise5/authoringTool/notebook/notebookAuthoringComponent.ts similarity index 89% rename from src/assets/wise5/authoringTool/notebook/authorNotebookController.ts rename to src/assets/wise5/authoringTool/notebook/notebookAuthoringComponent.ts index 62d8c5e76f..2cec38ada3 100644 --- a/src/assets/wise5/authoringTool/notebook/authorNotebookController.ts +++ b/src/assets/wise5/authoringTool/notebook/notebookAuthoringComponent.ts @@ -5,7 +5,7 @@ import { SpaceService } from '../../services/spaceService'; import { TeacherProjectService } from '../../services/teacherProjectService'; import { UtilService } from '../../services/utilService'; -class AuthorNotebookController { +class NotebookAuthoringController { $translate: any; isPublicNotebookEnabled: boolean; projectId: number; @@ -22,15 +22,18 @@ class AuthorNotebookController { ]; constructor( - $filter, - $stateParams, + $filter: any, + private $stateParams: any, private ConfigService: ConfigService, private ProjectService: TeacherProjectService, private SpaceService: SpaceService, private UtilService: UtilService ) { this.$translate = $filter('translate'); - this.projectId = $stateParams.projectId; + } + + $onInit() { + this.projectId = this.$stateParams.projectId; this.project = this.ProjectService.project; this.reportIdToAuthoringNote = {}; @@ -47,7 +50,6 @@ class AuthorNotebookController { this.initializeStudentNotesAuthoring(); this.initializeTeacherNotesAuthoring(); - this.isPublicNotebookEnabled = this.ProjectService.isSpaceExists('public'); } @@ -111,10 +113,9 @@ class AuthorNotebookController { reportStarterTextChanged(reportId) { const note = this.getReportNote(reportId); const authoringNote = this.getAuthoringReportNote(reportId); - let html = authoringNote.html; - html = this.ConfigService.removeAbsoluteAssetPaths(html); - html = this.UtilService.insertWISELinks(html); - note.content = html; + note.content = this.UtilService.insertWISELinks( + this.ConfigService.removeAbsoluteAssetPaths(authoringNote.html) + ); this.save(); } @@ -139,4 +140,7 @@ class AuthorNotebookController { } } -export default AuthorNotebookController; +export const NotebookAuthoringComponent = { + templateUrl: `/wise5/authoringTool/notebook/notebookAuthoring.html`, + controller: NotebookAuthoringController +}; diff --git a/src/assets/wise5/authoringTool/wiseLink/wiseLinkAuthoring.html b/src/assets/wise5/authoringTool/wiseLink/wiseLinkAuthoring.html index eed0fb18c9..bb8d129b59 100644 --- a/src/assets/wise5/authoringTool/wiseLink/wiseLinkAuthoring.html +++ b/src/assets/wise5/authoringTool/wiseLink/wiseLinkAuthoring.html @@ -11,18 +11,18 @@
{{ ::'createAWISELink' | translate }}

- + ng-class="{'node-select-option--group': $ctrl.isGroupNode(item.$key), 'node-select-option--node': !$ctrl.isGroupNode(item.$key)}"> - {{ ::wiseLinkAuthoringController.getNodePositionById(item.$key) + ': '}} - {{ ::wiseLinkAuthoringController.getNodeTitleByNodeId(item.$key) }} + {{ ::$ctrl.getNodePositionById(item.$key) + ': '}} + {{ ::$ctrl.getNodeTitleByNodeId(item.$key) }} ({{item.$key}}) @@ -30,11 +30,11 @@
{{ ::'createAWISELink' | translate }}
{{componentIndex + 1}}. {{component.type}} @@ -43,24 +43,20 @@
{{ ::'createAWISELink' | translate }}

- + {{ ::'link' | translate }} {{ ::'button' | translate }} - +
- + {{ ::'create' | translate }} - + {{ ::'CANCEL' | translate }}
diff --git a/src/assets/wise5/services/teacherProjectService.ts b/src/assets/wise5/services/teacherProjectService.ts index 2d17e00807..ea83ff1172 100644 --- a/src/assets/wise5/services/teacherProjectService.ts +++ b/src/assets/wise5/services/teacherProjectService.ts @@ -1337,7 +1337,7 @@ export class TeacherProjectService extends ProjectService { return this.upgrade.$injector.get('$mdDialog').show({ templateUrl: 'assets/wise5/authoringTool/wiseLink/wiseLinkAuthoring.html', controller: 'WISELinkAuthoringController', - controllerAs: 'wiseLinkAuthoringController', + controllerAs: '$ctrl', $stateParams: stateParams, clickOutsideToClose: true, escapeToClose: true diff --git a/src/assets/wise5/teacher/teacher-angular-js-module.ts b/src/assets/wise5/teacher/teacher-angular-js-module.ts index 3bc7be9a49..c07af53030 100644 --- a/src/assets/wise5/teacher/teacher-angular-js-module.ts +++ b/src/assets/wise5/teacher/teacher-angular-js-module.ts @@ -10,14 +10,14 @@ import { StudentStatusService } from '../services/studentStatusService'; import { TeacherDataService } from '../services/teacherDataService'; import { TeacherWebSocketService } from '../services/teacherWebSocketService'; import { AdvancedProjectAuthoringComponent } from '../authoringTool/advanced/advanced-project-authoring.component'; -import AuthoringToolController from '../authoringTool/authoringToolController'; +import { AuthoringToolComponent } from '../authoringTool/authoringToolComponent'; import { MainAuthoringComponent } from '../authoringTool/main/mainAuthoringComponent'; -import AuthorNotebookController from '../authoringTool/notebook/authorNotebookController'; +import { NotebookAuthoringComponent } from '../authoringTool/notebook/notebookAuthoringComponent'; import ClassroomMonitorController from '../classroomMonitor/classroomMonitorController'; import DataExportController from '../classroomMonitor/dataExport/dataExportController'; import ExportController from '../classroomMonitor/dataExport/exportController'; import ExportVisitsController from '../classroomMonitor/dataExport/exportVisitsController'; -import MilestonesAuthoringController from '../authoringTool/milestones/milestonesAuthoringController'; +import { MilestonesAuthoringComponent } from '../authoringTool/milestones/milestonesAuthoringComponent'; import { MilestonesComponent } from '../../../app/classroom-monitor/milestones/milestones.component'; import { NodeAdvancedAuthoringComponent } from '../authoringTool/node/advanced/node-advanced-authoring.component'; import { NodeAdvancedBranchAuthoringComponent } from '../authoringTool/node/advanced/branch/node-advanced-branch-authoring.component'; @@ -27,9 +27,12 @@ import { NodeAdvancedJsonAuthoringComponent } from '../authoringTool/node/advanc import { NodeAdvancedPathAuthoringComponent } from '../authoringTool/node/advanced/path/node-advanced-path-authoring.component'; import { NodeAuthoringComponent } from '../authoringTool/node/nodeAuthoringComponent'; import NotebookGradingController from '../classroomMonitor/notebook/notebookGradingController'; -import ProjectAssetController from '../authoringTool/asset/projectAssetController'; +import { + ProjectAssetAuthoringController, + ProjectAssetAuthoringComponent +} from '../authoringTool/asset/projectAssetAuthoringComponent'; import { ProjectAuthoringComponent } from '../authoringTool/project/projectAuthoringComponent'; -import ProjectInfoController from '../authoringTool/info/projectInfoController'; +import { ProjectInfoAuthoringComponent } from '../authoringTool/info/projectInfoAuthoringComponent'; import { RubricAuthoringComponent } from '../authoringTool/rubric/rubric-authoring.component'; import StudentGradingController from '../classroomMonitor/studentGrading/studentGradingController'; import StudentProgressController from '../classroomMonitor/studentProgress/studentProgressController'; @@ -172,23 +175,24 @@ angular component: WiseAuthoringTinymceEditorComponent }) as angular.IDirectiveFactory ) - .controller('AuthoringToolController', AuthoringToolController) + .component('authoringToolComponent', AuthoringToolComponent) .component('mainAuthoringComponent', MainAuthoringComponent) - .controller('AuthorNotebookController', AuthorNotebookController) + .component('notebookAuthoringComponent', NotebookAuthoringComponent) .controller('ClassroomMonitorController', ClassroomMonitorController) .controller('DataExportController', DataExportController) .controller('ExportController', ExportController) .controller('ExportVisitsController', ExportVisitsController) - .controller('MilestonesAuthoringController', MilestonesAuthoringController) + .component('milestonesAuthoringComponent', MilestonesAuthoringComponent) .directive( 'milestones', downgradeComponent({ component: MilestonesComponent }) as angular.IDirectiveFactory ) .component('nodeAuthoringComponent', NodeAuthoringComponent) .controller('NotebookGradingController', NotebookGradingController) - .controller('ProjectAssetController', ProjectAssetController) + .component('projectAssetAuthoringComponent', ProjectAssetAuthoringComponent) + .controller('ProjectAssetAuthoringController', ProjectAssetAuthoringController) .component('projectAuthoringComponent', ProjectAuthoringComponent) - .controller('ProjectInfoController', ProjectInfoController) + .component('projectInfoAuthoringComponent', ProjectInfoAuthoringComponent) .directive( 'rubricAuthoringComponent', downgradeComponent({ component: RubricAuthoringComponent }) as angular.IDirectiveFactory @@ -209,10 +213,7 @@ angular .state('root.at', { url: '/edit', abstract: true, - templateUrl: '/assets/wise5/authoringTool/authoringTool.html', - controller: 'AuthoringToolController', - controllerAs: 'authoringToolController', - resolve: {} + component: 'authoringToolComponent' }) .state('root.at.main', { url: '/home', @@ -309,17 +310,11 @@ angular }) .state('root.at.project.asset', { url: '/asset', - templateUrl: '/assets/wise5/authoringTool/asset/asset.html', - controller: 'ProjectAssetController', - controllerAs: 'projectAssetController', - resolve: {} + component: 'projectAssetAuthoringComponent' }) .state('root.at.project.info', { url: '/info', - templateUrl: '/assets/wise5/authoringTool/info/info.html', - controller: 'ProjectInfoController', - controllerAs: 'projectInfoController', - resolve: {} + component: 'projectInfoAuthoringComponent' }) .state('root.at.project.advanced', { url: '/advanced', @@ -331,17 +326,11 @@ angular }) .state('root.at.project.notebook', { url: '/notebook', - templateUrl: '/assets/wise5/authoringTool/notebook/notebookAuthoring.html', - controller: 'AuthorNotebookController', - controllerAs: 'authorNotebookController', - resolve: {} + component: 'notebookAuthoringComponent' }) .state('root.at.project.milestones', { url: '/milestones', - templateUrl: '/assets/wise5/authoringTool/milestones/milestonesAuthoring.html', - controller: 'MilestonesAuthoringController', - controllerAs: 'milestonesAuthoringController', - resolve: {} + component: 'milestonesAuthoringComponent' }) .state('root.cm', { url: '/manage/unit/:runId',