Skip to content

Commit 88788d1

Browse files
committed
Saved TeacherProjectService related files again to have prettier format them again. #2676
1 parent 07d7624 commit 88788d1

9 files changed

Lines changed: 62 additions & 67 deletions

File tree

src/main/webapp/site/src/app/authoring-tool/add-component/choose-new-component-location/choose-new-component-location.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ describe('ChooseNewComponentLocation', () => {
6868
});
6969

7070
it('insertComponentAfter() should create a new component and save the project', () => {
71-
spyOn(teacherProjectService, 'createComponent').and.returnValue({ id: 'comp3', type: 'Discussion' });
71+
spyOn(teacherProjectService, 'createComponent').and.returnValue({
72+
id: 'comp3',
73+
type: 'Discussion'
74+
});
7275
spyOn(teacherProjectService, 'saveProject').and.returnValue(new Promise(() => {}));
7376
component.insertComponentAfter('comp2');
7477
expect(teacherProjectService.createComponent).toHaveBeenCalled();

src/main/webapp/site/src/app/services/projectService.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('ProjectService', () => {
108108
});
109109

110110
function createNormalSpy() {
111-
spyOn(configService, 'getConfigParam').and.callFake(param => {
111+
spyOn(configService, 'getConfigParam').and.callFake((param) => {
112112
if (param === 'projectBaseURL') {
113113
return projectBaseURL;
114114
} else if (param === 'projectURL') {
@@ -162,10 +162,8 @@ function shouldNotReplaceAssetPathsInHtmlComponentContent() {
162162

163163
function shouldRetrieveProjectWhenConfigProjectURLIsValid() {
164164
it('should retrieve project when Config.projectURL is valid', () => {
165-
spyOn(configService, 'getConfigParam')
166-
.withArgs('projectURL')
167-
.and.returnValue(projectURL);
168-
service.retrieveProject().then(response => {
165+
spyOn(configService, 'getConfigParam').withArgs('projectURL').and.returnValue(projectURL);
166+
service.retrieveProject().then((response) => {
169167
expect(response).toEqual(scootersProjectJSON);
170168
});
171169
http.expectOne(projectURL);
@@ -353,7 +351,7 @@ function shouldIdentifyBranchStartAndMergePoints() {
353351
}
354352

355353
function expectFunctionCallToReturnValue(func, nodeIdArray, expectedValue) {
356-
nodeIdArray.forEach(nodeId => {
354+
nodeIdArray.forEach((nodeId) => {
357355
expect(service[func](nodeId)).toEqual(expectedValue);
358356
});
359357
}

src/main/webapp/site/src/app/services/teacherProjectService.spec.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('TeacherProjectService', () => {
106106
});
107107

108108
function createNormalSpy() {
109-
spyOn(configService, 'getConfigParam').and.callFake(param => {
109+
spyOn(configService, 'getConfigParam').and.callFake((param) => {
110110
if (param === 'projectBaseURL') {
111111
return projectBaseURL;
112112
} else if (param === 'projectURL') {
@@ -120,7 +120,7 @@ function createNormalSpy() {
120120
}
121121

122122
function createConfigServiceGetConfigParamSpy() {
123-
spyOn(configService, 'getConfigParam').and.callFake(param => {
123+
spyOn(configService, 'getConfigParam').and.callFake((param) => {
124124
if (param === 'projectBaseURL') {
125125
return projectBaseURL;
126126
} else if (param === 'projectURL') {
@@ -147,7 +147,7 @@ function registerNewProject() {
147147
scootersProjectJSONString
148148
);
149149
http.expectOne(registerNewProjectURL).flush(newProjectIdExpected);
150-
newProjectIdActual.then(result => {
150+
newProjectIdActual.then((result) => {
151151
expect(result).toEqual(newProjectIdExpected);
152152
});
153153
});
@@ -249,7 +249,7 @@ function getLibraryProjects() {
249249
createConfigServiceGetConfigParamSpy();
250250
const result = service.getLibraryProjects();
251251
http.expectOne(getLibraryProjectsURL).flush(libraryProjects);
252-
result.then(projects => {
252+
result.then((projects) => {
253253
expect(projects).toEqual(libraryProjects);
254254
});
255255
});
@@ -936,9 +936,7 @@ function shouldHandleSaveProjectResponseHelper(
936936
function shouldNotSaveProjectWhenTheUserDoesNotHavePermissionToEditTheProject() {
937937
it('should not save project when the user does not have permission to edit the project', () => {
938938
service.setProject(scootersProjectJSON);
939-
spyOn(configService, 'getConfigParam')
940-
.withArgs('canEditProject')
941-
.and.returnValue(false);
939+
spyOn(configService, 'getConfigParam').withArgs('canEditProject').and.returnValue(false);
942940
expect(service.saveProject()).toEqual(null);
943941
});
944942
}

src/main/webapp/wise5/components/componentController.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ class ComponentController {
230230
}
231231

232232
initializeScopeGetComponentState(scope, childControllerName) {
233-
scope.getComponentState = isSubmit => {
233+
scope.getComponentState = (isSubmit) => {
234234
const deferred = this.$q.defer();
235235
const childController = scope[childControllerName];
236236
if (this.hasDirtyWorkToSendToParent(childController, isSubmit)) {
237237
const action = this.getDirtyWorkToSendToParentAction(childController, isSubmit);
238-
childController.createComponentState(action).then(componentState => {
238+
childController.createComponentState(action).then((componentState) => {
239239
deferred.resolve(componentState);
240240
});
241241
} else {
@@ -460,7 +460,7 @@ class ComponentController {
460460
* data has changed.
461461
*/
462462
createComponentStateAndBroadcast(action) {
463-
this.createComponentState(action).then(componentState => {
463+
this.createComponentState(action).then((componentState) => {
464464
this.emitComponentStudentDataChanged(componentState);
465465
});
466466
}
@@ -670,7 +670,7 @@ class ComponentController {
670670
}
671671

672672
importWorkByStudentWorkId(studentWorkId) {
673-
this.StudentDataService.getStudentWorkById(studentWorkId).then(componentState => {
673+
this.StudentDataService.getStudentWorkById(studentWorkId).then((componentState) => {
674674
if (componentState != null) {
675675
this.setStudentWork(componentState);
676676
this.setParentStudentWorkIdToCurrentStudentWork(studentWorkId);
@@ -751,7 +751,7 @@ class ComponentController {
751751
}
752752

753753
attachStudentAsset(studentAsset) {
754-
return this.StudentAssetService.copyAssetForReference(studentAsset).then(copiedAsset => {
754+
return this.StudentAssetService.copyAssetForReference(studentAsset).then((copiedAsset) => {
755755
const attachment = {
756756
studentAssetId: copiedAsset.id,
757757
iconURL: copiedAsset.iconURL,
@@ -829,7 +829,7 @@ class ComponentController {
829829
this.audioRecordedSubscription = this.AudioRecorderService.audioRecorded$.subscribe(
830830
({ requester, audioFile }) => {
831831
if (requester === `${this.nodeId}-${this.componentId}`) {
832-
this.StudentAssetService.uploadAsset(audioFile).then(studentAsset => {
832+
this.StudentAssetService.uploadAsset(audioFile).then((studentAsset) => {
833833
this.attachStudentAsset(studentAsset).then(() => {
834834
this.StudentAssetService.deleteAsset(studentAsset);
835835
});
@@ -871,7 +871,7 @@ class ComponentController {
871871
$scope.nodeId = nodeId;
872872
$scope.componentId = componentId;
873873
$scope.componentState = componentState;
874-
$scope.closeDialog = function() {
874+
$scope.closeDialog = function () {
875875
$mdDialog.hide();
876876
};
877877
}
@@ -882,12 +882,14 @@ class ComponentController {
882882
if (componentState.nodeId == nodeId && componentState.componentId == componentId) {
883883
setTimeout(() => {
884884
const componentService = this.$injector.get(componentState.componentType + 'Service');
885-
componentService.generateImageFromRenderedComponentState(componentState).then(image => {
886-
clearTimeout(destroyDoneRenderingComponentListenerTimeout);
887-
doneRenderingComponentSubscription.unsubscribe();
888-
deferred.resolve(image);
889-
this.$mdDialog.hide();
890-
});
885+
componentService
886+
.generateImageFromRenderedComponentState(componentState)
887+
.then((image) => {
888+
clearTimeout(destroyDoneRenderingComponentListenerTimeout);
889+
doneRenderingComponentSubscription.unsubscribe();
890+
deferred.resolve(image);
891+
this.$mdDialog.hide();
892+
});
891893
}, 1000);
892894
}
893895
}

src/main/webapp/wise5/components/conceptMap/conceptMapService.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ export class ConceptMapService extends ComponentService {
776776
let svgString = svgElement.innerHTML;
777777

778778
// find all the images in the svg and replace them with Base64 images
779-
this.getHrefToBase64ImageReplacements(svgString, true).then(images => {
779+
this.getHrefToBase64ImageReplacements(svgString, true).then((images) => {
780780
/*
781781
* Loop through all the image objects. Each object contains
782782
* an image href and a Base64 image.
@@ -826,7 +826,7 @@ export class ConceptMapService extends ComponentService {
826826
const thisUtilService = this.UtilService;
827827

828828
// the function that is called after the image is fully loaded
829-
image.onload = event => {
829+
image.onload = (event) => {
830830
// get the image that was loaded
831831
const image: any = event.target;
832832

@@ -842,13 +842,13 @@ export class ConceptMapService extends ComponentService {
842842
const imageObject = thisUtilService.getImageObjectFromBase64String(base64Image);
843843

844844
// create a student asset image
845-
this.StudentAssetService.uploadAsset(imageObject).then(unreferencedAsset => {
845+
this.StudentAssetService.uploadAsset(imageObject).then((unreferencedAsset) => {
846846
/*
847847
* make a copy of the unreferenced asset so that we
848848
* get a referenced asset
849849
*/
850850
this.StudentAssetService.copyAssetForReference(unreferencedAsset).then(
851-
referencedAsset => {
851+
(referencedAsset) => {
852852
if (referencedAsset != null) {
853853
/*
854854
* get the asset url
@@ -970,7 +970,7 @@ export class ConceptMapService extends ComponentService {
970970
const ctx = myCanvas.getContext('2d');
971971

972972
// the function that is called after the image is fully loaded
973-
image.onload = function(event) {
973+
image.onload = function (event) {
974974
// get the image that was loaded
975975
const image: any = event.target;
976976

@@ -1147,7 +1147,7 @@ export class ConceptMapService extends ComponentService {
11471147
let svgString = serializer.serializeToString(svgElement);
11481148

11491149
// find all the images in the svg and replace them with Base64 images
1150-
this.getHrefToBase64ImageReplacements(svgString).then(images => {
1150+
this.getHrefToBase64ImageReplacements(svgString).then((images) => {
11511151
/*
11521152
* Loop through all the image objects. Each object contains
11531153
* an image href and a Base64 image.
@@ -1183,7 +1183,7 @@ export class ConceptMapService extends ComponentService {
11831183
const image = new Image();
11841184

11851185
// the function that is called after the image is fully loaded
1186-
image.onload = event => {
1186+
image.onload = (event) => {
11871187
// get the image that was loaded
11881188
let image: any = event.target;
11891189

@@ -1199,7 +1199,7 @@ export class ConceptMapService extends ComponentService {
11991199
const imageObject = this.UtilService.getImageObjectFromBase64String(base64Image);
12001200

12011201
// add the image to the student assets
1202-
this.StudentAssetService.uploadAsset(imageObject).then(asset => {
1202+
this.StudentAssetService.uploadAsset(imageObject).then((asset) => {
12031203
resolve(asset);
12041204
});
12051205
};

src/main/webapp/wise5/components/label/labelService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export class LabelService extends ComponentService {
288288
const image = new Image();
289289
const thisUtilService = this.UtilService;
290290
return new Promise((resolve, reject) => {
291-
image.onload = event => {
291+
image.onload = (event) => {
292292
const image: any = event.target;
293293
myCanvas.width = image.width;
294294
myCanvas.height = image.height;
@@ -297,13 +297,13 @@ export class LabelService extends ComponentService {
297297
const imageObject = thisUtilService.getImageObjectFromBase64String(base64Image);
298298

299299
// create a student asset image
300-
this.StudentAssetService.uploadAsset(imageObject).then(unreferencedAsset => {
300+
this.StudentAssetService.uploadAsset(imageObject).then((unreferencedAsset) => {
301301
/*
302302
* make a copy of the unreferenced asset so that we
303303
* get a referenced asset
304304
*/
305305
this.StudentAssetService.copyAssetForReference(unreferencedAsset).then(
306-
referencedAsset => {
306+
(referencedAsset) => {
307307
if (referencedAsset != null) {
308308
/*
309309
* get the asset url

src/main/webapp/wise5/services/notificationService.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ export class NotificationService {
1818
private setIsJSONValidSource: Subject<any> = new Subject<any>();
1919
public setIsJSONValid$: Observable<any> = this.setIsJSONValidSource.asObservable();
2020
private serverConnectionStatusSource: Subject<any> = new Subject<any>();
21-
public serverConnectionStatus$: Observable<any> =
22-
this.serverConnectionStatusSource.asObservable();
21+
public serverConnectionStatus$: Observable<any> = this.serverConnectionStatusSource.asObservable();
2322
private viewCurrentAmbientNotificationSource: Subject<any> = new Subject<any>();
24-
public viewCurrentAmbientNotification$: Observable<any> =
25-
this.viewCurrentAmbientNotificationSource.asObservable();
23+
public viewCurrentAmbientNotification$: Observable<any> = this.viewCurrentAmbientNotificationSource.asObservable();
2624

2725
constructor(
2826
private upgrade: UpgradeModule,
@@ -138,7 +136,7 @@ export class NotificationService {
138136
this.ConfigService.getWorkgroupId(),
139137
notificationData,
140138
notificationGroupId
141-
).then(notification => {
139+
).then((notification) => {
142140
this.addNotification(notification);
143141
});
144142
}
@@ -228,7 +226,7 @@ export class NotificationService {
228226
let notifications = this.notifications;
229227
for (const p in args) {
230228
if (args.hasOwnProperty(p) && args[p] !== null) {
231-
notifications = notifications.filter(notification => {
229+
notifications = notifications.filter((notification) => {
232230
return notification[p] === args[p];
233231
});
234232
}

src/main/webapp/wise5/services/projectService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export class ProjectService {
414414

415415
getGroupNodesIdToOrder() {
416416
const idToOrder = {};
417-
const onlyGroupNodes = Object.entries(this.idToOrder).filter(item => {
417+
const onlyGroupNodes = Object.entries(this.idToOrder).filter((item) => {
418418
return this.isGroupNode(item[0]);
419419
});
420420
for (const [key, value] of onlyGroupNodes) {
@@ -520,7 +520,7 @@ export class ProjectService {
520520
'(\'|"|\\\\\'|\\\\")',
521521
'gi'
522522
),
523-
matchedString => {
523+
(matchedString) => {
524524
/*
525525
* once found, we prepend the contentBaseURL + "assets/" to the string within the quotes
526526
* and keep everything else the same.
@@ -866,7 +866,7 @@ export class ProjectService {
866866
* the target ids show up in the project.
867867
*/
868868
constraintsComparatorGenerator(orderedNodeIds) {
869-
return function(constraintA, constraintB) {
869+
return function (constraintA, constraintB) {
870870
let constraintAIndex = orderedNodeIds.indexOf(constraintA.targetId);
871871
let constraintBIndex = orderedNodeIds.indexOf(constraintB.targetId);
872872
if (constraintAIndex < constraintBIndex) {
@@ -1002,7 +1002,7 @@ export class ProjectService {
10021002
* @returns an array with all the node ids
10031003
*/
10041004
getNodeIds() {
1005-
return this.applicationNodes.map(node => {
1005+
return this.applicationNodes.map((node) => {
10061006
return node.id;
10071007
});
10081008
}
@@ -1102,7 +1102,7 @@ export class ProjectService {
11021102
return this.http
11031103
.get(projectURL, { headers: headers })
11041104
.toPromise()
1105-
.then(projectJSON => {
1105+
.then((projectJSON) => {
11061106
this.setProject(projectJSON);
11071107
return projectJSON;
11081108
});

0 commit comments

Comments
 (0)