@abi-software/scaffoldvuer 0.1.52 → 0.1.53

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.
@@ -1,545 +0,0 @@
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
- },
134
- destroyed: function() {
135
- this.sortedPrimitiveGroups = undefined;
136
- },
137
- methods: {
138
- /**
139
- * This is called when a new organ is read into the scene.
140
- */
141
- organsAdded: function(name) {
142
- if (name && name != "") {
143
- let tmpArray = uniq(this.sortedPrimitiveGroups.concat([name]));
144
- tmpArray = orderBy(tmpArray);
145
- const index = tmpArray.indexOf(undefined);
146
- if (index > -1) {
147
- tmpArray.splice(index, 1);
148
- }
149
- this.sortedPrimitiveGroups = tmpArray;
150
- }
151
- },
152
- /**
153
- * Select a region by its name.
154
- */
155
- changeActiveByName: function(name, propagate) {
156
- let targetObject = this.getFirstZincObjectWithGroupName(name);
157
- if (targetObject && targetObject.getVisibility()) {
158
- this.activeRegion = name;
159
- this.$emit("object-selected", targetObject, propagate);
160
- } else {
161
- this.removeActive(propagate);
162
- }
163
- this.removeHover(propagate);
164
- },
165
- /**
166
- * Hover a region by its name.
167
- */
168
- changeHoverByName: function(name, propagate) {
169
- let targetObject = this.getFirstZincObjectWithGroupName(name);
170
- if (targetObject) {
171
- this.hoverRegion = name;
172
- this.$emit("object-hovered", targetObject, propagate);
173
- } else {
174
- this.removeHover(propagate);
175
- }
176
- },
177
- /**
178
- * Unselect the current selected region.
179
- */
180
- removeActive: function(propagate) {
181
- this.activeRegion = "";
182
- this.$emit("object-selected", undefined, propagate);
183
- },
184
- /**
185
- * Unselect the current hover region.
186
- */
187
- removeHover: function(propagate) {
188
- this.hoverRegion = "";
189
- this.$emit("object-hovered", undefined, propagate);
190
- },
191
- /**
192
- * Reset the controls.
193
- */
194
- clear: function() {
195
- this.sortedPrimitiveGroups = [];
196
- this.checkedItems = [];
197
- this.checkAll = true;
198
- this.isIndeterminate = false;
199
- this.activeRegion = "";
200
- this.hoverRegion = "";
201
- this.$emit("object-selected", undefined);
202
- },
203
- getFirstZincObjectWithGroupName: function(name) {
204
- if (this.module && this.module.scene) {
205
- let array = this.module.scene.findGeometriesWithGroupName(name);
206
- if (array.length > 0) return array[0];
207
- array = this.module.scene.findGlyphsetsWithGroupName(name);
208
- if (array.length > 0) return array[0];
209
- array = this.module.scene.findLinesWithGroupName(name);
210
- if (array.length > 0) return array[0];
211
- array = this.module.scene.findPointsetsWithGroupName(name);
212
- if (array.length > 0) return array[0];
213
- }
214
- return undefined;
215
- },
216
- getColour: function(name) {
217
- let graphic = this.getFirstZincObjectWithGroupName(name);
218
- if (graphic) {
219
- let hex = graphic.getColourHex();
220
- if (hex) return "#" + hex;
221
- }
222
- return "#FFFFFF";
223
- },
224
- setColour: function(name, value) {
225
- let graphic = this.getFirstZincObjectWithGroupName(name);
226
- if (graphic) {
227
- let hexString = value.replace("#", "0x");
228
- graphic.setColourHex(hexString);
229
- }
230
- },
231
- checkboxHover: function(name) {
232
- this.changeHoverByName(name, true);
233
- },
234
- itemClicked: function(name, event) {
235
- if (
236
- !(
237
- event.target.classList.contains("el-checkbox__inner") ||
238
- event.target.classList.contains("el-checkbox__original")
239
- )
240
- ) {
241
- this.changeActiveByName(name, true);
242
- event.preventDefault();
243
- }
244
- },
245
- handleCheckedItemsChange: function() {
246
- let unnamed = this.checkedItems.includes(undefined) ? true: false;
247
- let checkedCount = this.checkedItems.length;
248
- if (unnamed)
249
- checkedCount--;
250
- this.checkAll = checkedCount === this.sortedPrimitiveGroups.length;
251
- this.isIndeterminate =
252
- checkedCount > 0 && checkedCount < this.sortedPrimitiveGroups.length;
253
- },
254
- handleCheckAllChange(val) {
255
- this.checkedItems = val ? [...this.sortedPrimitiveGroups] : [];
256
- this.isIndeterminate = false;
257
- for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
258
- this.visibilityToggle(this.sortedPrimitiveGroups[i], this.checkAll);
259
- }
260
- },
261
- viewAll: function() {
262
- this.module.viewAll();
263
- },
264
- visibilityToggle: function(item, event) {
265
- this.module.changeOrganPartsVisibility(item, event);
266
- if (event == false) {
267
- if (this.activeRegion === item) {
268
- this.removeActive(true);
269
- }
270
- if (this.hoverRegion === item) {
271
- this.removeHover(true);
272
- }
273
- }
274
- },
275
- toggleDrawer: function() {
276
- this.drawerOpen = !this.drawerOpen;
277
- this.$emit("drawer-toggled", this.drawerOpen);
278
- },
279
- getState: function() {
280
- if (this.checkAll) {
281
- return { checkAll: true };
282
- }
283
- let checkedItems = [...this.checkedItems];
284
- const index = checkedItems.indexOf(undefined);
285
- if (index > -1) {
286
- checkedItems.splice(index, 1);
287
- }
288
- return { checkedItems: checkedItems };
289
- },
290
- setState: function(state) {
291
- if (state) {
292
- if (state.checkAll) {
293
- this.checkedItems = [...this.sortedPrimitiveGroups];
294
- for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
295
- this.module.changeOrganPartsVisibility(
296
- this.sortedPrimitiveGroups[i],
297
- true
298
- );
299
- }
300
- } else if (state.checkedItems) {
301
- this.checkedItems = [...state.checkedItems];
302
- for (let i = 0; i < this.sortedPrimitiveGroups.length; i++) {
303
-
304
- let visible = this.checkedItems.includes(
305
- this.sortedPrimitiveGroups[i]);
306
- this.module.changeOrganPartsVisibility(
307
- this.sortedPrimitiveGroups[i],
308
- visible
309
- );
310
- }
311
- }
312
- }
313
- this.handleCheckedItemsChange();
314
- }
315
- }
316
- };
317
- </script>
318
-
319
- <!-- Add "scoped" attribute to limit CSS to this component only -->
320
- <style scoped lang="scss">
321
- @import "~element-ui/packages/theme-chalk/src/checkbox";
322
- @import "~element-ui/packages/theme-chalk/src/checkbox-group";
323
- @import "~element-ui/packages/theme-chalk/src/color-picker";
324
- @import "~element-ui/packages/theme-chalk/src/row";
325
-
326
- .checkbox-container {
327
- display: flex;
328
- cursor: pointer;
329
- }
330
-
331
- .traditional-location {
332
- position: absolute;
333
- bottom: 0px;
334
- transition: all 1s ease;
335
-
336
- &:focus{
337
- outline: none;
338
- }
339
- &.open {
340
- left: 0px;
341
- .traditional-container {
342
- opacity: 1;
343
- }
344
- }
345
- &.close {
346
- left: -298px;
347
- .traditional-container {
348
- pointer-events:none;
349
- opacity: 0;
350
- }
351
- }
352
- }
353
-
354
- .traditional-container {
355
- transition: all 1s ease;
356
- float: left;
357
- padding-left: 16px;
358
- padding-right: 18px;
359
- max-height: calc(100% - 154px);
360
- text-align: left;
361
- overflow: none;
362
- border: 1px solid rgb(220, 223, 230);
363
- padding-top: 7px;
364
- padding-bottom: 16px;
365
- background: #ffffff;
366
- }
367
-
368
- .regions-display-text {
369
- width: 59px;
370
- height: 20px;
371
- color: rgb(48, 49, 51);
372
- font-size: 14px;
373
- font-weight: normal;
374
- line-height: 20px;
375
- margin-left: 8px;
376
- }
377
-
378
- .all-checkbox {
379
- float: right;
380
- }
381
-
382
- .checkbox-group {
383
- width: 260px;
384
- border: 1px solid rgb(144, 147, 153);
385
- border-radius: 4px;
386
- background: #ffffff;
387
- margin-top: 6px;
388
- }
389
-
390
- .checkbox-group-inner {
391
- padding: 18px;
392
- max-height: 240px;
393
- min-height: 130px;
394
- overflow: auto;
395
- scrollbar-color: #c0c4cc rgba(1, 1, 1, 0);
396
- scrollbar-width: thin;
397
-
398
- &::-webkit-scrollbar {
399
- width: 4px;
400
- }
401
-
402
- &::-webkit-scrollbar-thumb {
403
- border-radius: 10px;
404
- box-shadow: inset 0 0 6px #c0c4cc;
405
- }
406
- }
407
-
408
- ::v-deep .el-checkbox__input {
409
- &.is-indeterminate, &.is-checked {
410
- .el-checkbox__inner {
411
- background-color: $app-primary-color;
412
- border-color: $app-primary-color;
413
- }
414
- }
415
- }
416
-
417
- ::v-deep .el-color-picker__color {
418
- border: 1px solid $app-primary-color;
419
- }
420
-
421
- ::v-deep .el-checkbox__label {
422
- padding-left: 5px;
423
- color: $app-primary-color !important;
424
- font-size: 12px;
425
- font-weight: 500;
426
- letter-spacing: 0px;
427
- line-height: 14px;
428
- }
429
-
430
- .activeItem {
431
- background-color: #bbb !important;
432
- }
433
-
434
- .my-checkbox {
435
- background-color: #fff;
436
- width: 100%;
437
-
438
- ::v-deep .el-color-picker {
439
- height: 16px !important;
440
- top: 3px;
441
- }
442
-
443
- ::v-deep .el-color-picker__trigger {
444
- margin-left: 8px;
445
- margin-right: 8px;
446
- padding: 0px;
447
- height: 16px;
448
- width: 16px;
449
- border: 0px;
450
- }
451
-
452
- }
453
-
454
- .hoverItem {
455
- background-color: #eee !important;
456
- }
457
-
458
- ::v-deep .el-color-picker__icon {
459
- &.el-icon-arrow-down {
460
- display: none;
461
- }
462
- }
463
-
464
- ::v-deep .show-picker {
465
- .el-color-picker__icon {
466
- &.el-icon-arrow-down {
467
- display: block;
468
- }
469
- }
470
- }
471
-
472
- ::v-deep .my-drawer {
473
- background: rgba(0, 0, 0, 0);
474
- box-shadow: none;
475
- }
476
-
477
- .drawer {
478
- ::v-deep .el-drawer:focus {
479
- outline: none;
480
- }
481
- }
482
-
483
- .open-drawer {
484
- width: 20px;
485
- height: 40px;
486
- z-index: 8;
487
- position: absolute;
488
- left: 0px;
489
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
490
- border: solid 1px #e4e7ed;
491
- background-color: #f7faff;
492
- text-align: center;
493
- vertical-align: middle;
494
- cursor: pointer;
495
- pointer-events: auto;
496
- }
497
-
498
- .drawer-button {
499
- float: left;
500
- width: 20px;
501
- height: 40px;
502
- z-index: 8;
503
- margin-top: calc(50% - 52px);
504
- border: solid 1px #e4e7ed;
505
- border-left: 0;
506
- background-color: #ffffff;
507
- text-align: center;
508
- vertical-align: middle;
509
- cursor: pointer;
510
- pointer-events: auto;
511
- }
512
-
513
- .drawer-button {
514
- i {
515
- margin-top: 12px;
516
- color: $app-primary-color;
517
- transition-delay: 0.9s;
518
- }
519
- &.open {
520
- i {
521
- transform: rotate(0deg) scaleY(2.5);
522
- }
523
- }
524
- &.close {
525
- i {
526
- transform: rotate(180deg) scaleY(2.5);
527
- }
528
- }
529
- }
530
-
531
- .drawer-button.open i {
532
- transform: rotate(0deg) scaleY(2.5);
533
- }
534
-
535
- .drawer-button.close i {
536
- transform: rotate(180deg) scaleY(2.5);
537
- }
538
- </style>
539
-
540
- <style>
541
- .hide-scaffold-colour-popup {
542
- display: none;
543
- }
544
- </style>
545
-