@abi-software/scaffoldvuer 0.1.3 → 0.1.5-1.beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,546 @@
1
+ <template>
2
+ <div
3
+ class="traditional-location"
4
+ :class="{ open: drawerOpen, close: !drawerOpen }"
5
+ >
6
+ <div class="traditional-container">
7
+ <el-row>
8
+ <el-col :span="12">
9
+ <div class="regions-display-text">
10
+ Regions
11
+ </div>
12
+ </el-col>
13
+ <el-col :span="12">
14
+ <el-checkbox
15
+ v-model="checkAll"
16
+ class="all-checkbox"
17
+ :indeterminate="isIndeterminate"
18
+ @change="handleCheckAllChange"
19
+ >
20
+ Display all
21
+ </el-checkbox>
22
+ </el-col>
23
+ </el-row>
24
+ <el-checkbox-group
25
+ v-model="checkedItems"
26
+ size="small"
27
+ class="checkbox-group"
28
+ @change="handleCheckedItemsChange"
29
+ >
30
+ <div class="checkbox-group-inner">
31
+ <el-row
32
+ v-for="item in sortedPrimitiveGroups"
33
+ :key="item"
34
+ :label="item"
35
+ >
36
+ <div class="checkbox-container">
37
+ <el-checkbox
38
+ class="my-checkbox"
39
+ :label="item"
40
+ :checked="true"
41
+ :class="{ activeItem: activeRegion === item,
42
+ hoverItem: hoverRegion === item }"
43
+ @click.native="itemClicked(item, $event)"
44
+ @change="visibilityToggle(item, $event)"
45
+ @mouseover.native="checkboxHover(item)"
46
+ >
47
+ <el-color-picker
48
+ :class="{ 'show-picker' : showColourPicker }"
49
+ :value="getColour(item)"
50
+ size="small"
51
+ :popper-class="myPopperClass"
52
+ @change="setColour(item, $event)"
53
+ />
54
+ {{ item }}
55
+ </el-checkbox>
56
+ </div>
57
+ </el-row>
58
+ </div>
59
+ </el-checkbox-group>
60
+ </div>
61
+ <div
62
+ class="drawer-button"
63
+ :class="{ open: drawerOpen, close: !drawerOpen }"
64
+ @click="toggleDrawer"
65
+ >
66
+ <i class="el-icon-arrow-left" />
67
+ </div>
68
+ </div>
69
+ </template>
70
+
71
+ <script>
72
+ /* eslint-disable no-alert, no-console */
73
+ import Vue from "vue";
74
+ import { Checkbox, CheckboxGroup, ColorPicker, Row } from "element-ui";
75
+ import lang from "element-ui/lib/locale/lang/en";
76
+ import locale from "element-ui/lib/locale";
77
+
78
+ const orderBy = require("lodash/orderBy");
79
+ const uniq = require("lodash/uniq");
80
+ locale.use(lang);
81
+ Vue.use(Checkbox);
82
+ Vue.use(CheckboxGroup);
83
+ Vue.use(ColorPicker);
84
+ Vue.use(Row);
85
+
86
+ /**
87
+ * A vue component for toggling visibility of various regions.
88
+ */
89
+ export default {
90
+ name: "TraditionalControls",
91
+ props: {
92
+ /**
93
+ * @ignore
94
+ */
95
+ module: {
96
+ type: Object,
97
+ default: undefined
98
+ },
99
+ /**
100
+ * Enable/disable colour picker
101
+ */
102
+ showColourPicker: Boolean
103
+ },
104
+ data: function() {
105
+ return {
106
+ checkAll: true,
107
+ isIndeterminate: false,
108
+ checkedItems: [],
109
+ sortedPrimitiveGroups: [],
110
+ activeRegion: "",
111
+ hoverRegion: "",
112
+ myPopperClass: "hide-scaffold-colour-popup",
113
+ drawerOpen: true
114
+ };
115
+ },
116
+ watch: {
117
+ showColourPicker: {
118
+ immediate: true,
119
+ handler: function() {
120
+ if (this.showColourPicker) this.myPopperClass = "showPicker";
121
+ else this.myPopperClass = "hide-scaffold-colour-popup";
122
+ }
123
+ }
124
+ },
125
+ created: function() {
126
+ let tmpArray = this.module.sceneData.geometries.concat(
127
+ this.module.sceneData.lines
128
+ );
129
+ tmpArray = tmpArray.concat(this.module.sceneData.glyphsets);
130
+ tmpArray = uniq(tmpArray.concat(this.module.sceneData.pointset));
131
+ this.sortedPrimitiveGroups = orderBy(tmpArray);
132
+ this.module.addOrganPartAddedCallback(this.organsAdded);
133
+ this.module.graphicsHighlight.selectColour = 0x444444;
134
+ },
135
+ destroyed: function() {
136
+ this.sortedPrimitiveGroups = undefined;
137
+ },
138
+ methods: {
139
+ /**
140
+ * This is called when a new organ is read into the scene.
141
+ */
142
+ organsAdded: function(name) {
143
+ if (name && name != "") {
144
+ let tmpArray = uniq(this.sortedPrimitiveGroups.concat([name]));
145
+ tmpArray = orderBy(tmpArray);
146
+ const index = tmpArray.indexOf(undefined);
147
+ if (index > -1) {
148
+ tmpArray.splice(index, 1);
149
+ }
150
+ this.sortedPrimitiveGroups = tmpArray;
151
+ }
152
+ },
153
+ /**
154
+ * Select a region by its name.
155
+ */
156
+ changeActiveByName: function(name, propagate) {
157
+ let targetObject = this.getFirstZincObjectWithGroupName(name);
158
+ if (targetObject && targetObject.getVisibility()) {
159
+ this.activeRegion = name;
160
+ this.$emit("object-selected", targetObject, propagate);
161
+ } else {
162
+ this.removeActive(propagate);
163
+ }
164
+ this.removeHover(propagate);
165
+ },
166
+ /**
167
+ * Hover a region by its name.
168
+ */
169
+ changeHoverByName: function(name, propagate) {
170
+ let targetObject = this.getFirstZincObjectWithGroupName(name);
171
+ if (targetObject) {
172
+ this.hoverRegion = name;
173
+ this.$emit("object-hovered", targetObject, propagate);
174
+ } else {
175
+ this.removeHover(propagate);
176
+ }
177
+ },
178
+ /**
179
+ * Unselect the current selected region.
180
+ */
181
+ removeActive: function(propagate) {
182
+ this.activeRegion = "";
183
+ this.$emit("object-selected", undefined, propagate);
184
+ },
185
+ /**
186
+ * Unselect the current hover region.
187
+ */
188
+ removeHover: function(propagate) {
189
+ this.hoverRegion = "";
190
+ this.$emit("object-hovered", undefined, propagate);
191
+ },
192
+ /**
193
+ * Reset the controls.
194
+ */
195
+ clear: function() {
196
+ this.sortedPrimitiveGroups = [];
197
+ this.checkedItems = [];
198
+ this.checkAll = true;
199
+ this.isIndeterminate = false;
200
+ this.activeRegion = "";
201
+ this.hoverRegion = "";
202
+ this.$emit("object-selected", undefined);
203
+ },
204
+ getFirstZincObjectWithGroupName: function(name) {
205
+ if (this.module && this.module.scene) {
206
+ let array = this.module.scene.findGeometriesWithGroupName(name);
207
+ if (array.length > 0) return array[0];
208
+ array = this.module.scene.findGlyphsetsWithGroupName(name);
209
+ if (array.length > 0) return array[0];
210
+ array = this.module.scene.findLinesWithGroupName(name);
211
+ if (array.length > 0) return array[0];
212
+ array = this.module.scene.findPointsetsWithGroupName(name);
213
+ if (array.length > 0) return array[0];
214
+ }
215
+ return undefined;
216
+ },
217
+ getColour: function(name) {
218
+ let graphic = this.getFirstZincObjectWithGroupName(name);
219
+ if (graphic) {
220
+ let hex = graphic.getColourHex();
221
+ if (hex) return "#" + hex;
222
+ }
223
+ return "#FFFFFF";
224
+ },
225
+ setColour: function(name, value) {
226
+ let graphic = this.getFirstZincObjectWithGroupName(name);
227
+ if (graphic) {
228
+ let hexString = value.replace("#", "0x");
229
+ graphic.setColourHex(hexString);
230
+ }
231
+ },
232
+ checkboxHover: function(name) {
233
+ this.changeHoverByName(name, true);
234
+ },
235
+ itemClicked: function(name, event) {
236
+ if (
237
+ !(
238
+ event.target.classList.contains("el-checkbox__inner") ||
239
+ event.target.classList.contains("el-checkbox__original")
240
+ )
241
+ ) {
242
+ this.changeActiveByName(name, true);
243
+ event.preventDefault();
244
+ }
245
+ },
246
+ handleCheckedItemsChange: function() {
247
+ let unnamed = this.checkedItems.includes(undefined) ? true: false;
248
+ let checkedCount = this.checkedItems.length;
249
+ if (unnamed)
250
+ checkedCount--;
251
+ this.checkAll = checkedCount === this.sortedPrimitiveGroups.length;
252
+ this.isIndeterminate =
253
+ checkedCount > 0 && checkedCount < this.sortedPrimitiveGroups.length;
254
+ },
255
+ handleCheckAllChange(val) {
256
+ this.checkedItems = val ? [...this.sortedPrimitiveGroups] : [];
257
+ this.isIndeterminate = false;
258
+ for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
259
+ this.visibilityToggle(this.sortedPrimitiveGroups[i], this.checkAll);
260
+ }
261
+ },
262
+ viewAll: function() {
263
+ this.module.viewAll();
264
+ },
265
+ visibilityToggle: function(item, event) {
266
+ this.module.changeOrganPartsVisibility(item, event);
267
+ if (event == false) {
268
+ if (this.activeRegion === item) {
269
+ this.removeActive(true);
270
+ }
271
+ if (this.hoverRegion === item) {
272
+ this.removeHover(true);
273
+ }
274
+ }
275
+ },
276
+ toggleDrawer: function() {
277
+ this.drawerOpen = !this.drawerOpen;
278
+ this.$emit("drawer-toggled", this.drawerOpen);
279
+ },
280
+ getState: function() {
281
+ if (this.checkAll) {
282
+ return { checkAll: true };
283
+ }
284
+ let checkedItems = [...this.checkedItems];
285
+ const index = checkedItems.indexOf(undefined);
286
+ if (index > -1) {
287
+ checkedItems.splice(index, 1);
288
+ }
289
+ return { checkedItems: checkedItems };
290
+ },
291
+ setState: function(state) {
292
+ if (state) {
293
+ if (state.checkAll) {
294
+ this.checkedItems = [...this.sortedPrimitiveGroups];
295
+ for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
296
+ this.module.changeOrganPartsVisibility(
297
+ this.sortedPrimitiveGroups[i],
298
+ true
299
+ );
300
+ }
301
+ } else if (state.checkedItems) {
302
+ this.checkedItems = [...state.checkedItems];
303
+ for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
304
+
305
+ let visible = this.checkedItems.includes(
306
+ this.sortedPrimitiveGroups[i]);
307
+ this.module.changeOrganPartsVisibility(
308
+ this.sortedPrimitiveGroups[i],
309
+ visible
310
+ );
311
+ }
312
+ }
313
+ }
314
+ this.handleCheckedItemsChange();
315
+ }
316
+ }
317
+ };
318
+ </script>
319
+
320
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
321
+ <style scoped lang="scss">
322
+ @import "~element-ui/packages/theme-chalk/src/checkbox";
323
+ @import "~element-ui/packages/theme-chalk/src/checkbox-group";
324
+ @import "~element-ui/packages/theme-chalk/src/color-picker";
325
+ @import "~element-ui/packages/theme-chalk/src/row";
326
+
327
+ .checkbox-container {
328
+ display: flex;
329
+ cursor: pointer;
330
+ }
331
+
332
+ .traditional-location {
333
+ position: absolute;
334
+ bottom: 0px;
335
+ transition: all 1s ease;
336
+
337
+ &:focus{
338
+ outline: none;
339
+ }
340
+ &.open {
341
+ left: 0px;
342
+ .traditional-container {
343
+ opacity: 1;
344
+ }
345
+ }
346
+ &.close {
347
+ left: -298px;
348
+ .traditional-container {
349
+ pointer-events:none;
350
+ opacity: 0;
351
+ }
352
+ }
353
+ }
354
+
355
+ .traditional-container {
356
+ transition: all 1s ease;
357
+ float: left;
358
+ padding-left: 16px;
359
+ padding-right: 18px;
360
+ max-height: calc(100% - 154px);
361
+ text-align: left;
362
+ overflow: none;
363
+ border: 1px solid rgb(220, 223, 230);
364
+ padding-top: 7px;
365
+ padding-bottom: 16px;
366
+ background: #ffffff;
367
+ }
368
+
369
+ .regions-display-text {
370
+ width: 59px;
371
+ height: 20px;
372
+ color: rgb(48, 49, 51);
373
+ font-size: 14px;
374
+ font-weight: normal;
375
+ line-height: 20px;
376
+ margin-left: 8px;
377
+ }
378
+
379
+ .all-checkbox {
380
+ float: right;
381
+ }
382
+
383
+ .checkbox-group {
384
+ width: 260px;
385
+ border: 1px solid rgb(144, 147, 153);
386
+ border-radius: 4px;
387
+ background: #ffffff;
388
+ margin-top: 6px;
389
+ }
390
+
391
+ .checkbox-group-inner {
392
+ padding: 18px;
393
+ max-height: 240px;
394
+ min-height: 130px;
395
+ overflow: auto;
396
+ scrollbar-color: #c0c4cc rgba(1, 1, 1, 0);
397
+ scrollbar-width: thin;
398
+
399
+ &::-webkit-scrollbar {
400
+ width: 4px;
401
+ }
402
+
403
+ &::-webkit-scrollbar-thumb {
404
+ border-radius: 10px;
405
+ box-shadow: inset 0 0 6px #c0c4cc;
406
+ }
407
+ }
408
+
409
+ ::v-deep .el-checkbox__input {
410
+ &.is-indeterminate, &.is-checked {
411
+ .el-checkbox__inner {
412
+ background-color: $app-primary-color;
413
+ border-color: $app-primary-color;
414
+ }
415
+ }
416
+ }
417
+
418
+ ::v-deep .el-color-picker__color {
419
+ border: 1px solid $app-primary-color;
420
+ }
421
+
422
+ ::v-deep .el-checkbox__label {
423
+ padding-left: 5px;
424
+ color: $app-primary-color !important;
425
+ font-size: 12px;
426
+ font-weight: 500;
427
+ letter-spacing: 0px;
428
+ line-height: 14px;
429
+ }
430
+
431
+ .activeItem {
432
+ background-color: #bbb !important;
433
+ }
434
+
435
+ .my-checkbox {
436
+ background-color: #fff;
437
+ width: 100%;
438
+
439
+ ::v-deep .el-color-picker {
440
+ height: 16px !important;
441
+ top: 3px;
442
+ }
443
+
444
+ ::v-deep .el-color-picker__trigger {
445
+ margin-left: 8px;
446
+ margin-right: 8px;
447
+ padding: 0px;
448
+ height: 16px;
449
+ width: 16px;
450
+ border: 0px;
451
+ }
452
+
453
+ }
454
+
455
+ .hoverItem {
456
+ background-color: #eee !important;
457
+ }
458
+
459
+ ::v-deep .el-color-picker__icon {
460
+ &.el-icon-arrow-down {
461
+ display: none;
462
+ }
463
+ }
464
+
465
+ ::v-deep .show-picker {
466
+ .el-color-picker__icon {
467
+ &.el-icon-arrow-down {
468
+ display: block;
469
+ }
470
+ }
471
+ }
472
+
473
+ ::v-deep .my-drawer {
474
+ background: rgba(0, 0, 0, 0);
475
+ box-shadow: none;
476
+ }
477
+
478
+ .drawer {
479
+ ::v-deep .el-drawer:focus {
480
+ outline: none;
481
+ }
482
+ }
483
+
484
+ .open-drawer {
485
+ width: 20px;
486
+ height: 40px;
487
+ z-index: 8;
488
+ position: absolute;
489
+ left: 0px;
490
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
491
+ border: solid 1px #e4e7ed;
492
+ background-color: #f7faff;
493
+ text-align: center;
494
+ vertical-align: middle;
495
+ cursor: pointer;
496
+ pointer-events: auto;
497
+ }
498
+
499
+ .drawer-button {
500
+ float: left;
501
+ width: 20px;
502
+ height: 40px;
503
+ z-index: 8;
504
+ margin-top: calc(50% - 52px);
505
+ border: solid 1px #e4e7ed;
506
+ border-left: 0;
507
+ background-color: #ffffff;
508
+ text-align: center;
509
+ vertical-align: middle;
510
+ cursor: pointer;
511
+ pointer-events: auto;
512
+ }
513
+
514
+ .drawer-button {
515
+ i {
516
+ margin-top: 12px;
517
+ color: $app-primary-color;
518
+ transition-delay: 0.9s;
519
+ }
520
+ &.open {
521
+ i {
522
+ transform: rotate(0deg) scaleY(2.5);
523
+ }
524
+ }
525
+ &.close {
526
+ i {
527
+ transform: rotate(180deg) scaleY(2.5);
528
+ }
529
+ }
530
+ }
531
+
532
+ .drawer-button.open i {
533
+ transform: rotate(0deg) scaleY(2.5);
534
+ }
535
+
536
+ .drawer-button.close i {
537
+ transform: rotate(180deg) scaleY(2.5);
538
+ }
539
+ </style>
540
+
541
+ <style>
542
+ .hide-scaffold-colour-popup {
543
+ display: none;
544
+ }
545
+ </style>
546
+
@@ -1,15 +1,7 @@
1
1
  // The Vue build version to load with the `import` command
2
2
  // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3
- import Vue from "vue";
4
3
  import ScaffoldVuer from "./ScaffoldVuer.vue";
5
4
 
6
- const Components = {
7
- ScaffoldVuer
8
- };
9
-
10
- Object.keys(Components).forEach(name => {
11
- Vue.component(name, Components[name]);
12
- });
13
-
14
- export default Components;
15
-
5
+ export {
6
+ ScaffoldVuer
7
+ };
@@ -0,0 +1,12 @@
1
+ {
2
+ "type": "service_account",
3
+ "project_id": "scaffold-models-1598402284168",
4
+ "private_key_id": "d97f27e0d164aa69fb8995342447407b1a8af037",
5
+ "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCSU0/CnYgiP254\ntvAZzosYTwFZ69KqZYNfWOjWRRB5wKr+itLGpi25WcO2wR4YtXiTXk9htaYd9hSM\n90LEH5+aqhvMovmDltpLRRfL0qg4jf/AlmL11lmbj715Rsko6ADD1fQfnl5leYLb\nikbkCBCdedAOZmC0Px9RuMV+5N440dE7PejBc6UGGCouTHzXeuT/8KigBTKLNk3x\nLu1v0Aw07iJLKAXQKGNKKxRuBVoc/WcVRqTfs7HWQcxFYpIg4MmRoa8MKJujZPwR\nCLRHktCo4Sip32By7LFapjkhjV0ImUq+B/gOctBIt/MC445lxaW8Z6iC0jPOhSRi\nRRjhY2+3AgMBAAECggEAQQxEMtHxCLiGFafNiMtmzkGg6iaJmjJSenp913MQZe+e\nlFWGacTKItGizYWAKZ/SoECWrWshE8SnUhtBVQpx20Gv5gK1RSg0lq16bKOTIMEP\nZr/z8jF92EfIBTfQiRzJ6kUcp0mx0Q55e7s21Hw5VqgmM6CTcM120M+BDG4V08/W\nSqsmtYRcitUeiolQCVPxx0AAeqS8ysZWPBen1tNY9HfZ+2TBkmDf+G7anZO72UTy\n3GRIpCUr4EaopftCwsk6hwbxmsJCFLBMmWobhdeb3k6Srwg5FIQ84xR2cyW0fPHm\nE/kjFKoUomXTiaBhNndLHnG6eh3G2Ml96FIRQlzgAQKBgQDDpJhANedrwzAq/J7r\ngUFrjaEfQn65khCsdgbeBV5AsfNq3BVCDcsaK9ieqX7HgDFwx5bGBQerH8GjQjFD\nHNcz/ZCpsk2CzDjhLLgxzd48NVlq606kMg9/YqaJ96U7H5dUS40f0JbrcWZ+dG4q\n/ZS4jMM61u0zUfmiN5a1r//YAQKBgQC/d71Ig9vHz5a9he3LqMCFR+gZPNy2hYSX\ndcwhosI3IuC4frUoQToZdsPADI7s5hK7Ob+AlWokJ3YeCmqTYMr96ayHA6yfw99r\nIxmeMKP1G94OShO/kX/Y9mw+JiCDUSXJef2n8zrMrDSHdAusa14YYp3vfeI3fPI4\n4opP0pgHtwKBgQCWt95y2RQHeL9K3oKve0wix2Ew69EktNoTgnmX4RrTTEPyNspJ\nsMaeyth+oqUAnEl6UMhelNFri3NpijzZLwa7DsS7dpkwApRvJDxiYe6rA453R/+1\njrtRr3YNI7Mu8Q9r6Sg3MkKR7zK+iIO2qtQ/uHFOivUBbE2cIqcAIS5AAQKBgCPS\nHgqECMlAEB6TAOMaRjJpOoYGOfC32A+SDUe5sIYqM0qxAelvEpSTAJpcfxzZCmYW\nrro6uenbrCCAqGG8OR356rozuMcHGTRtE6zhwrrnpMqdl0Y+zWFk8OlLrseClgQ0\nm30hZz3Fdepljo2KZMdBI/UbYwgoixSTZXb7mk/PAoGASN0HgtU9EhYsfBZYGqL7\nh3rUVOQBOfnhx3+3g03pgnDZtb2YRH1izuTH6Ak0UnMNtZLJqCopHfmZAZmYmVeD\nnpDz9B9nJF0MM0JRYdKEOXzp+HsL8zovt+sKxYeRXq2l4oxJiqIpeLvhvNeHURnB\n10Rl+BuUU2qmilM3kuWIA48=\n-----END PRIVATE KEY-----\n",
6
+ "client_email": "scaffoldvuer@scaffold-models-1598402284168.iam.gserviceaccount.com",
7
+ "client_id": "112229511591019595252",
8
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
+ "token_uri": "https://oauth2.googleapis.com/token",
10
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/scaffoldvuer%40scaffold-models-1598402284168.iam.gserviceaccount.com"
12
+ }
package/src/main.js CHANGED
@@ -1,8 +1,14 @@
1
1
  import Vue from 'vue'
2
+ import VueRouter from 'vue-router'
2
3
  import App from './App.vue'
3
4
 
4
5
  Vue.config.productionTip = false
6
+ Vue.use(VueRouter)
7
+
8
+ const router = new VueRouter({
9
+ })
5
10
 
6
11
  new Vue({
12
+ router,
7
13
  render: h => h(App),
8
14
  }).$mount('#app')
@@ -0,0 +1,80 @@
1
+ const MODULE_CHANGE = { ALL: 0, DESTROYED: 1, NAME_CHANGED: 2, SETTINGS_CHANGED: 3 };
2
+
3
+ const BaseModule = function() {
4
+ this.typeName = "Base Module";
5
+ this.instanceName = "default";
6
+ this.onChangedCallbacks = [];
7
+ /** Notifier handle for informing other modules of any changes **/
8
+ this.eventNotifiers = [];
9
+ }
10
+
11
+ BaseModule.prototype.setName = function(name) {
12
+ if (name && this.instanceName !== name) {
13
+ this.instanceName = name;
14
+ const callbackArray = this.onChangedCallbacks.slice();
15
+ for (let i = 0; i < callbackArray.length; i++) {
16
+ callbackArray[i]( this, MODULE_CHANGE.NAME_CHANGED );
17
+ }
18
+ }
19
+ }
20
+
21
+ BaseModule.prototype.settingsChanged = function() {
22
+ const callbackArray = this.onChangedCallbacks.slice();
23
+ for (let i = 0; i < callbackArray.length; i++) {
24
+ callbackArray[i]( this, MODULE_CHANGE.SETTINGS_CHANGED );
25
+ }
26
+ }
27
+
28
+ BaseModule.prototype.exportSettings = function() {
29
+ const settings = {};
30
+ settings.dialog = this.typeName;
31
+ settings.name = this.instanceName;
32
+ return settings;
33
+ }
34
+
35
+ BaseModule.prototype.importSettings = function(settings) {
36
+ if (settings.dialog == this.typeName) {
37
+ this.setName(settings.name);
38
+ return true;
39
+ }
40
+ return false;
41
+ }
42
+
43
+ BaseModule.prototype.publishChanges = function(annotations, eventType) {
44
+ for (let i = 0; i < this.eventNotifiers.length; i++) {
45
+ this.eventNotifiers[i].publish(this, eventType, annotations);
46
+ }
47
+ }
48
+
49
+ BaseModule.prototype.getName = function() {
50
+ return this.instanceName;
51
+ }
52
+
53
+ BaseModule.prototype.destroy = function() {
54
+ //Make a temorary copy as the array may be altered during the loop
55
+ const callbackArray = this.onChangedCallbacks.slice();
56
+ for (let i = 0; i < callbackArray.length; i++) {
57
+ callbackArray[i]( this, MODULE_CHANGE.DESTROYED );
58
+ }
59
+
60
+ delete this;
61
+ }
62
+
63
+ BaseModule.prototype.addChangedCallback = function(callback) {
64
+ if (this.onChangedCallbacks.includes(callback) == false)
65
+ this.onChangedCallbacks.push(callback);
66
+ }
67
+
68
+ BaseModule.prototype.removeChangedCallback = function(callback) {
69
+ const index = this.onChangedCallbacks.indexOf(callback);
70
+ if (index > -1) {
71
+ this.onChangedCallbacks.splice(index, 1);
72
+ }
73
+ }
74
+
75
+ BaseModule.prototype.addNotifier = function(eventNotifier) {
76
+ this.eventNotifiers.push(eventNotifier);
77
+ }
78
+
79
+ exports.BaseModule = BaseModule;
80
+ exports.MODULE_CHANGE = MODULE_CHANGE;