@zeedhi/common 1.49.0 → 1.50.0
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.
- package/dist/zd-common.esm.js +79 -22
- package/dist/zd-common.umd.js +79 -22
- package/package.json +2 -2
- package/types/components/zd-dashboard/interfaces.d.ts +3 -5
- package/types/components/zd-select-tree/interfaces.d.ts +3 -1
- package/types/components/zd-select-tree/select-tree.d.ts +5 -0
- package/types/components/zd-tree/tree.d.ts +2 -1
- package/types/services/zd-modal/modal-service.d.ts +5 -0
- package/types/utils/tree-data-structure/tree-data-structure.d.ts +1 -1
package/dist/zd-common.esm.js
CHANGED
|
@@ -2813,6 +2813,16 @@ class ModalService {
|
|
|
2813
2813
|
return this.create(modal);
|
|
2814
2814
|
});
|
|
2815
2815
|
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Creates a new modal instance from JSON
|
|
2818
|
+
* @param modal modal structure
|
|
2819
|
+
*/
|
|
2820
|
+
static createFromJsonPost(modalPath, params) {
|
|
2821
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2822
|
+
const modal = yield Metadata.post(modalPath, params);
|
|
2823
|
+
return this.create(modal);
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2816
2826
|
/**
|
|
2817
2827
|
* Deletes modal
|
|
2818
2828
|
* @param modal modal instance
|
|
@@ -3103,7 +3113,7 @@ class Dashboard extends ComponentRender {
|
|
|
3103
3113
|
];
|
|
3104
3114
|
this.editingMode = this.getInitValue('editingMode', props.editingMode, this.editingMode);
|
|
3105
3115
|
this.moveMode = this.getInitValue('moveMode', props.moveMode, this.moveMode);
|
|
3106
|
-
this.cards = props.cards
|
|
3116
|
+
this.cards = this.getInitValue('cards', props.cards, this.cards);
|
|
3107
3117
|
this.overrideNamedProps = props.overrideNamedProps || this.overrideNamedProps;
|
|
3108
3118
|
this.removePadding = this.getInitValue('removePadding', props.removePadding, this.removePadding);
|
|
3109
3119
|
this.height = this.getInitValue('height', props.height, this.height);
|
|
@@ -3131,13 +3141,7 @@ class Dashboard extends ComponentRender {
|
|
|
3131
3141
|
addCard() {
|
|
3132
3142
|
const addCardForm = Metadata.getInstance('addCardForm');
|
|
3133
3143
|
if (addCardForm.validate()) {
|
|
3134
|
-
const newCard = {
|
|
3135
|
-
cardId: this.getCardId(),
|
|
3136
|
-
path: addCardForm.value.inputPath,
|
|
3137
|
-
local: addCardForm.value.inputLocal,
|
|
3138
|
-
height: addCardForm.value.inputHeight,
|
|
3139
|
-
width: addCardForm.value.inputWidth,
|
|
3140
|
-
};
|
|
3144
|
+
const newCard = Object.assign({ cardId: this.getCardId(), path: addCardForm.value.inputPath, local: addCardForm.value.inputLocal, height: addCardForm.value.inputHeight, width: addCardForm.value.inputWidth }, addCardForm.value);
|
|
3141
3145
|
this.cards.push(newCard);
|
|
3142
3146
|
this.modalCancelClick();
|
|
3143
3147
|
}
|
|
@@ -9060,7 +9064,9 @@ class TreeDataStructure {
|
|
|
9060
9064
|
originalData.splice(index + 1, 0, ...data);
|
|
9061
9065
|
this.originalDatasource.data = originalData;
|
|
9062
9066
|
this.originalDatasource.currentRow = this.clearRow(row);
|
|
9067
|
+
return data;
|
|
9063
9068
|
}
|
|
9069
|
+
return undefined;
|
|
9064
9070
|
});
|
|
9065
9071
|
}
|
|
9066
9072
|
/**
|
|
@@ -9248,6 +9254,10 @@ class SelectTree extends TextInput {
|
|
|
9248
9254
|
*/
|
|
9249
9255
|
this.lazyLoad = true;
|
|
9250
9256
|
this.selectValue = null;
|
|
9257
|
+
/**
|
|
9258
|
+
* Uses delayed loading to load tree branches
|
|
9259
|
+
*/
|
|
9260
|
+
this.fetchOnDemand = false;
|
|
9251
9261
|
this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
|
|
9252
9262
|
this.alwaysOpen = this.getInitValue('alwaysOpen', props.alwaysOpen, this.alwaysOpen);
|
|
9253
9263
|
this.flattenSearchResults = this.getInitValue('flattenSearchResults', props.flattenSearchResults, this.flattenSearchResults);
|
|
@@ -9266,6 +9276,7 @@ class SelectTree extends TextInput {
|
|
|
9266
9276
|
this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
|
|
9267
9277
|
this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
|
|
9268
9278
|
this.preventLoadOnFocus = this.getInitValue('preventLoadOnFocus', props.preventLoadOnFocus, this.preventLoadOnFocus);
|
|
9279
|
+
this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
|
|
9269
9280
|
if (props.datasource && Object.keys(props.datasource).length) {
|
|
9270
9281
|
this.lazyLoad = props.datasource.lazyLoad !== false;
|
|
9271
9282
|
const searchFields = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
|
|
@@ -9302,7 +9313,7 @@ class SelectTree extends TextInput {
|
|
|
9302
9313
|
datasource: this.datasource,
|
|
9303
9314
|
parentField: this.parentField,
|
|
9304
9315
|
openLevelOnLoad: false,
|
|
9305
|
-
fetchOnDemand:
|
|
9316
|
+
fetchOnDemand: this.fetchOnDemand,
|
|
9306
9317
|
});
|
|
9307
9318
|
if (!this.lazyLoad) {
|
|
9308
9319
|
this.datasource.get().then(() => { this.createNodesFromDatasource(false); });
|
|
@@ -9322,7 +9333,16 @@ class SelectTree extends TextInput {
|
|
|
9322
9333
|
}
|
|
9323
9334
|
}
|
|
9324
9335
|
createNodeFromRow(row) {
|
|
9325
|
-
|
|
9336
|
+
let children;
|
|
9337
|
+
if (this.fetchOnDemand) {
|
|
9338
|
+
children = null;
|
|
9339
|
+
}
|
|
9340
|
+
else {
|
|
9341
|
+
children = this.createChildrenNodes(row.tree__children);
|
|
9342
|
+
if (!children.length) {
|
|
9343
|
+
children = undefined;
|
|
9344
|
+
}
|
|
9345
|
+
}
|
|
9326
9346
|
const dataTextArr = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
|
|
9327
9347
|
const dataTextNames = [];
|
|
9328
9348
|
const masks = [];
|
|
@@ -9357,15 +9377,18 @@ class SelectTree extends TextInput {
|
|
|
9357
9377
|
return {
|
|
9358
9378
|
id: row[this.dataValue],
|
|
9359
9379
|
label: dataText,
|
|
9360
|
-
children
|
|
9380
|
+
children,
|
|
9361
9381
|
row,
|
|
9362
9382
|
};
|
|
9363
9383
|
}
|
|
9364
9384
|
createChildrenNodes(rows) {
|
|
9365
9385
|
const newNodes = [];
|
|
9366
9386
|
rows.forEach((row) => {
|
|
9367
|
-
|
|
9368
|
-
|
|
9387
|
+
if (Object.keys(row).length > 0) {
|
|
9388
|
+
const newNode = this.createNodeFromRow(row);
|
|
9389
|
+
row.tree__node = newNode;
|
|
9390
|
+
newNodes.push(newNode);
|
|
9391
|
+
}
|
|
9369
9392
|
});
|
|
9370
9393
|
return newNodes;
|
|
9371
9394
|
}
|
|
@@ -9401,7 +9424,7 @@ class SelectTree extends TextInput {
|
|
|
9401
9424
|
return this.disabledItems.indexOf(node.id) !== -1;
|
|
9402
9425
|
}
|
|
9403
9426
|
getDisabledNodes(nodes) {
|
|
9404
|
-
return nodes.map((node) => (Object.assign(Object.assign({}, node), { isDisabled: this.isDisable(node), children: node.children ? this.getDisabledNodes(node.children) :
|
|
9427
|
+
return nodes.map((node) => (Object.assign(Object.assign({}, node), { isDisabled: this.isDisable(node), children: node.children ? this.getDisabledNodes(node.children) : node.children })));
|
|
9405
9428
|
}
|
|
9406
9429
|
getNodes() {
|
|
9407
9430
|
return this.getDisabledNodes(this.nodes);
|
|
@@ -9468,6 +9491,22 @@ class SelectTree extends TextInput {
|
|
|
9468
9491
|
}
|
|
9469
9492
|
this.selectValue = val;
|
|
9470
9493
|
}
|
|
9494
|
+
loadChildren(parentNode) {
|
|
9495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9496
|
+
return this.treeDataStructure.toggleExpand(parentNode.row).then((data) => {
|
|
9497
|
+
const node = parentNode.row.tree__node;
|
|
9498
|
+
if (node) {
|
|
9499
|
+
if (!data || data.length === 0) {
|
|
9500
|
+
node.children = undefined;
|
|
9501
|
+
}
|
|
9502
|
+
else {
|
|
9503
|
+
const nodes = this.createChildrenNodes(data);
|
|
9504
|
+
node.children = nodes;
|
|
9505
|
+
}
|
|
9506
|
+
}
|
|
9507
|
+
});
|
|
9508
|
+
});
|
|
9509
|
+
}
|
|
9471
9510
|
}
|
|
9472
9511
|
|
|
9473
9512
|
/**
|
|
@@ -10540,6 +10579,10 @@ class Tree extends ComponentRender {
|
|
|
10540
10579
|
children: [],
|
|
10541
10580
|
};
|
|
10542
10581
|
newNode = merge(newNode, node, override);
|
|
10582
|
+
if (typeof node.isLeaf === 'undefined') {
|
|
10583
|
+
const hasChildren = newNode.children.length > 0;
|
|
10584
|
+
newNode.isLeaf = !hasChildren;
|
|
10585
|
+
}
|
|
10543
10586
|
newNode.children = this.initNodes(node.children || [], override);
|
|
10544
10587
|
return newNode;
|
|
10545
10588
|
});
|
|
@@ -10614,6 +10657,7 @@ class Tree extends ComponentRender {
|
|
|
10614
10657
|
insertNode(newNode) {
|
|
10615
10658
|
const initNode = this.initNodes([newNode])[0];
|
|
10616
10659
|
if (this.selectedNodes.length) {
|
|
10660
|
+
this.updateNodeData(this.selectedNodes[0], { isLeaf: false });
|
|
10617
10661
|
const cursorPosition = {
|
|
10618
10662
|
node: this.selectedNodes[0],
|
|
10619
10663
|
placement: 'inside',
|
|
@@ -10624,31 +10668,44 @@ class Tree extends ComponentRender {
|
|
|
10624
10668
|
this.nodes.push(initNode);
|
|
10625
10669
|
}
|
|
10626
10670
|
}
|
|
10671
|
+
/** Import multiples nodes by the current cursor position */
|
|
10627
10672
|
importNodes(nodes) {
|
|
10628
10673
|
if (this.selectedNodes.length) {
|
|
10629
|
-
const cursorPosition = {
|
|
10630
|
-
node: this.selectedNodes[0],
|
|
10631
|
-
placement: 'inside',
|
|
10632
|
-
};
|
|
10633
10674
|
nodes.reverse().forEach((node) => {
|
|
10634
|
-
this.
|
|
10675
|
+
this.insertNode(node);
|
|
10635
10676
|
});
|
|
10636
10677
|
}
|
|
10637
10678
|
else {
|
|
10638
10679
|
nodes.forEach((node) => {
|
|
10639
|
-
this.
|
|
10680
|
+
this.insertNode(node);
|
|
10640
10681
|
});
|
|
10641
10682
|
}
|
|
10642
10683
|
}
|
|
10643
10684
|
/** Remove selected node */
|
|
10644
10685
|
removeSelected() {
|
|
10686
|
+
const parentNodesPath = [];
|
|
10645
10687
|
if (this.selectedNodes.length) {
|
|
10646
|
-
const selectedPaths = this.selectedNodes.map((item) =>
|
|
10688
|
+
const selectedPaths = this.selectedNodes.map((item) => {
|
|
10689
|
+
const parent = this.getParentNode(item);
|
|
10690
|
+
if (parent) {
|
|
10691
|
+
parentNodesPath.push(parent.path);
|
|
10692
|
+
}
|
|
10693
|
+
return item.path;
|
|
10694
|
+
});
|
|
10647
10695
|
this.tree.remove(selectedPaths);
|
|
10696
|
+
parentNodesPath.forEach((path) => {
|
|
10697
|
+
const parent = this.getNode(path);
|
|
10698
|
+
if (parent && parent.children && parent.children.length === 0) {
|
|
10699
|
+
this.tree.updateNode(path, { isLeaf: true });
|
|
10700
|
+
}
|
|
10701
|
+
});
|
|
10648
10702
|
}
|
|
10649
10703
|
}
|
|
10650
10704
|
/** Update selected node */
|
|
10651
10705
|
updateNodeData(node, value) {
|
|
10706
|
+
if (node.children && node.children.length === 0) {
|
|
10707
|
+
this.tree.updateNode(node.path, { isLeaf: true });
|
|
10708
|
+
}
|
|
10652
10709
|
this.tree.updateNode(node.path, value);
|
|
10653
10710
|
}
|
|
10654
10711
|
setTree(tree) {
|
|
@@ -10782,7 +10839,7 @@ class Tree extends ComponentRender {
|
|
|
10782
10839
|
}
|
|
10783
10840
|
getParentNode(node) {
|
|
10784
10841
|
const hasParent = Array.isArray(node.path) && node.path.length > 1;
|
|
10785
|
-
if (
|
|
10842
|
+
if (hasParent) {
|
|
10786
10843
|
return this.tree.getNode(node.path.slice(0, -1));
|
|
10787
10844
|
}
|
|
10788
10845
|
return undefined;
|
package/dist/zd-common.umd.js
CHANGED
|
@@ -2820,6 +2820,16 @@
|
|
|
2820
2820
|
return this.create(modal);
|
|
2821
2821
|
});
|
|
2822
2822
|
}
|
|
2823
|
+
/**
|
|
2824
|
+
* Creates a new modal instance from JSON
|
|
2825
|
+
* @param modal modal structure
|
|
2826
|
+
*/
|
|
2827
|
+
static createFromJsonPost(modalPath, params) {
|
|
2828
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2829
|
+
const modal = yield core.Metadata.post(modalPath, params);
|
|
2830
|
+
return this.create(modal);
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2823
2833
|
/**
|
|
2824
2834
|
* Deletes modal
|
|
2825
2835
|
* @param modal modal instance
|
|
@@ -3110,7 +3120,7 @@
|
|
|
3110
3120
|
];
|
|
3111
3121
|
this.editingMode = this.getInitValue('editingMode', props.editingMode, this.editingMode);
|
|
3112
3122
|
this.moveMode = this.getInitValue('moveMode', props.moveMode, this.moveMode);
|
|
3113
|
-
this.cards = props.cards
|
|
3123
|
+
this.cards = this.getInitValue('cards', props.cards, this.cards);
|
|
3114
3124
|
this.overrideNamedProps = props.overrideNamedProps || this.overrideNamedProps;
|
|
3115
3125
|
this.removePadding = this.getInitValue('removePadding', props.removePadding, this.removePadding);
|
|
3116
3126
|
this.height = this.getInitValue('height', props.height, this.height);
|
|
@@ -3138,13 +3148,7 @@
|
|
|
3138
3148
|
addCard() {
|
|
3139
3149
|
const addCardForm = core.Metadata.getInstance('addCardForm');
|
|
3140
3150
|
if (addCardForm.validate()) {
|
|
3141
|
-
const newCard = {
|
|
3142
|
-
cardId: this.getCardId(),
|
|
3143
|
-
path: addCardForm.value.inputPath,
|
|
3144
|
-
local: addCardForm.value.inputLocal,
|
|
3145
|
-
height: addCardForm.value.inputHeight,
|
|
3146
|
-
width: addCardForm.value.inputWidth,
|
|
3147
|
-
};
|
|
3151
|
+
const newCard = Object.assign({ cardId: this.getCardId(), path: addCardForm.value.inputPath, local: addCardForm.value.inputLocal, height: addCardForm.value.inputHeight, width: addCardForm.value.inputWidth }, addCardForm.value);
|
|
3148
3152
|
this.cards.push(newCard);
|
|
3149
3153
|
this.modalCancelClick();
|
|
3150
3154
|
}
|
|
@@ -9067,7 +9071,9 @@
|
|
|
9067
9071
|
originalData.splice(index + 1, 0, ...data);
|
|
9068
9072
|
this.originalDatasource.data = originalData;
|
|
9069
9073
|
this.originalDatasource.currentRow = this.clearRow(row);
|
|
9074
|
+
return data;
|
|
9070
9075
|
}
|
|
9076
|
+
return undefined;
|
|
9071
9077
|
});
|
|
9072
9078
|
}
|
|
9073
9079
|
/**
|
|
@@ -9255,6 +9261,10 @@
|
|
|
9255
9261
|
*/
|
|
9256
9262
|
this.lazyLoad = true;
|
|
9257
9263
|
this.selectValue = null;
|
|
9264
|
+
/**
|
|
9265
|
+
* Uses delayed loading to load tree branches
|
|
9266
|
+
*/
|
|
9267
|
+
this.fetchOnDemand = false;
|
|
9258
9268
|
this.nodes = this.getInitValue('nodes', props.nodes, this.nodes);
|
|
9259
9269
|
this.alwaysOpen = this.getInitValue('alwaysOpen', props.alwaysOpen, this.alwaysOpen);
|
|
9260
9270
|
this.flattenSearchResults = this.getInitValue('flattenSearchResults', props.flattenSearchResults, this.flattenSearchResults);
|
|
@@ -9273,6 +9283,7 @@
|
|
|
9273
9283
|
this.dataDisabled = this.getInitValue('dataDisabled', props.dataDisabled, this.dataDisabled);
|
|
9274
9284
|
this.disabledItems = this.getInitValue('disabledItems', props.disabledItems, this.disabledItems);
|
|
9275
9285
|
this.preventLoadOnFocus = this.getInitValue('preventLoadOnFocus', props.preventLoadOnFocus, this.preventLoadOnFocus);
|
|
9286
|
+
this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
|
|
9276
9287
|
if (props.datasource && Object.keys(props.datasource).length) {
|
|
9277
9288
|
this.lazyLoad = props.datasource.lazyLoad !== false;
|
|
9278
9289
|
const searchFields = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
|
|
@@ -9309,7 +9320,7 @@
|
|
|
9309
9320
|
datasource: this.datasource,
|
|
9310
9321
|
parentField: this.parentField,
|
|
9311
9322
|
openLevelOnLoad: false,
|
|
9312
|
-
fetchOnDemand:
|
|
9323
|
+
fetchOnDemand: this.fetchOnDemand,
|
|
9313
9324
|
});
|
|
9314
9325
|
if (!this.lazyLoad) {
|
|
9315
9326
|
this.datasource.get().then(() => { this.createNodesFromDatasource(false); });
|
|
@@ -9329,7 +9340,16 @@
|
|
|
9329
9340
|
}
|
|
9330
9341
|
}
|
|
9331
9342
|
createNodeFromRow(row) {
|
|
9332
|
-
|
|
9343
|
+
let children;
|
|
9344
|
+
if (this.fetchOnDemand) {
|
|
9345
|
+
children = null;
|
|
9346
|
+
}
|
|
9347
|
+
else {
|
|
9348
|
+
children = this.createChildrenNodes(row.tree__children);
|
|
9349
|
+
if (!children.length) {
|
|
9350
|
+
children = undefined;
|
|
9351
|
+
}
|
|
9352
|
+
}
|
|
9333
9353
|
const dataTextArr = Array.isArray(this.dataText) ? this.dataText : [this.dataText];
|
|
9334
9354
|
const dataTextNames = [];
|
|
9335
9355
|
const masks = [];
|
|
@@ -9364,15 +9384,18 @@
|
|
|
9364
9384
|
return {
|
|
9365
9385
|
id: row[this.dataValue],
|
|
9366
9386
|
label: dataText,
|
|
9367
|
-
children
|
|
9387
|
+
children,
|
|
9368
9388
|
row,
|
|
9369
9389
|
};
|
|
9370
9390
|
}
|
|
9371
9391
|
createChildrenNodes(rows) {
|
|
9372
9392
|
const newNodes = [];
|
|
9373
9393
|
rows.forEach((row) => {
|
|
9374
|
-
|
|
9375
|
-
|
|
9394
|
+
if (Object.keys(row).length > 0) {
|
|
9395
|
+
const newNode = this.createNodeFromRow(row);
|
|
9396
|
+
row.tree__node = newNode;
|
|
9397
|
+
newNodes.push(newNode);
|
|
9398
|
+
}
|
|
9376
9399
|
});
|
|
9377
9400
|
return newNodes;
|
|
9378
9401
|
}
|
|
@@ -9408,7 +9431,7 @@
|
|
|
9408
9431
|
return this.disabledItems.indexOf(node.id) !== -1;
|
|
9409
9432
|
}
|
|
9410
9433
|
getDisabledNodes(nodes) {
|
|
9411
|
-
return nodes.map((node) => (Object.assign(Object.assign({}, node), { isDisabled: this.isDisable(node), children: node.children ? this.getDisabledNodes(node.children) :
|
|
9434
|
+
return nodes.map((node) => (Object.assign(Object.assign({}, node), { isDisabled: this.isDisable(node), children: node.children ? this.getDisabledNodes(node.children) : node.children })));
|
|
9412
9435
|
}
|
|
9413
9436
|
getNodes() {
|
|
9414
9437
|
return this.getDisabledNodes(this.nodes);
|
|
@@ -9475,6 +9498,22 @@
|
|
|
9475
9498
|
}
|
|
9476
9499
|
this.selectValue = val;
|
|
9477
9500
|
}
|
|
9501
|
+
loadChildren(parentNode) {
|
|
9502
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9503
|
+
return this.treeDataStructure.toggleExpand(parentNode.row).then((data) => {
|
|
9504
|
+
const node = parentNode.row.tree__node;
|
|
9505
|
+
if (node) {
|
|
9506
|
+
if (!data || data.length === 0) {
|
|
9507
|
+
node.children = undefined;
|
|
9508
|
+
}
|
|
9509
|
+
else {
|
|
9510
|
+
const nodes = this.createChildrenNodes(data);
|
|
9511
|
+
node.children = nodes;
|
|
9512
|
+
}
|
|
9513
|
+
}
|
|
9514
|
+
});
|
|
9515
|
+
});
|
|
9516
|
+
}
|
|
9478
9517
|
}
|
|
9479
9518
|
|
|
9480
9519
|
/**
|
|
@@ -10547,6 +10586,10 @@
|
|
|
10547
10586
|
children: [],
|
|
10548
10587
|
};
|
|
10549
10588
|
newNode = merge__default["default"](newNode, node, override);
|
|
10589
|
+
if (typeof node.isLeaf === 'undefined') {
|
|
10590
|
+
const hasChildren = newNode.children.length > 0;
|
|
10591
|
+
newNode.isLeaf = !hasChildren;
|
|
10592
|
+
}
|
|
10550
10593
|
newNode.children = this.initNodes(node.children || [], override);
|
|
10551
10594
|
return newNode;
|
|
10552
10595
|
});
|
|
@@ -10621,6 +10664,7 @@
|
|
|
10621
10664
|
insertNode(newNode) {
|
|
10622
10665
|
const initNode = this.initNodes([newNode])[0];
|
|
10623
10666
|
if (this.selectedNodes.length) {
|
|
10667
|
+
this.updateNodeData(this.selectedNodes[0], { isLeaf: false });
|
|
10624
10668
|
const cursorPosition = {
|
|
10625
10669
|
node: this.selectedNodes[0],
|
|
10626
10670
|
placement: 'inside',
|
|
@@ -10631,31 +10675,44 @@
|
|
|
10631
10675
|
this.nodes.push(initNode);
|
|
10632
10676
|
}
|
|
10633
10677
|
}
|
|
10678
|
+
/** Import multiples nodes by the current cursor position */
|
|
10634
10679
|
importNodes(nodes) {
|
|
10635
10680
|
if (this.selectedNodes.length) {
|
|
10636
|
-
const cursorPosition = {
|
|
10637
|
-
node: this.selectedNodes[0],
|
|
10638
|
-
placement: 'inside',
|
|
10639
|
-
};
|
|
10640
10681
|
nodes.reverse().forEach((node) => {
|
|
10641
|
-
this.
|
|
10682
|
+
this.insertNode(node);
|
|
10642
10683
|
});
|
|
10643
10684
|
}
|
|
10644
10685
|
else {
|
|
10645
10686
|
nodes.forEach((node) => {
|
|
10646
|
-
this.
|
|
10687
|
+
this.insertNode(node);
|
|
10647
10688
|
});
|
|
10648
10689
|
}
|
|
10649
10690
|
}
|
|
10650
10691
|
/** Remove selected node */
|
|
10651
10692
|
removeSelected() {
|
|
10693
|
+
const parentNodesPath = [];
|
|
10652
10694
|
if (this.selectedNodes.length) {
|
|
10653
|
-
const selectedPaths = this.selectedNodes.map((item) =>
|
|
10695
|
+
const selectedPaths = this.selectedNodes.map((item) => {
|
|
10696
|
+
const parent = this.getParentNode(item);
|
|
10697
|
+
if (parent) {
|
|
10698
|
+
parentNodesPath.push(parent.path);
|
|
10699
|
+
}
|
|
10700
|
+
return item.path;
|
|
10701
|
+
});
|
|
10654
10702
|
this.tree.remove(selectedPaths);
|
|
10703
|
+
parentNodesPath.forEach((path) => {
|
|
10704
|
+
const parent = this.getNode(path);
|
|
10705
|
+
if (parent && parent.children && parent.children.length === 0) {
|
|
10706
|
+
this.tree.updateNode(path, { isLeaf: true });
|
|
10707
|
+
}
|
|
10708
|
+
});
|
|
10655
10709
|
}
|
|
10656
10710
|
}
|
|
10657
10711
|
/** Update selected node */
|
|
10658
10712
|
updateNodeData(node, value) {
|
|
10713
|
+
if (node.children && node.children.length === 0) {
|
|
10714
|
+
this.tree.updateNode(node.path, { isLeaf: true });
|
|
10715
|
+
}
|
|
10659
10716
|
this.tree.updateNode(node.path, value);
|
|
10660
10717
|
}
|
|
10661
10718
|
setTree(tree) {
|
|
@@ -10789,7 +10846,7 @@
|
|
|
10789
10846
|
}
|
|
10790
10847
|
getParentNode(node) {
|
|
10791
10848
|
const hasParent = Array.isArray(node.path) && node.path.length > 1;
|
|
10792
|
-
if (
|
|
10849
|
+
if (hasParent) {
|
|
10793
10850
|
return this.tree.getNode(node.path.slice(0, -1));
|
|
10794
10851
|
}
|
|
10795
10852
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.50.0",
|
|
4
4
|
"description": "Zeedhi Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"lodash.times": "^4.3.2",
|
|
38
38
|
"mockdate": "^3.0.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "47f7e1870055d3ad9bba54c0f96b1e34176b70b6"
|
|
41
41
|
}
|
|
@@ -2,7 +2,7 @@ import { IEventParam } from '@zeedhi/core';
|
|
|
2
2
|
import { Dashboard } from './dashboard';
|
|
3
3
|
import { IComponentRender, IComponentEvents } from '../zd-component/interfaces';
|
|
4
4
|
import { IButton } from '../zd-button/interfaces';
|
|
5
|
-
import {
|
|
5
|
+
import { ICard } from '../zd-card/interfaces';
|
|
6
6
|
export declare type IDashboardEventParam = IEventParam<Dashboard>;
|
|
7
7
|
export declare type IDashboardLoadEvent<T> = (event: T) => Promise<any>;
|
|
8
8
|
export interface IDashboardEvents<T = IEventParam<any>> extends IComponentEvents<T> {
|
|
@@ -19,13 +19,11 @@ export interface IDashboard extends IComponentRender {
|
|
|
19
19
|
height?: string | number;
|
|
20
20
|
heightAdjust?: string | number;
|
|
21
21
|
}
|
|
22
|
-
export interface IDashboardCard {
|
|
22
|
+
export interface IDashboardCard extends Omit<ICard, 'name' | 'component'> {
|
|
23
23
|
cardId: string;
|
|
24
24
|
path: string;
|
|
25
25
|
local: boolean;
|
|
26
26
|
height: number | string;
|
|
27
|
-
width: number;
|
|
28
|
-
flat?: boolean;
|
|
29
|
-
events?: ICardEvents;
|
|
27
|
+
width: number | string;
|
|
30
28
|
overrideNamedProps?: any;
|
|
31
29
|
}
|
|
@@ -6,7 +6,8 @@ export interface ISelectTreeNode<T> {
|
|
|
6
6
|
label: string;
|
|
7
7
|
isDisabled?: boolean;
|
|
8
8
|
isDefaultExpanded?: boolean;
|
|
9
|
-
children?: ISelectTreeNode<T>[];
|
|
9
|
+
children?: ISelectTreeNode<T>[] | null;
|
|
10
|
+
row?: IDictionary<any>;
|
|
10
11
|
}
|
|
11
12
|
export interface ISelectTree extends IComponentRender {
|
|
12
13
|
nodes?: ISelectTreeNode<IDictionary>[];
|
|
@@ -28,6 +29,7 @@ export interface ISelectTree extends IComponentRender {
|
|
|
28
29
|
dataText?: string | any[];
|
|
29
30
|
dataDisabled?: string;
|
|
30
31
|
disabledItems?: any[];
|
|
32
|
+
fetchOnDemand?: boolean;
|
|
31
33
|
}
|
|
32
34
|
export interface ISelectTreeCloseEvent extends IEventParam<SelectTree> {
|
|
33
35
|
selectedNodes: ISelectTreeNode<IDictionary>[];
|
|
@@ -89,6 +89,10 @@ export declare class SelectTree extends TextInput implements ISelectTree {
|
|
|
89
89
|
*/
|
|
90
90
|
private lazyLoad;
|
|
91
91
|
selectValue: any;
|
|
92
|
+
/**
|
|
93
|
+
* Uses delayed loading to load tree branches
|
|
94
|
+
*/
|
|
95
|
+
fetchOnDemand: boolean;
|
|
92
96
|
/**
|
|
93
97
|
* Creates a new instance of SelectTree
|
|
94
98
|
* @param props
|
|
@@ -135,4 +139,5 @@ export declare class SelectTree extends TextInput implements ISelectTree {
|
|
|
135
139
|
get value(): any;
|
|
136
140
|
set value(value: any);
|
|
137
141
|
setValue(value: any): void;
|
|
142
|
+
loadChildren(parentNode: ISelectTreeNode<IDictionary>): Promise<void>;
|
|
138
143
|
}
|
|
@@ -68,7 +68,7 @@ export declare class Tree extends ComponentRender implements ITree {
|
|
|
68
68
|
/**
|
|
69
69
|
* Initialize all the properties of the declared nodes (reactivity)
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
initNodes(nodes: ITreeNodeModel<IDictionary>[], override?: IDictionary): ITreeNodeModel<IDictionary>[];
|
|
72
72
|
/** Nodes */
|
|
73
73
|
get nodes(): ITreeNodeModel<IDictionary>[];
|
|
74
74
|
set nodes(value: ITreeNodeModel<IDictionary>[]);
|
|
@@ -82,6 +82,7 @@ export declare class Tree extends ComponentRender implements ITree {
|
|
|
82
82
|
private createChildrenNodes;
|
|
83
83
|
/** Insert nodes by the current cursor position */
|
|
84
84
|
insertNode(newNode: ITreeNodeModel<IDictionary>): void;
|
|
85
|
+
/** Import multiples nodes by the current cursor position */
|
|
85
86
|
importNodes(nodes: ITreeNodeModel<IDictionary>[]): void;
|
|
86
87
|
/** Remove selected node */
|
|
87
88
|
removeSelected(): void;
|
|
@@ -17,6 +17,11 @@ export declare class ModalService {
|
|
|
17
17
|
* @param modal modal structure
|
|
18
18
|
*/
|
|
19
19
|
static createFromJson(modalPath: string, local?: boolean): Promise<Modal>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new modal instance from JSON
|
|
22
|
+
* @param modal modal structure
|
|
23
|
+
*/
|
|
24
|
+
static createFromJsonPost(modalPath: string, params?: object): Promise<Modal>;
|
|
20
25
|
/**
|
|
21
26
|
* Deletes modal
|
|
22
27
|
* @param modal modal instance
|
|
@@ -105,7 +105,7 @@ export declare class TreeDataStructure {
|
|
|
105
105
|
* @param row Row object
|
|
106
106
|
* @param rowIndex Row index
|
|
107
107
|
*/
|
|
108
|
-
toggleExpand(row: IDictionary<any>, rowIndex?: number): Promise<
|
|
108
|
+
toggleExpand(row: IDictionary<any>, rowIndex?: number): Promise<IDictionary<any>[] | undefined>;
|
|
109
109
|
/**
|
|
110
110
|
* Return row with tree data
|
|
111
111
|
* @param row datasource row
|