jedison 1.6.1 → 1.8.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/CHANGELOG.md +15 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +264 -16
- package/dist/esm/jedison.js.map +1 -1
- package/dist/umd/jedison.umd.js +1 -1
- package/dist/umd/jedison.umd.js.map +1 -1
- package/package.json +3 -2
package/dist/esm/jedison.js
CHANGED
|
@@ -2556,19 +2556,23 @@ class InstanceIfThenElse extends Instance {
|
|
|
2556
2556
|
});
|
|
2557
2557
|
}
|
|
2558
2558
|
const startingValue = this.instanceStartingValues[index2];
|
|
2559
|
-
const currentValue = instance.getValue();
|
|
2560
2559
|
let instanceValue = value;
|
|
2561
2560
|
if (isObject(startingValue) && isObject(value)) {
|
|
2562
|
-
if (indexChanged) {
|
|
2561
|
+
if (indexChanged && initiator !== "api") {
|
|
2563
2562
|
instanceValue = overwriteExistingProperties(startingValue, withoutIf);
|
|
2564
|
-
this.jedison.updateInstancesWatchedData();
|
|
2565
2563
|
} else {
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2564
|
+
const audacity = this.jedison.options.audacity;
|
|
2565
|
+
if (audacity && initiator === "api" && index2 === fittestIndex) {
|
|
2566
|
+
const prePassValue = mergeDeep({}, instance.getValue(), value);
|
|
2567
|
+
instance.setValue(prePassValue, false, "api");
|
|
2568
|
+
}
|
|
2569
|
+
const currentValue = instance.getValue();
|
|
2569
2570
|
instanceValue = overwriteExistingProperties(currentValue, value);
|
|
2570
2571
|
}
|
|
2571
2572
|
}
|
|
2573
|
+
if (indexChanged) {
|
|
2574
|
+
this.jedison.updateInstancesWatchedData();
|
|
2575
|
+
}
|
|
2572
2576
|
instance.setValue(instanceValue, false, initiator);
|
|
2573
2577
|
instance.on("notifyParent", (initiator2) => {
|
|
2574
2578
|
const value2 = instance.getValueRaw();
|
|
@@ -2580,6 +2584,7 @@ class InstanceIfThenElse extends Instance {
|
|
|
2580
2584
|
if (initiator === "api" && this.hasNullableFields(this.activeInstance)) {
|
|
2581
2585
|
this.activeInstance.setValue(value, false, "secondary");
|
|
2582
2586
|
}
|
|
2587
|
+
this.activeInstance.register();
|
|
2583
2588
|
this.value = this.activeInstance.getValueRaw();
|
|
2584
2589
|
}
|
|
2585
2590
|
getWithoutIfValueFromValue(value) {
|
|
@@ -3150,6 +3155,17 @@ class InstanceArray extends Instance {
|
|
|
3150
3155
|
this.emit("item-add", initiator, instance);
|
|
3151
3156
|
this.jedison.emit("item-add", initiator, instance);
|
|
3152
3157
|
}
|
|
3158
|
+
addItemAfter(afterIndex, initiator) {
|
|
3159
|
+
const tempEditor = this.createItemInstance();
|
|
3160
|
+
const raw = this.getValueRaw();
|
|
3161
|
+
const value = isArray(raw) ? clone(raw) : [];
|
|
3162
|
+
value.splice(afterIndex + 1, 0, tempEditor.getValueRaw());
|
|
3163
|
+
tempEditor.destroy();
|
|
3164
|
+
this.setValue(value, true, initiator);
|
|
3165
|
+
const instance = this.children[afterIndex + 1];
|
|
3166
|
+
this.emit("item-add", initiator, instance);
|
|
3167
|
+
this.jedison.emit("item-add", initiator, instance);
|
|
3168
|
+
}
|
|
3153
3169
|
deleteItem(itemIndex, initiator) {
|
|
3154
3170
|
const raw = this.getValueRaw();
|
|
3155
3171
|
if (!isArray(raw)) {
|
|
@@ -4325,7 +4341,7 @@ class EditorObjectCategories extends EditorObject {
|
|
|
4325
4341
|
categoryName = defaultLabel;
|
|
4326
4342
|
}
|
|
4327
4343
|
if (!categoriesMap.has(categoryName)) {
|
|
4328
|
-
categoriesMap.set(categoryName, { children: [], id:
|
|
4344
|
+
categoriesMap.set(categoryName, { children: [], id: this.getIdFromPath(child.path) });
|
|
4329
4345
|
}
|
|
4330
4346
|
categoriesMap.get(categoryName).children.push(child);
|
|
4331
4347
|
});
|
|
@@ -4425,7 +4441,7 @@ class EditorObjectNav extends EditorObject {
|
|
|
4425
4441
|
this.instance.children.forEach((child, index2) => {
|
|
4426
4442
|
if (!this.isChildVisible(child)) return;
|
|
4427
4443
|
const active = index2 === this.activeTabIndex;
|
|
4428
|
-
const id =
|
|
4444
|
+
const id = this.getIdFromPath(child.path);
|
|
4429
4445
|
const schemaTitle = getSchemaTitle(child.schema);
|
|
4430
4446
|
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
4431
4447
|
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
@@ -4471,14 +4487,49 @@ class EditorArray extends Editor {
|
|
|
4471
4487
|
editJsonData: getSchemaXOption(this.instance.schema, "editJsonData") ?? this.instance.jedison.options.editJsonData,
|
|
4472
4488
|
arrayAdd: getSchemaXOption(this.instance.schema, "arrayAdd") ?? this.instance.jedison.options.arrayAdd,
|
|
4473
4489
|
arrayAddContent: getSchemaXOption(this.instance.schema, "arrayAddContent") ?? this.instance.jedison.translator.translate("arrayAdd"),
|
|
4490
|
+
arrayFooterAdd: getSchemaXOption(this.instance.schema, "arrayFooterAdd") ?? this.instance.jedison.options.arrayFooterAdd,
|
|
4491
|
+
arrayFooterAddContent: getSchemaXOption(this.instance.schema, "arrayFooterAddContent") ?? this.instance.jedison.translator.translate("arrayAdd"),
|
|
4492
|
+
arrayFooterButtonsPosition: getSchemaXOption(this.instance.schema, "arrayFooterButtonsPosition") ?? this.instance.jedison.options.arrayFooterButtonsPosition,
|
|
4493
|
+
arrayDeleteAll: getSchemaXOption(this.instance.schema, "arrayDeleteAll") ?? this.instance.jedison.options.arrayDeleteAll,
|
|
4494
|
+
arrayDeleteAllContent: getSchemaXOption(this.instance.schema, "arrayDeleteAllContent") ?? this.instance.jedison.translator.translate("arrayDeleteAll"),
|
|
4495
|
+
arrayFooterDeleteAll: getSchemaXOption(this.instance.schema, "arrayFooterDeleteAll") ?? this.instance.jedison.options.arrayFooterDeleteAll,
|
|
4496
|
+
arrayFooterDeleteAllContent: getSchemaXOption(this.instance.schema, "arrayFooterDeleteAllContent") ?? this.instance.jedison.translator.translate("arrayDeleteAll"),
|
|
4474
4497
|
collapseToggleContent: getSchemaXOption(this.instance.schema, "collapseToggleContent") ?? this.instance.jedison.translator.translate("collapseToggle")
|
|
4475
4498
|
});
|
|
4476
4499
|
this.control.jsonData.input.value = JSON.stringify(this.instance.getValue(), null, 2);
|
|
4477
4500
|
}
|
|
4501
|
+
deleteAllItems() {
|
|
4502
|
+
const schemaConfirm = getSchemaXOption(this.instance.schema, "arrayDeleteConfirm");
|
|
4503
|
+
const globalConfirm = this.instance.jedison.options.arrayDeleteConfirm;
|
|
4504
|
+
const shouldConfirm = isSet(schemaConfirm) ? schemaConfirm : globalConfirm;
|
|
4505
|
+
const doDeleteAll = () => {
|
|
4506
|
+
this.instance.setValue([], true, "user");
|
|
4507
|
+
};
|
|
4508
|
+
if (shouldConfirm) {
|
|
4509
|
+
if (window.confirm(this.instance.jedison.translator.translate("arrayConfirmDeleteAll"))) {
|
|
4510
|
+
doDeleteAll();
|
|
4511
|
+
}
|
|
4512
|
+
} else {
|
|
4513
|
+
doDeleteAll();
|
|
4514
|
+
}
|
|
4515
|
+
}
|
|
4478
4516
|
addEventListeners() {
|
|
4479
4517
|
this.control.addBtn.addEventListener("click", () => {
|
|
4480
4518
|
this.instance.addItem("user");
|
|
4481
4519
|
});
|
|
4520
|
+
this.control.footerAddBtn.addEventListener("click", () => {
|
|
4521
|
+
this.instance.addItem("user");
|
|
4522
|
+
});
|
|
4523
|
+
if (this.control.deleteAllBtn) {
|
|
4524
|
+
this.control.deleteAllBtn.addEventListener("click", () => {
|
|
4525
|
+
this.deleteAllItems();
|
|
4526
|
+
});
|
|
4527
|
+
}
|
|
4528
|
+
if (this.control.footerDeleteAllBtn) {
|
|
4529
|
+
this.control.footerDeleteAllBtn.addEventListener("click", () => {
|
|
4530
|
+
this.deleteAllItems();
|
|
4531
|
+
});
|
|
4532
|
+
}
|
|
4482
4533
|
this.addJsonDataEventListeners();
|
|
4483
4534
|
}
|
|
4484
4535
|
addJsonDataEventListeners() {
|
|
@@ -4509,6 +4560,7 @@ class EditorArray extends Editor {
|
|
|
4509
4560
|
const schemaMoveUpContent = getSchemaXOption(this.instance.schema, "arrayMoveUpContent");
|
|
4510
4561
|
const schemaMoveDownContent = getSchemaXOption(this.instance.schema, "arrayMoveDownContent");
|
|
4511
4562
|
const schemaDragContent = getSchemaXOption(this.instance.schema, "arrayDragContent");
|
|
4563
|
+
const schemaAddAfterContent = getSchemaXOption(this.instance.schema, "arrayAddAfterContent");
|
|
4512
4564
|
const deleteBtn = this.theme.getDeleteItemBtn({
|
|
4513
4565
|
content: schemaDeleteContent ?? this.instance.jedison.translator.translate("arrayDelete")
|
|
4514
4566
|
});
|
|
@@ -4521,6 +4573,9 @@ class EditorArray extends Editor {
|
|
|
4521
4573
|
const dragBtn = this.theme.getDragItemBtn({
|
|
4522
4574
|
content: schemaDragContent ?? this.instance.jedison.translator.translate("arrayDrag")
|
|
4523
4575
|
});
|
|
4576
|
+
const addAfterBtn = this.theme.getAddAfterItemBtn({
|
|
4577
|
+
content: schemaAddAfterContent ?? this.instance.jedison.translator.translate("arrayAddAfter")
|
|
4578
|
+
});
|
|
4524
4579
|
const btnGroup = this.theme.getBtnGroup();
|
|
4525
4580
|
deleteBtn.addEventListener("click", () => {
|
|
4526
4581
|
const schemaConfirm = getSchemaXOption(this.instance.schema, "arrayDeleteConfirm");
|
|
@@ -4548,13 +4603,17 @@ class EditorArray extends Editor {
|
|
|
4548
4603
|
this.activeItemIndex = toIndex;
|
|
4549
4604
|
this.instance.move(index2, toIndex, "user");
|
|
4550
4605
|
});
|
|
4606
|
+
addAfterBtn.addEventListener("click", () => {
|
|
4607
|
+
this.activeItemIndex = index2 + 1;
|
|
4608
|
+
this.instance.addItemAfter(index2, "user");
|
|
4609
|
+
});
|
|
4551
4610
|
if (index2 === 0) {
|
|
4552
4611
|
moveUpBtn.setAttribute("always-disabled", true);
|
|
4553
4612
|
}
|
|
4554
4613
|
if (index2 === this.instance.children.length - 1) {
|
|
4555
4614
|
moveDownBtn.setAttribute("always-disabled", true);
|
|
4556
4615
|
}
|
|
4557
|
-
return { deleteBtn, moveUpBtn, moveDownBtn, btnGroup, dragBtn };
|
|
4616
|
+
return { deleteBtn, moveUpBtn, moveDownBtn, btnGroup, dragBtn, addAfterBtn };
|
|
4558
4617
|
}
|
|
4559
4618
|
isSortable() {
|
|
4560
4619
|
return window.Sortable && isSet(getSchemaXOption(this.instance.schema, "sortable"));
|
|
@@ -4574,16 +4633,47 @@ class EditorArray extends Editor {
|
|
|
4574
4633
|
});
|
|
4575
4634
|
}
|
|
4576
4635
|
}
|
|
4636
|
+
refreshDeleteAllBtn() {
|
|
4637
|
+
if (!this.control.deleteAllBtn && !this.control.footerDeleteAllBtn) return;
|
|
4638
|
+
const isEmpty = this.instance.value.length === 0;
|
|
4639
|
+
const cannotDeleteAll = isEmpty;
|
|
4640
|
+
const btns = [this.control.deleteAllBtn, this.control.footerDeleteAllBtn].filter(Boolean);
|
|
4641
|
+
if (cannotDeleteAll || this.disabled || this.readOnly) {
|
|
4642
|
+
btns.forEach((btn) => {
|
|
4643
|
+
btn.setAttribute("disabled", "");
|
|
4644
|
+
btn.setAttribute("always-disabled", true);
|
|
4645
|
+
});
|
|
4646
|
+
} else {
|
|
4647
|
+
if (!this.disabled && !this.readOnly) {
|
|
4648
|
+
btns.forEach((btn) => {
|
|
4649
|
+
btn.removeAttribute("disabled");
|
|
4650
|
+
btn.removeAttribute("always-disabled");
|
|
4651
|
+
});
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4577
4655
|
refreshAddBtn() {
|
|
4578
4656
|
const maxItems2 = getSchemaMaxItems(this.instance.schema);
|
|
4579
4657
|
const enforceMaxItems = getSchemaXOption(this.instance.schema, "enforceMaxItems") ?? this.instance.jedison.options.enforceMaxItems;
|
|
4580
4658
|
if (isSet(maxItems2) && enforceMaxItems && maxItems2 <= this.instance.value.length) {
|
|
4581
4659
|
this.control.addBtn.setAttribute("disabled", "");
|
|
4582
4660
|
this.control.addBtn.setAttribute("always-disabled", true);
|
|
4661
|
+
this.control.footerAddBtn.setAttribute("disabled", "");
|
|
4662
|
+
this.control.footerAddBtn.setAttribute("always-disabled", true);
|
|
4663
|
+
this.control.childrenSlot.querySelectorAll(".jedi-array-add-after").forEach((btn) => {
|
|
4664
|
+
btn.setAttribute("disabled", "");
|
|
4665
|
+
btn.setAttribute("always-disabled", true);
|
|
4666
|
+
});
|
|
4583
4667
|
} else {
|
|
4584
4668
|
if (!this.disabled && !this.readOnly) {
|
|
4585
4669
|
this.control.addBtn.removeAttribute("disabled");
|
|
4586
4670
|
this.control.addBtn.removeAttribute("always-disabled");
|
|
4671
|
+
this.control.footerAddBtn.removeAttribute("disabled");
|
|
4672
|
+
this.control.footerAddBtn.removeAttribute("always-disabled");
|
|
4673
|
+
this.control.childrenSlot.querySelectorAll(".jedi-array-add-after").forEach((btn) => {
|
|
4674
|
+
btn.removeAttribute("disabled");
|
|
4675
|
+
btn.removeAttribute("always-disabled");
|
|
4676
|
+
});
|
|
4587
4677
|
}
|
|
4588
4678
|
}
|
|
4589
4679
|
}
|
|
@@ -4592,9 +4682,10 @@ class EditorArray extends Editor {
|
|
|
4592
4682
|
const minItems2 = getSchemaMinItems(this.instance.schema);
|
|
4593
4683
|
const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
|
|
4594
4684
|
const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
|
|
4685
|
+
const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.options.arrayAddAfter;
|
|
4595
4686
|
this.control.childrenSlot.innerHTML = "";
|
|
4596
4687
|
this.instance.children.forEach((child, index2) => {
|
|
4597
|
-
const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup } = this.getButtons(index2);
|
|
4688
|
+
const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup, addAfterBtn } = this.getButtons(index2);
|
|
4598
4689
|
const { container, arrayActions, body } = this.theme.getArrayItem({
|
|
4599
4690
|
readOnly: this.instance.isReadOnly(),
|
|
4600
4691
|
index: index2
|
|
@@ -4610,6 +4701,9 @@ class EditorArray extends Editor {
|
|
|
4610
4701
|
if (this.isSortable()) {
|
|
4611
4702
|
btnGroup.appendChild(dragBtn);
|
|
4612
4703
|
}
|
|
4704
|
+
if (isSet(arrayAddAfter) && arrayAddAfter === true) {
|
|
4705
|
+
btnGroup.appendChild(addAfterBtn);
|
|
4706
|
+
}
|
|
4613
4707
|
this.control.childrenSlot.appendChild(container);
|
|
4614
4708
|
body.appendChild(child.ui.control.container);
|
|
4615
4709
|
if (this.disabled || this.instance.isReadOnly()) {
|
|
@@ -4627,6 +4721,7 @@ class EditorArray extends Editor {
|
|
|
4627
4721
|
child.ui.refreshUI();
|
|
4628
4722
|
});
|
|
4629
4723
|
this.refreshAddBtn();
|
|
4724
|
+
this.refreshDeleteAllBtn();
|
|
4630
4725
|
this.refreshJsonData();
|
|
4631
4726
|
this.refreshLegendWarning();
|
|
4632
4727
|
}
|
|
@@ -4699,6 +4794,20 @@ class EditorArrayTable extends EditorArray {
|
|
|
4699
4794
|
this.activeItemIndex = this.instance.value.length;
|
|
4700
4795
|
this.instance.addItem("user");
|
|
4701
4796
|
});
|
|
4797
|
+
this.control.footerAddBtn.addEventListener("click", () => {
|
|
4798
|
+
this.activeItemIndex = this.instance.value.length;
|
|
4799
|
+
this.instance.addItem("user");
|
|
4800
|
+
});
|
|
4801
|
+
if (this.control.deleteAllBtn) {
|
|
4802
|
+
this.control.deleteAllBtn.addEventListener("click", () => {
|
|
4803
|
+
this.deleteAllItems();
|
|
4804
|
+
});
|
|
4805
|
+
}
|
|
4806
|
+
if (this.control.footerDeleteAllBtn) {
|
|
4807
|
+
this.control.footerDeleteAllBtn.addEventListener("click", () => {
|
|
4808
|
+
this.deleteAllItems();
|
|
4809
|
+
});
|
|
4810
|
+
}
|
|
4702
4811
|
this.addJsonDataEventListeners();
|
|
4703
4812
|
}
|
|
4704
4813
|
isSortable() {
|
|
@@ -4711,6 +4820,7 @@ class EditorArrayTable extends EditorArray {
|
|
|
4711
4820
|
const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
|
|
4712
4821
|
const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
|
|
4713
4822
|
const arrayButtonsPosition = getSchemaXOption(this.instance.schema, "arrayButtonsPosition") ?? this.instance.jedison.options.arrayButtonsPosition;
|
|
4823
|
+
const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.options.arrayAddAfter;
|
|
4714
4824
|
const th = this.theme.getTableHeader();
|
|
4715
4825
|
const { label } = this.theme.getFakeLabel({
|
|
4716
4826
|
content: "Controls",
|
|
@@ -4748,7 +4858,7 @@ class EditorArrayTable extends EditorArray {
|
|
|
4748
4858
|
this.instance.children.forEach((child, index2) => {
|
|
4749
4859
|
const tbodyRow = document.createElement("tr");
|
|
4750
4860
|
const buttonsTd = this.theme.getTableDefinition({ isButtonColumn: true });
|
|
4751
|
-
const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup } = this.getButtons(index2);
|
|
4861
|
+
const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup, addAfterBtn } = this.getButtons(index2);
|
|
4752
4862
|
if (this.isSortable()) {
|
|
4753
4863
|
btnGroup.appendChild(dragBtn);
|
|
4754
4864
|
}
|
|
@@ -4759,6 +4869,9 @@ class EditorArrayTable extends EditorArray {
|
|
|
4759
4869
|
btnGroup.appendChild(moveUpBtn);
|
|
4760
4870
|
btnGroup.appendChild(moveDownBtn);
|
|
4761
4871
|
}
|
|
4872
|
+
if (isSet(arrayAddAfter) && arrayAddAfter === true) {
|
|
4873
|
+
btnGroup.appendChild(addAfterBtn);
|
|
4874
|
+
}
|
|
4762
4875
|
buttonsTd.appendChild(btnGroup);
|
|
4763
4876
|
if (arrayButtonsPosition === "left") {
|
|
4764
4877
|
tbodyRow.appendChild(buttonsTd);
|
|
@@ -4774,6 +4887,7 @@ class EditorArrayTable extends EditorArray {
|
|
|
4774
4887
|
});
|
|
4775
4888
|
this.refreshSortable(table.tbody);
|
|
4776
4889
|
this.refreshAddBtn();
|
|
4890
|
+
this.refreshDeleteAllBtn();
|
|
4777
4891
|
this.refreshJsonData();
|
|
4778
4892
|
this.refreshDisabledState();
|
|
4779
4893
|
this.refreshScrollPosition(table.container);
|
|
@@ -4824,6 +4938,20 @@ class EditorArrayTableObject extends EditorArray {
|
|
|
4824
4938
|
this.activeItemIndex = this.instance.value.length;
|
|
4825
4939
|
this.instance.addItem("user");
|
|
4826
4940
|
});
|
|
4941
|
+
this.control.footerAddBtn.addEventListener("click", () => {
|
|
4942
|
+
this.activeItemIndex = this.instance.value.length;
|
|
4943
|
+
this.instance.addItem("user");
|
|
4944
|
+
});
|
|
4945
|
+
if (this.control.deleteAllBtn) {
|
|
4946
|
+
this.control.deleteAllBtn.addEventListener("click", () => {
|
|
4947
|
+
this.deleteAllItems();
|
|
4948
|
+
});
|
|
4949
|
+
}
|
|
4950
|
+
if (this.control.footerDeleteAllBtn) {
|
|
4951
|
+
this.control.footerDeleteAllBtn.addEventListener("click", () => {
|
|
4952
|
+
this.deleteAllItems();
|
|
4953
|
+
});
|
|
4954
|
+
}
|
|
4827
4955
|
this.addJsonDataEventListeners();
|
|
4828
4956
|
}
|
|
4829
4957
|
isSortable() {
|
|
@@ -4836,6 +4964,7 @@ class EditorArrayTableObject extends EditorArray {
|
|
|
4836
4964
|
const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
|
|
4837
4965
|
const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
|
|
4838
4966
|
const arrayButtonsPosition = getSchemaXOption(this.instance.schema, "arrayButtonsPosition") ?? this.instance.jedison.options.arrayButtonsPosition;
|
|
4967
|
+
const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.options.arrayAddAfter;
|
|
4839
4968
|
const th = this.theme.getTableHeader();
|
|
4840
4969
|
const { label } = this.theme.getFakeLabel({
|
|
4841
4970
|
content: "Controls",
|
|
@@ -4879,7 +5008,7 @@ class EditorArrayTableObject extends EditorArray {
|
|
|
4879
5008
|
this.instance.children.forEach((child, index2) => {
|
|
4880
5009
|
const tbodyRow = document.createElement("tr");
|
|
4881
5010
|
const buttonsTd = this.theme.getTableDefinition({ isButtonColumn: true });
|
|
4882
|
-
const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup } = this.getButtons(index2);
|
|
5011
|
+
const { deleteBtn, moveUpBtn, moveDownBtn, dragBtn, btnGroup, addAfterBtn } = this.getButtons(index2);
|
|
4883
5012
|
if (this.isSortable()) {
|
|
4884
5013
|
btnGroup.appendChild(dragBtn);
|
|
4885
5014
|
}
|
|
@@ -4890,6 +5019,9 @@ class EditorArrayTableObject extends EditorArray {
|
|
|
4890
5019
|
btnGroup.appendChild(moveUpBtn);
|
|
4891
5020
|
btnGroup.appendChild(moveDownBtn);
|
|
4892
5021
|
}
|
|
5022
|
+
if (isSet(arrayAddAfter) && arrayAddAfter === true) {
|
|
5023
|
+
btnGroup.appendChild(addAfterBtn);
|
|
5024
|
+
}
|
|
4893
5025
|
buttonsTd.appendChild(btnGroup);
|
|
4894
5026
|
if (arrayButtonsPosition === "left") {
|
|
4895
5027
|
tbodyRow.appendChild(buttonsTd);
|
|
@@ -4914,6 +5046,7 @@ class EditorArrayTableObject extends EditorArray {
|
|
|
4914
5046
|
});
|
|
4915
5047
|
this.refreshSortable(table.tbody);
|
|
4916
5048
|
this.refreshAddBtn();
|
|
5049
|
+
this.refreshDeleteAllBtn();
|
|
4917
5050
|
this.refreshJsonData();
|
|
4918
5051
|
this.refreshDisabledState();
|
|
4919
5052
|
this.refreshScrollPosition(table.container);
|
|
@@ -5085,6 +5218,22 @@ class EditorArrayNav extends EditorArray {
|
|
|
5085
5218
|
this.activeItemIndex = this.instance.value.length;
|
|
5086
5219
|
this.instance.addItem("user");
|
|
5087
5220
|
});
|
|
5221
|
+
this.control.footerAddBtn.addEventListener("click", () => {
|
|
5222
|
+
this.activeItemIndex = this.instance.value.length;
|
|
5223
|
+
this.instance.addItem("user");
|
|
5224
|
+
});
|
|
5225
|
+
if (this.control.deleteAllBtn) {
|
|
5226
|
+
this.control.deleteAllBtn.addEventListener("click", () => {
|
|
5227
|
+
this.activeItemIndex = 0;
|
|
5228
|
+
this.deleteAllItems();
|
|
5229
|
+
});
|
|
5230
|
+
}
|
|
5231
|
+
if (this.control.footerDeleteAllBtn) {
|
|
5232
|
+
this.control.footerDeleteAllBtn.addEventListener("click", () => {
|
|
5233
|
+
this.activeItemIndex = 0;
|
|
5234
|
+
this.deleteAllItems();
|
|
5235
|
+
});
|
|
5236
|
+
}
|
|
5088
5237
|
this.addJsonDataEventListeners();
|
|
5089
5238
|
}
|
|
5090
5239
|
refreshUI() {
|
|
@@ -5104,13 +5253,14 @@ class EditorArrayNav extends EditorArray {
|
|
|
5104
5253
|
});
|
|
5105
5254
|
const arrayDelete = getSchemaXOption(this.instance.schema, "arrayDelete") ?? this.instance.jedison.options.arrayDelete;
|
|
5106
5255
|
const arrayMove = getSchemaXOption(this.instance.schema, "arrayMove") ?? this.instance.jedison.options.arrayMove;
|
|
5256
|
+
const arrayAddAfter = getSchemaXOption(this.instance.schema, "arrayAddAfter") ?? this.instance.jedison.options.arrayAddAfter;
|
|
5107
5257
|
this.control.childrenSlot.appendChild(row);
|
|
5108
5258
|
row.appendChild(tabListCol);
|
|
5109
5259
|
row.appendChild(tabContentCol);
|
|
5110
5260
|
tabListCol.appendChild(tabList);
|
|
5111
5261
|
tabContentCol.appendChild(tabContent);
|
|
5112
5262
|
this.instance.children.forEach((child, index2) => {
|
|
5113
|
-
const { deleteBtn, moveUpBtn, moveDownBtn, btnGroup } = this.getButtons(index2);
|
|
5263
|
+
const { deleteBtn, moveUpBtn, moveDownBtn, btnGroup, addAfterBtn } = this.getButtons(index2);
|
|
5114
5264
|
if (isSet(arrayDelete) && arrayDelete === true) {
|
|
5115
5265
|
btnGroup.appendChild(deleteBtn);
|
|
5116
5266
|
}
|
|
@@ -5118,6 +5268,9 @@ class EditorArrayNav extends EditorArray {
|
|
|
5118
5268
|
btnGroup.appendChild(moveUpBtn);
|
|
5119
5269
|
btnGroup.appendChild(moveDownBtn);
|
|
5120
5270
|
}
|
|
5271
|
+
if (isSet(arrayAddAfter) && arrayAddAfter === true) {
|
|
5272
|
+
btnGroup.appendChild(addAfterBtn);
|
|
5273
|
+
}
|
|
5121
5274
|
this.control.childrenSlot.appendChild(child.ui.control.container);
|
|
5122
5275
|
const schemaTitle = getSchemaTitle(child.schema);
|
|
5123
5276
|
const childTitle = isSet(schemaTitle) ? schemaTitle + " " + (index2 + 1) : child.getKey();
|
|
@@ -5129,7 +5282,7 @@ class EditorArrayNav extends EditorArray {
|
|
|
5129
5282
|
titleTemplate = compileTemplate(template, data) ?? childTitle;
|
|
5130
5283
|
}
|
|
5131
5284
|
const active = index2 === this.activeItemIndex;
|
|
5132
|
-
const id =
|
|
5285
|
+
const id = this.getIdFromPath(child.path);
|
|
5133
5286
|
const navWarning = getSchemaXOption(this.instance.schema, "navWarning") ?? true;
|
|
5134
5287
|
const navWarningMessage = getSchemaXOption(this.instance.schema, "navWarningMessage");
|
|
5135
5288
|
const { list, arrayActions } = this.theme.getTab({
|
|
@@ -5166,6 +5319,7 @@ class EditorArrayNav extends EditorArray {
|
|
|
5166
5319
|
});
|
|
5167
5320
|
this.refreshDisabledState();
|
|
5168
5321
|
this.refreshAddBtn();
|
|
5322
|
+
this.refreshDeleteAllBtn();
|
|
5169
5323
|
this.refreshJsonData();
|
|
5170
5324
|
}
|
|
5171
5325
|
}
|
|
@@ -6024,7 +6178,10 @@ const defaultTranslations = {
|
|
|
6024
6178
|
arrayMoveDown: "Move down",
|
|
6025
6179
|
arrayDrag: "Drag",
|
|
6026
6180
|
arrayAdd: "Add item",
|
|
6181
|
+
arrayAddAfter: "Add after",
|
|
6027
6182
|
arrayConfirmDelete: "Are you sure you want to delete this item?",
|
|
6183
|
+
arrayDeleteAll: "Delete all items",
|
|
6184
|
+
arrayConfirmDeleteAll: "Are you sure you want to delete all items?",
|
|
6028
6185
|
objectAddProperty: "Add property",
|
|
6029
6186
|
objectPropertyAdded: "field was added to the form",
|
|
6030
6187
|
objectPropertyRemoved: "field was removed from the form",
|
|
@@ -6070,6 +6227,8 @@ const translations = {
|
|
|
6070
6227
|
arrayDrag: "Drag",
|
|
6071
6228
|
arrayAdd: "Add item",
|
|
6072
6229
|
arrayConfirmDelete: "Are you sure you want to delete this item?",
|
|
6230
|
+
arrayDeleteAll: "Delete all items",
|
|
6231
|
+
arrayConfirmDeleteAll: "Are you sure you want to delete all items?",
|
|
6073
6232
|
objectAddProperty: "Add property",
|
|
6074
6233
|
objectPropertyAdded: "field was added to the form",
|
|
6075
6234
|
objectPropertyRemoved: "field was removed from the form",
|
|
@@ -6114,6 +6273,8 @@ const translations = {
|
|
|
6114
6273
|
arrayDrag: "Ziehen",
|
|
6115
6274
|
arrayAdd: "Element hinzufügen",
|
|
6116
6275
|
arrayConfirmDelete: "Möchten Sie dieses Element wirklich löschen?",
|
|
6276
|
+
arrayDeleteAll: "Alle Elemente löschen",
|
|
6277
|
+
arrayConfirmDeleteAll: "Möchten Sie wirklich alle Elemente löschen?",
|
|
6117
6278
|
objectAddProperty: "Eigenschaft hinzufügen",
|
|
6118
6279
|
objectPropertyAdded: "Feld wurde dem Formular hinzugefügt",
|
|
6119
6280
|
objectPropertyRemoved: "Feld wurde aus dem Formular entfernt",
|
|
@@ -6158,6 +6319,8 @@ const translations = {
|
|
|
6158
6319
|
arrayDrag: "Trascina",
|
|
6159
6320
|
arrayAdd: "Aggiungi elemento",
|
|
6160
6321
|
arrayConfirmDelete: "Sei sicuro di voler eliminare questo elemento?",
|
|
6322
|
+
arrayDeleteAll: "Elimina tutti gli elementi",
|
|
6323
|
+
arrayConfirmDeleteAll: "Sei sicuro di voler eliminare tutti gli elementi?",
|
|
6161
6324
|
objectAddProperty: "Aggiungi proprietà",
|
|
6162
6325
|
objectPropertyAdded: "Campo aggiunto al modulo",
|
|
6163
6326
|
objectPropertyRemoved: "Campo rimosso dal modulo",
|
|
@@ -6202,6 +6365,8 @@ const translations = {
|
|
|
6202
6365
|
arrayDrag: "Arrastrar",
|
|
6203
6366
|
arrayAdd: "Agregar elemento",
|
|
6204
6367
|
arrayConfirmDelete: "¿Estás seguro de que deseas eliminar este elemento?",
|
|
6368
|
+
arrayDeleteAll: "Eliminar todos los elementos",
|
|
6369
|
+
arrayConfirmDeleteAll: "¿Está seguro de que desea eliminar todos los elementos?",
|
|
6205
6370
|
objectAddProperty: "Agregar propiedad",
|
|
6206
6371
|
objectPropertyAdded: "campo fue añadido al formulario",
|
|
6207
6372
|
objectPropertyRemoved: "campo fue eliminado del formulario",
|
|
@@ -6279,6 +6444,11 @@ class Jedison extends EventEmitter {
|
|
|
6279
6444
|
arrayDeleteConfirm: true,
|
|
6280
6445
|
arrayMove: true,
|
|
6281
6446
|
arrayAdd: true,
|
|
6447
|
+
arrayAddAfter: false,
|
|
6448
|
+
arrayFooterAdd: false,
|
|
6449
|
+
arrayFooterButtonsPosition: "right",
|
|
6450
|
+
arrayDeleteAll: false,
|
|
6451
|
+
arrayFooterDeleteAll: false,
|
|
6282
6452
|
objectAdd: true,
|
|
6283
6453
|
arrayButtonsPosition: "left",
|
|
6284
6454
|
startCollapsed: false,
|
|
@@ -6312,7 +6482,8 @@ class Jedison extends EventEmitter {
|
|
|
6312
6482
|
enforceMaxItems: true,
|
|
6313
6483
|
enforceEnum: true,
|
|
6314
6484
|
subErrors: false,
|
|
6315
|
-
debug: false
|
|
6485
|
+
debug: false,
|
|
6486
|
+
audacity: true
|
|
6316
6487
|
}, options);
|
|
6317
6488
|
this.rootName = "#";
|
|
6318
6489
|
this.pathSeparator = "/";
|
|
@@ -6523,6 +6694,9 @@ class Jedison extends EventEmitter {
|
|
|
6523
6694
|
node.oneOf[index2] = this.refParser.expand(subschema);
|
|
6524
6695
|
});
|
|
6525
6696
|
}
|
|
6697
|
+
if (isObject(node.items) && this.refParser.hasRef(node.items)) {
|
|
6698
|
+
node.items = this.refParser.expand(node.items);
|
|
6699
|
+
}
|
|
6526
6700
|
});
|
|
6527
6701
|
}
|
|
6528
6702
|
if (this.isEditor) {
|
|
@@ -7097,6 +7271,16 @@ class Theme {
|
|
|
7097
7271
|
html.classList.add("jedi-editor-card-body");
|
|
7098
7272
|
return html;
|
|
7099
7273
|
}
|
|
7274
|
+
/**
|
|
7275
|
+
* A footer for array cards
|
|
7276
|
+
*/
|
|
7277
|
+
getArrayFooter() {
|
|
7278
|
+
const html = document.createElement("div");
|
|
7279
|
+
html.classList.add("jedi-array-footer");
|
|
7280
|
+
html.style.display = "flex";
|
|
7281
|
+
html.style.alignItems = "center";
|
|
7282
|
+
return html;
|
|
7283
|
+
}
|
|
7100
7284
|
/**
|
|
7101
7285
|
* Wrapper for editor actions buttons
|
|
7102
7286
|
*/
|
|
@@ -7392,6 +7576,28 @@ class Theme {
|
|
|
7392
7576
|
html.classList.add("jedi-array-add");
|
|
7393
7577
|
return html;
|
|
7394
7578
|
}
|
|
7579
|
+
/**
|
|
7580
|
+
* Array "delete all" button
|
|
7581
|
+
*/
|
|
7582
|
+
getArrayBtnDeleteAll(config) {
|
|
7583
|
+
const html = this.getButton({
|
|
7584
|
+
content: config.content,
|
|
7585
|
+
icon: "delete"
|
|
7586
|
+
});
|
|
7587
|
+
html.classList.add("jedi-array-delete-all");
|
|
7588
|
+
return html;
|
|
7589
|
+
}
|
|
7590
|
+
/**
|
|
7591
|
+
* Array "add after" item button
|
|
7592
|
+
*/
|
|
7593
|
+
getAddAfterItemBtn(config) {
|
|
7594
|
+
const addAfterItemBtn = this.getButton({
|
|
7595
|
+
content: config.content,
|
|
7596
|
+
icon: "add"
|
|
7597
|
+
});
|
|
7598
|
+
addAfterItemBtn.classList.add("jedi-array-add-after");
|
|
7599
|
+
return addAfterItemBtn;
|
|
7600
|
+
}
|
|
7395
7601
|
/**
|
|
7396
7602
|
* Array "delete" item button
|
|
7397
7603
|
*/
|
|
@@ -7702,6 +7908,13 @@ class Theme {
|
|
|
7702
7908
|
const addBtn = this.getArrayBtnAdd({
|
|
7703
7909
|
content: config.arrayAddContent
|
|
7704
7910
|
});
|
|
7911
|
+
const footerAddBtn = this.getArrayBtnAdd({
|
|
7912
|
+
content: config.arrayFooterAddContent
|
|
7913
|
+
});
|
|
7914
|
+
const deleteAllBtn = config.arrayDeleteAll === true ? this.getArrayBtnDeleteAll({ content: config.arrayDeleteAllContent }) : null;
|
|
7915
|
+
const footerDeleteAllBtn = config.arrayFooterDeleteAll === true ? this.getArrayBtnDeleteAll({ content: config.arrayFooterDeleteAllContent }) : null;
|
|
7916
|
+
const footerBtnGroup = this.getBtnGroup();
|
|
7917
|
+
const footer = this.getArrayFooter();
|
|
7705
7918
|
const fieldset = this.getFieldset();
|
|
7706
7919
|
const info = this.getInfo(config.info);
|
|
7707
7920
|
const { legend, legendText, infoContainer, right } = this.getLegend({
|
|
@@ -7754,6 +7967,9 @@ class Theme {
|
|
|
7754
7967
|
if (config.editJsonData) {
|
|
7755
7968
|
btnGroup.appendChild(jsonData.toggle);
|
|
7756
7969
|
}
|
|
7970
|
+
if (deleteAllBtn) {
|
|
7971
|
+
btnGroup.appendChild(deleteAllBtn);
|
|
7972
|
+
}
|
|
7757
7973
|
if (isSet(config.arrayAdd) && config.arrayAdd === true) {
|
|
7758
7974
|
btnGroup.appendChild(addBtn);
|
|
7759
7975
|
}
|
|
@@ -7761,6 +7977,20 @@ class Theme {
|
|
|
7761
7977
|
if (config.enableCollapseToggle) {
|
|
7762
7978
|
actions.appendChild(collapseToggle);
|
|
7763
7979
|
}
|
|
7980
|
+
const showFooter = (config.arrayFooterAdd === true || config.arrayFooterDeleteAll === true) && config.readOnly === false;
|
|
7981
|
+
if (showFooter) {
|
|
7982
|
+
if (footerDeleteAllBtn) {
|
|
7983
|
+
footerBtnGroup.appendChild(footerDeleteAllBtn);
|
|
7984
|
+
}
|
|
7985
|
+
if (config.arrayFooterAdd === true) {
|
|
7986
|
+
footerBtnGroup.appendChild(footerAddBtn);
|
|
7987
|
+
}
|
|
7988
|
+
if (config.arrayFooterButtonsPosition === "right") {
|
|
7989
|
+
footerBtnGroup.style.marginLeft = "auto";
|
|
7990
|
+
}
|
|
7991
|
+
footer.appendChild(footerBtnGroup);
|
|
7992
|
+
collapse.appendChild(footer);
|
|
7993
|
+
}
|
|
7764
7994
|
return {
|
|
7765
7995
|
container,
|
|
7766
7996
|
collapseToggle,
|
|
@@ -7774,7 +8004,10 @@ class Theme {
|
|
|
7774
8004
|
jsonData,
|
|
7775
8005
|
legend,
|
|
7776
8006
|
legendText,
|
|
7777
|
-
switcherSlot
|
|
8007
|
+
switcherSlot,
|
|
8008
|
+
footerAddBtn,
|
|
8009
|
+
deleteAllBtn,
|
|
8010
|
+
footerDeleteAllBtn
|
|
7778
8011
|
};
|
|
7779
8012
|
}
|
|
7780
8013
|
getArrayItem(config = {}) {
|
|
@@ -8565,6 +8798,11 @@ class ThemeBootstrap3 extends Theme {
|
|
|
8565
8798
|
html.style.paddingBottom = "0";
|
|
8566
8799
|
return html;
|
|
8567
8800
|
}
|
|
8801
|
+
getArrayFooter() {
|
|
8802
|
+
const footer = super.getArrayFooter();
|
|
8803
|
+
footer.classList.add("panel-footer");
|
|
8804
|
+
return footer;
|
|
8805
|
+
}
|
|
8568
8806
|
getBtnGroup() {
|
|
8569
8807
|
const html = super.getBtnGroup();
|
|
8570
8808
|
html.classList.add("btn-group");
|
|
@@ -8919,6 +9157,11 @@ class ThemeBootstrap4 extends Theme {
|
|
|
8919
9157
|
html.classList.add("pb-0");
|
|
8920
9158
|
return html;
|
|
8921
9159
|
}
|
|
9160
|
+
getArrayFooter() {
|
|
9161
|
+
const footer = super.getArrayFooter();
|
|
9162
|
+
footer.classList.add("card-footer");
|
|
9163
|
+
return footer;
|
|
9164
|
+
}
|
|
8922
9165
|
getBtnGroup() {
|
|
8923
9166
|
const html = super.getBtnGroup();
|
|
8924
9167
|
html.classList.add("btn-group");
|
|
@@ -9300,6 +9543,11 @@ class ThemeBootstrap5 extends Theme {
|
|
|
9300
9543
|
html.classList.add("pb-0");
|
|
9301
9544
|
return html;
|
|
9302
9545
|
}
|
|
9546
|
+
getArrayFooter() {
|
|
9547
|
+
const footer = super.getArrayFooter();
|
|
9548
|
+
footer.classList.add("card-footer");
|
|
9549
|
+
return footer;
|
|
9550
|
+
}
|
|
9303
9551
|
getControlSlot() {
|
|
9304
9552
|
const controlSlot = super.getControlSlot();
|
|
9305
9553
|
controlSlot.classList.add("mb-3");
|