@kris701/ez-ui 1.4.12 → 1.4.13
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.
|
@@ -3295,15 +3295,29 @@ class EzUITreeMultiSelect {
|
|
|
3295
3295
|
map = new Map();
|
|
3296
3296
|
visMap = new Map();
|
|
3297
3297
|
ngOnChanges(changes) {
|
|
3298
|
+
if (changes['options'] && changes['options'].currentValue != changes['options'].previousValue) {
|
|
3299
|
+
let index = 0;
|
|
3300
|
+
for (let option of this.options)
|
|
3301
|
+
this.setIDs(option, "" + index++);
|
|
3302
|
+
}
|
|
3298
3303
|
if (changes['selected'] && changes['selected'].currentValue != changes['selected'].previousValue) {
|
|
3299
3304
|
this.selected = changes['selected'].currentValue;
|
|
3300
3305
|
let newMap = new Map();
|
|
3301
3306
|
if (this.selected)
|
|
3302
3307
|
for (let item of this.selected)
|
|
3303
|
-
newMap.set(item, true);
|
|
3308
|
+
newMap.set(item.id, true);
|
|
3304
3309
|
this.map = newMap;
|
|
3305
3310
|
}
|
|
3306
3311
|
}
|
|
3312
|
+
setIDs(parent, prefix) {
|
|
3313
|
+
if (!parent.id || parent.id == '')
|
|
3314
|
+
parent.id = prefix;
|
|
3315
|
+
if (parent.children) {
|
|
3316
|
+
let subIndex = 0;
|
|
3317
|
+
for (let child of parent.children)
|
|
3318
|
+
this.setIDs(child, prefix + ";" + subIndex++);
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3307
3321
|
stringify = (value) => value.label;
|
|
3308
3322
|
expandAll() {
|
|
3309
3323
|
for (let option of this.options)
|
|
@@ -3349,13 +3363,16 @@ class EzUITreeMultiSelect {
|
|
|
3349
3363
|
}
|
|
3350
3364
|
onChecked(node, value) {
|
|
3351
3365
|
flatten(node).filter(x => x.selectable != false).forEach((item) => {
|
|
3352
|
-
this.map.set(item, value);
|
|
3366
|
+
this.map.set(item.id, value);
|
|
3353
3367
|
});
|
|
3354
3368
|
this.map = new Map(this.map.entries());
|
|
3355
3369
|
let newSelected = [];
|
|
3356
|
-
for (let
|
|
3357
|
-
|
|
3358
|
-
|
|
3370
|
+
for (let node of this.options) {
|
|
3371
|
+
let nodes = flatten(node);
|
|
3372
|
+
for (let sub of nodes)
|
|
3373
|
+
if (this.map.get(sub.id) == true && !newSelected.find(x => x.id == sub.id))
|
|
3374
|
+
newSelected.push(sub);
|
|
3375
|
+
}
|
|
3359
3376
|
this.selected = newSelected;
|
|
3360
3377
|
this.selectedChange.emit(this.selected);
|
|
3361
3378
|
}
|
|
@@ -3364,10 +3381,10 @@ class EzUITreeMultiSelect {
|
|
|
3364
3381
|
const flat = flatten(item);
|
|
3365
3382
|
const key = flat[0];
|
|
3366
3383
|
if (key) {
|
|
3367
|
-
result = !!map.get(key);
|
|
3384
|
+
result = !!map.get(key.id);
|
|
3368
3385
|
}
|
|
3369
3386
|
for (const item of flat) {
|
|
3370
|
-
if (result !== !!map.get(item)) {
|
|
3387
|
+
if (result !== !!map.get(item.id)) {
|
|
3371
3388
|
return null;
|
|
3372
3389
|
}
|
|
3373
3390
|
}
|