@abi-software/map-utilities 0.0.0-beta.4 → 0.0.0-beta.6

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,345 +1,350 @@
1
- <template>
2
- <div>
3
- <el-row v-if="title">
4
- <el-col :span="12">
5
- <div class="title-text">
6
- {{ title }}
7
- </div>
8
- </el-col>
9
- </el-row>
10
- <div class="tree-container">
11
- <el-tree
12
- ref="regionTree"
13
- v-loading="!isReady"
14
- element-loading-background="rgba(0, 0, 0, 0.3)"
15
- show-checkbox
16
- :node-key="nodeKey"
17
- :data="treeData"
18
- :check-strictly="false"
19
- :expand-on-click-node="false"
20
- :render-after-expand="false"
21
- :default-expanded-keys="expandedKeys"
22
- @check="checkChanged"
23
- >
24
- <template #default="{ node, data }">
25
- <span
26
- v-if="mapType === 'flatmap'"
27
- class="region-tree-node"
28
- :class="{
29
- activeItem: nodeIsActive(data),
30
- hoverItem: nodeIsHover(data),
31
- }"
32
- @click="changeActiveByNode(data)"
33
- @mouseover="changeHoverByNode(data)"
34
- >
35
- <div :style="getBackgroundStyles(data)">
36
- {{ node.label }}
37
- </div>
38
- </span>
39
- <span
40
- v-else-if="mapType === 'scaffold'"
41
- class="region-tree-node"
42
- :class="{
43
- activeItem: active.includes(data.id),
44
- hoverItem: hover.includes(data.id),
45
- }"
46
- @click="changeActiveByNode(data, true)"
47
- @mouseover="changeHoverByNode(data, true)"
48
- >
49
- <el-color-picker
50
- v-if="data.isPrimitives"
51
- :class="{ 'show-picker': showColourPicker }"
52
- v-model="data.activeColour"
53
- size="small"
54
- :popper-class="myPopperClass"
55
- @change="setColour(data, $event)"
56
- />
57
- <span>{{ node.label }}</span>
58
- <span v-if="data.isTextureSlides" class="node-options">
59
- (Texture)
60
- </span>
61
- </span>
62
- </template>
63
- </el-tree>
64
- </div>
65
- </div>
66
- </template>
67
-
68
- <script>
69
- export default {
70
- name: "TreeControls",
71
- props: {
72
- /**
73
- * The type of map that the TreeControls is used. Either "flatmap" or "scaffold".
74
- */
75
- mapType: {
76
- type: String,
77
- required: true,
78
- },
79
- isReady: {
80
- type: Boolean,
81
- default: true,
82
- },
83
- /**
84
- * The title of the TreeControls.
85
- */
86
- title: {
87
- type: String,
88
- },
89
- /**
90
- * The data of the tree.
91
- */
92
- treeData: {
93
- type: Array,
94
- default: function () {
95
- return [];
96
- },
97
- },
98
- showColourPicker: {
99
- type: Boolean,
100
- default: false,
101
- },
102
- /**
103
- * The active node of the tree.
104
- */
105
- active: {
106
- type: [String, Array],
107
- required: true,
108
- },
109
- /**
110
- * The hover node of the tree.
111
- */
112
- hover: {
113
- type: [String, Array],
114
- required: true,
115
- },
116
- },
117
- data: function () {
118
- return {
119
- defaultExpandedKeys: ["All"],
120
- myPopperClass: "hide-scaffold-colour-popup",
121
- };
122
- },
123
- computed: {
124
- isFlatmap: function () {
125
- return this.mapType === "flatmap";
126
- },
127
- isScaffold: function () {
128
- return this.mapType === "scaffold";
129
- },
130
- nodeKey: function () {
131
- if (this.isFlatmap) {
132
- return "key";
133
- } else if (this.isScaffold) {
134
- return "id";
135
- }
136
- },
137
- expandedKeys: function () {
138
- if (this.isFlatmap) {
139
- return this.defaultExpandedKeys;
140
- } else if (this.isScaffold) {
141
- return [];
142
- }
143
- },
144
- },
145
- watch: {
146
- showColourPicker: {
147
- immediate: true,
148
- handler: function () {
149
- if (this.showColourPicker) this.myPopperClass = "showPicker";
150
- else this.myPopperClass = "hide-scaffold-colour-popup";
151
- },
152
- },
153
- },
154
- methods: {
155
- setColour: function (nodeData, value) {
156
- this.$emit("setColour", nodeData, value);
157
- },
158
- getBackgroundStyles: function (node) {
159
- if ("colour" in node) {
160
- return { background: node.colour };
161
- }
162
- return {};
163
- },
164
- nodeIsActive: function (data) {
165
- return this.active === data.models;
166
- },
167
- nodeIsHover: function (data) {
168
- return this.hover === data.models;
169
- },
170
- changeActiveByNode: function (data, propagate = false) {
171
- if (this.isFlatmap) {
172
- if (data.models) {
173
- this.$emit("changeActive", data.models);
174
- }
175
- } else if (this.isScaffold) {
176
- if (data.isPrimitives || data.isRegion) {
177
- this.$emit("changeActive", data, propagate);
178
- }
179
- }
180
- },
181
- changeHoverByNode: function (data, propagate = false) {
182
- if (this.isFlatmap) {
183
- if (data.models) {
184
- this.$emit("changeHover", data.models);
185
- }
186
- } else if (this.isScaffold) {
187
- if (data.isPrimitives) {
188
- this.$emit("changeHover", data, propagate);
189
- }
190
- }
191
- },
192
- checkChanged: function (node, data) {
193
- if (this.isFlatmap) {
194
- const isChecked = data.checkedKeys.includes(node.key);
195
- if (node.key === "All") {
196
- this.$emit("checkAll", isChecked);
197
- } else {
198
- this.$emit("checkChanged", { key: node.key, value: isChecked });
199
- }
200
- } else if (this.isScaffold) {
201
- this.$emit("checkChanged", node, data);
202
- }
203
- },
204
- },
205
- unmounted: function () {
206
- this.sortedPrimitiveGroups = undefined;
207
- },
208
- };
209
- </script>
210
-
211
- <style lang="scss" scoped>
212
- :deep(.el-loading-spinner) {
213
- .path {
214
- stroke: $app-primary-color;
215
- }
216
-
217
- .el-loading-text {
218
- color: $app-primary-color;
219
- }
220
- }
221
-
222
- .title-text {
223
- width: 59px;
224
- height: 20px;
225
- color: rgb(48, 49, 51);
226
- font-size: 14px;
227
- font-weight: normal;
228
- line-height: 20px;
229
- margin-left: 8px;
230
- }
231
-
232
- .tree-container {
233
- width: 260px;
234
- border: 1px solid rgb(144, 147, 153);
235
- border-radius: 4px;
236
- background: #ffffff;
237
- margin-top: 6px;
238
- scrollbar-width: thin;
239
-
240
- :deep(.el-tree) {
241
- max-height: 240px;
242
- min-height: 130px;
243
- overflow: auto;
244
-
245
- &::-webkit-scrollbar {
246
- width: 4px;
247
- }
248
-
249
- &::-webkit-scrollbar-thumb {
250
- border-radius: 10px;
251
- box-shadow: inset 0 0 6px #c0c4cc;
252
- }
253
- }
254
-
255
- :deep(.el-tree-node__content) {
256
- height: 22px;
257
- }
258
- }
259
-
260
- :deep(.el-checkbox__input) {
261
- &.is-indeterminate,
262
- &.is-checked {
263
- .el-checkbox__inner {
264
- background-color: $app-primary-color;
265
- border-color: $app-primary-color;
266
- }
267
- }
268
- }
269
-
270
- :deep(
271
- .el-tree-node__children
272
- .el-tree-node__children
273
- .el-tree-node__content
274
- > label.el-checkbox
275
- ) {
276
- display: none;
277
- }
278
-
279
- :deep(.el-checkbox__label) {
280
- padding-left: 5px;
281
- color: $app-primary-color !important;
282
- font-size: 12px;
283
- font-weight: 500;
284
- letter-spacing: 0px;
285
- line-height: 14px;
286
- }
287
-
288
- .activeItem {
289
- background-color: #bbb !important;
290
- }
291
-
292
- .hoverItem {
293
- background-color: #eee !important;
294
- }
295
-
296
- .region-tree-node {
297
- flex: 1;
298
- color: $app-primary-color !important;
299
- display: flex;
300
- font-size: 12px;
301
- line-height: 14px;
302
- padding-left: 0px;
303
- background-color: #fff;
304
- width: 100%;
305
-
306
- :deep(.el-color-picker) {
307
- height: 14px !important;
308
- }
309
-
310
- :deep(.el-color-picker__trigger) {
311
- margin-left: 8px;
312
- margin-right: 8px;
313
- padding: 0px;
314
- height: 14px;
315
- width: 14px;
316
- border: 0px;
317
- }
318
- }
319
-
320
- :deep(.el-color-picker__color) {
321
- border: 1px solid $app-primary-color;
322
- }
323
-
324
- :deep(.el-color-picker__icon) {
325
- &.el-icon-arrow-down {
326
- display: none;
327
- }
328
- }
329
-
330
- :deep(.show-picker) {
331
- .el-color-picker__icon {
332
- &.el-icon-arrow-down {
333
- display: block;
334
- }
335
- }
336
- }
337
-
338
- .hide-scaffold-colour-popup {
339
- display: none;
340
- }
341
-
342
- .node-options {
343
- text-align: right;
344
- }
345
- </style>
1
+ <template>
2
+ <div class="selections-container">
3
+ <el-row v-if="title">
4
+ <el-col :span="12">
5
+ <div class="title-text">
6
+ {{ title }}
7
+ </div>
8
+ </el-col>
9
+ </el-row>
10
+ <div class="tree-container">
11
+ <el-tree
12
+ ref="regionTree"
13
+ v-loading="!isReady"
14
+ element-loading-background="rgba(0, 0, 0, 0.3)"
15
+ show-checkbox
16
+ :node-key="nodeKey"
17
+ :data="treeData"
18
+ :check-strictly="false"
19
+ :expand-on-click-node="false"
20
+ :render-after-expand="false"
21
+ :default-expanded-keys="expandedKeys"
22
+ @check="checkChanged"
23
+ >
24
+ <template #default="{ node, data }">
25
+ <span
26
+ v-if="mapType === 'flatmap'"
27
+ class="region-tree-node"
28
+ :class="{
29
+ activeItem: nodeIsActive(data),
30
+ hoverItem: nodeIsHover(data),
31
+ }"
32
+ @click="changeActiveByNode(data)"
33
+ @mouseover="changeHoverByNode(data)"
34
+ >
35
+ <div :style="getBackgroundStyles(data)">
36
+ {{ node.label }}
37
+ </div>
38
+ </span>
39
+ <span
40
+ v-else-if="mapType === 'scaffold'"
41
+ class="region-tree-node"
42
+ :class="{
43
+ activeItem: active.includes(data.id),
44
+ hoverItem: hover.includes(data.id),
45
+ }"
46
+ @click="changeActiveByNode(data, true)"
47
+ @mouseover="changeHoverByNode(data, true)"
48
+ >
49
+ <el-color-picker
50
+ v-if="data.isPrimitives"
51
+ :class="{ 'show-picker': showColourPicker }"
52
+ v-model="data.activeColour"
53
+ size="small"
54
+ :popper-class="myPopperClass"
55
+ @change="setColour(data, $event)"
56
+ />
57
+ <span>{{ node.label }}</span>
58
+ <span v-if="data.isTextureSlides" class="node-options">
59
+ (Texture)
60
+ </span>
61
+ </span>
62
+ </template>
63
+ </el-tree>
64
+ </div>
65
+ </div>
66
+ </template>
67
+
68
+ <script>
69
+ export default {
70
+ name: "TreeControls",
71
+ props: {
72
+ /**
73
+ * The type of map that the TreeControls is used. Either "flatmap" or "scaffold".
74
+ */
75
+ mapType: {
76
+ type: String,
77
+ required: true,
78
+ },
79
+ isReady: {
80
+ type: Boolean,
81
+ default: true,
82
+ },
83
+ /**
84
+ * The title of the TreeControls.
85
+ */
86
+ title: {
87
+ type: String,
88
+ },
89
+ /**
90
+ * The data of the tree.
91
+ */
92
+ treeData: {
93
+ type: Array,
94
+ default: function () {
95
+ return [];
96
+ },
97
+ },
98
+ showColourPicker: {
99
+ type: Boolean,
100
+ default: false,
101
+ },
102
+ /**
103
+ * The active node of the tree.
104
+ */
105
+ active: {
106
+ type: [String, Array],
107
+ required: true,
108
+ },
109
+ /**
110
+ * The hover node of the tree.
111
+ */
112
+ hover: {
113
+ type: [String, Array],
114
+ required: true,
115
+ },
116
+ },
117
+ data: function () {
118
+ return {
119
+ defaultExpandedKeys: ["All"],
120
+ myPopperClass: "hide-scaffold-colour-popup",
121
+ };
122
+ },
123
+ computed: {
124
+ isFlatmap: function () {
125
+ return this.mapType === "flatmap";
126
+ },
127
+ isScaffold: function () {
128
+ return this.mapType === "scaffold";
129
+ },
130
+ nodeKey: function () {
131
+ if (this.isFlatmap) {
132
+ return "key";
133
+ } else if (this.isScaffold) {
134
+ return "id";
135
+ }
136
+ },
137
+ expandedKeys: function () {
138
+ if (this.isFlatmap) {
139
+ return this.defaultExpandedKeys;
140
+ } else if (this.isScaffold) {
141
+ return [];
142
+ }
143
+ },
144
+ },
145
+ watch: {
146
+ showColourPicker: {
147
+ immediate: true,
148
+ handler: function () {
149
+ if (this.showColourPicker) this.myPopperClass = "showPicker";
150
+ else this.myPopperClass = "hide-scaffold-colour-popup";
151
+ },
152
+ },
153
+ },
154
+ methods: {
155
+ setColour: function (nodeData, value) {
156
+ this.$emit("setColour", nodeData, value);
157
+ },
158
+ getBackgroundStyles: function (node) {
159
+ if ("colour" in node) {
160
+ return { background: node.colour };
161
+ }
162
+ return {};
163
+ },
164
+ nodeIsActive: function (data) {
165
+ return this.active === data.models;
166
+ },
167
+ nodeIsHover: function (data) {
168
+ return this.hover === data.models;
169
+ },
170
+ changeActiveByNode: function (data, propagate = false) {
171
+ if (this.isFlatmap) {
172
+ if (data.models) {
173
+ this.$emit("changeActive", data.models);
174
+ }
175
+ } else if (this.isScaffold) {
176
+ if (data.isPrimitives || data.isRegion) {
177
+ this.$emit("changeActive", data, propagate);
178
+ }
179
+ }
180
+ },
181
+ changeHoverByNode: function (data, propagate = false) {
182
+ if (this.isFlatmap) {
183
+ if (data.models) {
184
+ this.$emit("changeHover", data.models);
185
+ }
186
+ } else if (this.isScaffold) {
187
+ if (data.isPrimitives) {
188
+ this.$emit("changeHover", data, propagate);
189
+ }
190
+ }
191
+ },
192
+ checkChanged: function (node, data) {
193
+ if (this.isFlatmap) {
194
+ const isChecked = data.checkedKeys.includes(node.key);
195
+ if (node.key === "All") {
196
+ this.$emit("checkAll", isChecked);
197
+ } else {
198
+ this.$emit("checkChanged", { key: node.key, value: isChecked });
199
+ }
200
+ } else if (this.isScaffold) {
201
+ this.$emit("checkChanged", node, data);
202
+ }
203
+ },
204
+ },
205
+ unmounted: function () {
206
+ this.sortedPrimitiveGroups = undefined;
207
+ },
208
+ };
209
+ </script>
210
+
211
+ <style lang="scss" scoped>
212
+ :deep(.el-loading-spinner) {
213
+ .path {
214
+ stroke: $app-primary-color;
215
+ }
216
+
217
+ .el-loading-text {
218
+ color: $app-primary-color;
219
+ }
220
+ }
221
+
222
+ .selections-container {
223
+ padding-top: 5px;
224
+ }
225
+
226
+ .title-text {
227
+ width: 59px;
228
+ height: 20px;
229
+ color: rgb(48, 49, 51);
230
+ font-size: 14px;
231
+ font-weight: normal;
232
+ line-height: 20px;
233
+ margin-left: 8px;
234
+ }
235
+
236
+ .tree-container {
237
+ width: 260px;
238
+ border: 1px solid rgb(144, 147, 153);
239
+ border-radius: 4px;
240
+ background: #ffffff;
241
+ margin-top: 6px;
242
+ scrollbar-width: thin;
243
+ overflow: hidden;
244
+
245
+ :deep(.el-tree) {
246
+ max-height: 240px;
247
+ min-height: 130px;
248
+ overflow: auto;
249
+
250
+ &::-webkit-scrollbar {
251
+ width: 4px;
252
+ }
253
+
254
+ &::-webkit-scrollbar-thumb {
255
+ border-radius: 10px;
256
+ box-shadow: inset 0 0 6px #c0c4cc;
257
+ }
258
+ }
259
+
260
+ :deep(.el-tree-node__content) {
261
+ height: 22px;
262
+ }
263
+ }
264
+
265
+ :deep(.el-checkbox__input) {
266
+ &.is-indeterminate,
267
+ &.is-checked {
268
+ .el-checkbox__inner {
269
+ background-color: $app-primary-color;
270
+ border-color: $app-primary-color;
271
+ }
272
+ }
273
+ }
274
+
275
+ :deep(
276
+ .el-tree-node__children
277
+ .el-tree-node__children
278
+ .el-tree-node__content
279
+ > label.el-checkbox
280
+ ) {
281
+ display: none;
282
+ }
283
+
284
+ :deep(.el-checkbox__label) {
285
+ padding-left: 5px;
286
+ color: $app-primary-color !important;
287
+ font-size: 12px;
288
+ font-weight: 500;
289
+ letter-spacing: 0px;
290
+ line-height: 14px;
291
+ }
292
+
293
+ .activeItem {
294
+ background-color: #bbb !important;
295
+ }
296
+
297
+ .hoverItem {
298
+ background-color: #eee !important;
299
+ }
300
+
301
+ .region-tree-node {
302
+ flex: 1;
303
+ color: $app-primary-color !important;
304
+ display: flex;
305
+ font-size: 12px;
306
+ line-height: 14px;
307
+ padding-left: 0px;
308
+ background-color: #fff;
309
+ width: 100%;
310
+
311
+ :deep(.el-color-picker) {
312
+ height: 14px !important;
313
+ }
314
+
315
+ :deep(.el-color-picker__trigger) {
316
+ margin-left: 8px;
317
+ margin-right: 8px;
318
+ padding: 0px;
319
+ height: 14px;
320
+ width: 14px;
321
+ border: 0px;
322
+ }
323
+ }
324
+
325
+ :deep(.el-color-picker__color) {
326
+ border: 1px solid $app-primary-color;
327
+ }
328
+
329
+ :deep(.el-color-picker__icon) {
330
+ &.el-icon-arrow-down {
331
+ display: none;
332
+ }
333
+ }
334
+
335
+ :deep(.show-picker) {
336
+ .el-color-picker__icon {
337
+ &.el-icon-arrow-down {
338
+ display: block;
339
+ }
340
+ }
341
+ }
342
+
343
+ .hide-scaffold-colour-popup {
344
+ display: none;
345
+ }
346
+
347
+ .node-options {
348
+ text-align: right;
349
+ }
350
+ </style>