Skip to content

Commit 3e49085

Browse files
Refactored enable/disable tools in Draw authoring. #2889
1 parent 9fd00ce commit 3e49085

2 files changed

Lines changed: 25 additions & 44 deletions

File tree

src/main/webapp/wise5/components/draw/draw-authoring/draw-authoring.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<button mat-raised-button
4747
color="primary"
4848
class="enable-all-tools-button"
49-
(click)="enableAllToolsButtonClicked()"
49+
(click)="enableAllTools(true)"
5050
matTooltip="Enable All Tools"
5151
matTooltipPosition="above"
5252
i18n-matTooltip
@@ -57,7 +57,7 @@
5757
<button mat-raised-button
5858
color="primary"
5959
class="disable-all-tools-button"
60-
(click)="disableAllToolsButtonClicked()"
60+
(click)="enableAllTools(false)"
6161
matTooltip="Disable All Tools"
6262
matTooltipPosition="above"
6363
i18n-matTooltip
@@ -289,4 +289,4 @@
289289
i18n-aria-label>
290290
<mat-icon>delete_sweep</mat-icon>
291291
</button>
292-
</div>
292+
</div>

src/main/webapp/wise5/components/draw/draw-authoring/draw-authoring.component.ts

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { ConfigService } from '../../../services/configService';
77
import { NodeService } from '../../../services/nodeService';
88
import { ProjectAssetService } from '../../../../site/src/app/services/projectAssetService';
99
import { TeacherProjectService } from '../../../services/teacherProjectService';
10-
import { UtilService } from '../../../services/utilService';
1110
import { Subject, Subscription } from 'rxjs';
1211
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
1312

@@ -17,6 +16,23 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
1716
styleUrls: ['draw-authoring.component.scss']
1817
})
1918
export class DrawAuthoring extends ComponentAuthoring {
19+
allToolNames: string[] = [
20+
'select',
21+
'line',
22+
'shape',
23+
'freeHand',
24+
'text',
25+
'stamp',
26+
'strokeColor',
27+
'fillColor',
28+
'clone',
29+
'strokeWidth',
30+
'sendBack',
31+
'sendForward',
32+
'undo',
33+
'redo',
34+
'delete'
35+
];
2036
width: number;
2137
height: number;
2238
defaultWidth: number = 800;
@@ -39,8 +55,7 @@ export class DrawAuthoring extends ComponentAuthoring {
3955
protected ConfigService: ConfigService,
4056
protected NodeService: NodeService,
4157
protected ProjectAssetService: ProjectAssetService,
42-
protected ProjectService: TeacherProjectService,
43-
protected UtilService: UtilService
58+
protected ProjectService: TeacherProjectService
4459
) {
4560
super(ConfigService, NodeService, ProjectAssetService, ProjectService);
4661
this.inputChangeSubscription = this.inputChange
@@ -85,47 +100,13 @@ export class DrawAuthoring extends ComponentAuthoring {
85100
this.stampImageChangeSubscription.unsubscribe();
86101
}
87102

88-
enableAllToolsButtonClicked(): void {
103+
enableAllTools(doEnable: boolean) {
89104
if (this.authoringComponentContent.tools == null) {
90105
this.authoringComponentContent.tools = {};
91106
}
92-
this.authoringComponentContent.tools.select = true;
93-
this.authoringComponentContent.tools.line = true;
94-
this.authoringComponentContent.tools.shape = true;
95-
this.authoringComponentContent.tools.freeHand = true;
96-
this.authoringComponentContent.tools.text = true;
97-
this.authoringComponentContent.tools.stamp = true;
98-
this.authoringComponentContent.tools.strokeColor = true;
99-
this.authoringComponentContent.tools.fillColor = true;
100-
this.authoringComponentContent.tools.clone = true;
101-
this.authoringComponentContent.tools.strokeWidth = true;
102-
this.authoringComponentContent.tools.sendBack = true;
103-
this.authoringComponentContent.tools.sendForward = true;
104-
this.authoringComponentContent.tools.undo = true;
105-
this.authoringComponentContent.tools.redo = true;
106-
this.authoringComponentContent.tools.delete = true;
107-
this.componentChanged();
108-
}
109-
110-
disableAllToolsButtonClicked(): void {
111-
if (this.authoringComponentContent.tools == null) {
112-
this.authoringComponentContent.tools = {};
113-
}
114-
this.authoringComponentContent.tools.select = false;
115-
this.authoringComponentContent.tools.line = false;
116-
this.authoringComponentContent.tools.shape = false;
117-
this.authoringComponentContent.tools.freeHand = false;
118-
this.authoringComponentContent.tools.text = false;
119-
this.authoringComponentContent.tools.stamp = false;
120-
this.authoringComponentContent.tools.strokeColor = false;
121-
this.authoringComponentContent.tools.fillColor = false;
122-
this.authoringComponentContent.tools.clone = false;
123-
this.authoringComponentContent.tools.strokeWidth = false;
124-
this.authoringComponentContent.tools.sendBack = false;
125-
this.authoringComponentContent.tools.sendForward = false;
126-
this.authoringComponentContent.tools.undo = false;
127-
this.authoringComponentContent.tools.redo = false;
128-
this.authoringComponentContent.tools.delete = false;
107+
this.allToolNames.map((toolName) => {
108+
this.authoringComponentContent.tools[toolName] = doEnable;
109+
});
129110
this.componentChanged();
130111
}
131112

0 commit comments

Comments
 (0)