@ditojs/admin 3.2.1 → 3.2.2
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/README.md +1 -1
- package/dist/dito-admin.es.js +43 -22
- package/dist/dito-admin.umd.js +4 -4
- package/package.json +2 -2
- package/src/DitoAdmin.js +1 -0
- package/src/components/DitoDialog.vue +13 -7
- package/src/components/DitoForm.vue +21 -10
- package/src/components/DitoView.vue +12 -6
- package/src/mixins/DitoMixin.js +23 -10
- package/src/mixins/OptionsMixin.js +6 -6
- package/src/mixins/RouteMixin.js +1 -1
- package/src/mixins/SourceMixin.js +3 -3
- package/src/mixins/TypeMixin.js +3 -8
- package/src/mixins/ValueMixin.js +1 -1
- package/src/types/DitoTypeComputed.vue +1 -1
- package/src/utils/{FormModel.js → DataModel.js} +4 -4
- package/src/utils/schema/data.js +8 -8
- package/src/utils/schema/lookup.js +1 -1
- package/types/index.d.ts +7 -4
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ For detailed explanation on how things work, checkout the [guide](http://vuejs-t
|
|
|
28
28
|
|
|
29
29
|
## Introduction
|
|
30
30
|
|
|
31
|
-
An admin of a model consists of two parts, the view and the form. The view represents the model class and has access to the collection routes. The view typically shows a list of model instances with different functionalities like sorting and scopes. The form represents model instances and has access to members of the model. On the
|
|
31
|
+
An admin of a model consists of two parts, the view and the form. The view represents the model class and has access to the collection routes. The view typically shows a list of model instances with different functionalities like sorting and scopes. The form represents model instances and has access to members of the model. On the data model instances can be edited. The view and the form have in common that they both consist of components.
|
|
32
32
|
|
|
33
33
|
## Creating A View
|
|
34
34
|
|
package/dist/dito-admin.es.js
CHANGED
|
@@ -1308,9 +1308,6 @@ var ai = {
|
|
|
1308
1308
|
name() {
|
|
1309
1309
|
return this.schema.name;
|
|
1310
1310
|
},
|
|
1311
|
-
formModel() {
|
|
1312
|
-
return (this.dialogComponent ?? this.routeComponent).formModel;
|
|
1313
|
-
},
|
|
1314
1311
|
type() {
|
|
1315
1312
|
return this.schema.type;
|
|
1316
1313
|
},
|
|
@@ -1398,7 +1395,7 @@ var ai = {
|
|
|
1398
1395
|
},
|
|
1399
1396
|
methods: {
|
|
1400
1397
|
warnAboutUncomputedValue() {
|
|
1401
|
-
this.schema.compute && !this.
|
|
1398
|
+
this.schema.compute && !this.dataModel.hasComputedValueEntry(this.componentPath) && console.warn(`The value of the component at '${this.componentPath}' isn't computed, as its data isn't part of a data model.`);
|
|
1402
1399
|
},
|
|
1403
1400
|
_register(e) {
|
|
1404
1401
|
this.$emit("update:component", e ? this : null), this._registerWithSchemaComponent(e, this.componentPath);
|
|
@@ -1617,6 +1614,7 @@ var Di = {
|
|
|
1617
1614
|
"$sourceComponent",
|
|
1618
1615
|
"$resourceComponent",
|
|
1619
1616
|
"$dialogComponent",
|
|
1617
|
+
"$dataModel",
|
|
1620
1618
|
"$panelComponent",
|
|
1621
1619
|
"$tabComponent"
|
|
1622
1620
|
],
|
|
@@ -1635,6 +1633,9 @@ var Di = {
|
|
|
1635
1633
|
};
|
|
1636
1634
|
},
|
|
1637
1635
|
computed: {
|
|
1636
|
+
dataModel() {
|
|
1637
|
+
return this.$dataModel();
|
|
1638
|
+
},
|
|
1638
1639
|
providesData() {
|
|
1639
1640
|
return !1;
|
|
1640
1641
|
},
|
|
@@ -1926,9 +1927,12 @@ var Di = {
|
|
|
1926
1927
|
let r = this.hasListeners(e), i = n?.hasListeners(e);
|
|
1927
1928
|
if (r || i) {
|
|
1928
1929
|
let a = (n) => n.emit(e, t = G.get(this, t)), o = (e) => i && e !== !1 ? a(n).then(() => e) : e, s = () => r ? a(this).then(o) : o(void 0);
|
|
1929
|
-
return ["load", "change"].includes(e) ? this
|
|
1930
|
+
return ["load", "change"].includes(e) ? this.waitForDataModel().then(s) : s();
|
|
1930
1931
|
}
|
|
1931
1932
|
},
|
|
1933
|
+
async waitForDataModel() {
|
|
1934
|
+
await this.$nextTick(), await this.dataModel?.waitForPendingLoads();
|
|
1935
|
+
},
|
|
1932
1936
|
emitSchemaEvent(e, t) {
|
|
1933
1937
|
return this.schemaComponent.emitEvent(e, t);
|
|
1934
1938
|
}
|
|
@@ -4148,7 +4152,7 @@ function bo(e) {
|
|
|
4148
4152
|
return F(e) || We(e);
|
|
4149
4153
|
}
|
|
4150
4154
|
//#endregion
|
|
4151
|
-
//#region src/utils/
|
|
4155
|
+
//#region src/utils/DataModel.js
|
|
4152
4156
|
var xo = class {
|
|
4153
4157
|
computedValueRecords = /* @__PURE__ */ new Map();
|
|
4154
4158
|
optionsRecords = /* @__PURE__ */ new Map();
|
|
@@ -4411,7 +4415,8 @@ var Ao = /*#__PURE__*/ X(Y.component("DitoView", {
|
|
|
4411
4415
|
provide() {
|
|
4412
4416
|
return {
|
|
4413
4417
|
$sourceComponent: () => this.mainComponent?.sourceComponent || null,
|
|
4414
|
-
$resourceComponent: () => this.mainComponent?.resourceComponent || null
|
|
4418
|
+
$resourceComponent: () => this.mainComponent?.resourceComponent || null,
|
|
4419
|
+
$dataModel: () => this.ownDataModel
|
|
4415
4420
|
};
|
|
4416
4421
|
},
|
|
4417
4422
|
data() {
|
|
@@ -4421,6 +4426,9 @@ var Ao = /*#__PURE__*/ X(Y.component("DitoView", {
|
|
|
4421
4426
|
};
|
|
4422
4427
|
},
|
|
4423
4428
|
computed: {
|
|
4429
|
+
dataModel() {
|
|
4430
|
+
return this.ownDataModel;
|
|
4431
|
+
},
|
|
4424
4432
|
schema() {
|
|
4425
4433
|
return this.meta.schema ?? {};
|
|
4426
4434
|
},
|
|
@@ -4458,7 +4466,7 @@ var Ao = /*#__PURE__*/ X(Y.component("DitoView", {
|
|
|
4458
4466
|
}
|
|
4459
4467
|
} },
|
|
4460
4468
|
created() {
|
|
4461
|
-
this.
|
|
4469
|
+
this.ownDataModel = new xo({
|
|
4462
4470
|
component: this,
|
|
4463
4471
|
getSchema: () => this.viewSchema,
|
|
4464
4472
|
getData: () => this.data
|
|
@@ -4468,7 +4476,7 @@ var Ao = /*#__PURE__*/ X(Y.component("DitoView", {
|
|
|
4468
4476
|
this.shouldRenderSchema(this.viewSchema) || this.$router.replace({ path: "/" });
|
|
4469
4477
|
},
|
|
4470
4478
|
beforeUnmount() {
|
|
4471
|
-
this.
|
|
4479
|
+
this.ownDataModel.stop();
|
|
4472
4480
|
},
|
|
4473
4481
|
methods: {
|
|
4474
4482
|
setData(e) {
|
|
@@ -4572,7 +4580,10 @@ var Fo = /*#__PURE__*/ X(Y.component("DitoDialog", {
|
|
|
4572
4580
|
components: { UseFocusTrap: Mo },
|
|
4573
4581
|
emits: ["remove"],
|
|
4574
4582
|
provide() {
|
|
4575
|
-
return {
|
|
4583
|
+
return {
|
|
4584
|
+
$dialogComponent: () => this,
|
|
4585
|
+
$dataModel: () => this.ownDataModel
|
|
4586
|
+
};
|
|
4576
4587
|
},
|
|
4577
4588
|
props: {
|
|
4578
4589
|
components: {
|
|
@@ -4605,6 +4616,9 @@ var Fo = /*#__PURE__*/ X(Y.component("DitoDialog", {
|
|
|
4605
4616
|
return { dialogData: e };
|
|
4606
4617
|
},
|
|
4607
4618
|
computed: {
|
|
4619
|
+
dataModel() {
|
|
4620
|
+
return this.ownDataModel;
|
|
4621
|
+
},
|
|
4608
4622
|
dialogComponent() {
|
|
4609
4623
|
return this;
|
|
4610
4624
|
},
|
|
@@ -4635,7 +4649,7 @@ var Fo = /*#__PURE__*/ X(Y.component("DitoDialog", {
|
|
|
4635
4649
|
}
|
|
4636
4650
|
},
|
|
4637
4651
|
created() {
|
|
4638
|
-
this.
|
|
4652
|
+
this.ownDataModel = new xo({
|
|
4639
4653
|
component: this,
|
|
4640
4654
|
getSchema: () => this.schema,
|
|
4641
4655
|
getData: () => this.dialogData
|
|
@@ -4647,7 +4661,7 @@ var Fo = /*#__PURE__*/ X(Y.component("DitoDialog", {
|
|
|
4647
4661
|
} });
|
|
4648
4662
|
},
|
|
4649
4663
|
beforeUnmount() {
|
|
4650
|
-
this.
|
|
4664
|
+
this.ownDataModel.stop();
|
|
4651
4665
|
},
|
|
4652
4666
|
methods: {
|
|
4653
4667
|
remove() {
|
|
@@ -4663,7 +4677,7 @@ var Fo = /*#__PURE__*/ X(Y.component("DitoDialog", {
|
|
|
4663
4677
|
e.target instanceof HTMLInputElement && this.submit();
|
|
4664
4678
|
},
|
|
4665
4679
|
async submit() {
|
|
4666
|
-
await this.waitForPendingLoadsOf(this.
|
|
4680
|
+
await this.waitForPendingLoadsOf(this.dataModel), this.resolve(this.dialogData);
|
|
4667
4681
|
},
|
|
4668
4682
|
cancel() {
|
|
4669
4683
|
this.resolve(void 0);
|
|
@@ -7937,6 +7951,9 @@ function Cc(e, t, n, r, i, a) {
|
|
|
7937
7951
|
}
|
|
7938
7952
|
var wc = /*#__PURE__*/ X(Y.component("DitoForm", {
|
|
7939
7953
|
mixins: [vo, yc],
|
|
7954
|
+
provide() {
|
|
7955
|
+
return { $dataModel: () => this.ownDataModel };
|
|
7956
|
+
},
|
|
7940
7957
|
data() {
|
|
7941
7958
|
return {
|
|
7942
7959
|
createdData: null,
|
|
@@ -7944,6 +7961,9 @@ var wc = /*#__PURE__*/ X(Y.component("DitoForm", {
|
|
|
7944
7961
|
};
|
|
7945
7962
|
},
|
|
7946
7963
|
computed: {
|
|
7964
|
+
dataModel() {
|
|
7965
|
+
return this.ownDataModel;
|
|
7966
|
+
},
|
|
7947
7967
|
isForm() {
|
|
7948
7968
|
return !0;
|
|
7949
7969
|
},
|
|
@@ -7983,7 +8003,7 @@ var wc = /*#__PURE__*/ X(Y.component("DitoForm", {
|
|
|
7983
8003
|
return this.param === "create";
|
|
7984
8004
|
},
|
|
7985
8005
|
isDirty() {
|
|
7986
|
-
return !this.isMutating && this.
|
|
8006
|
+
return !this.isMutating && this.dataModel.isDirty;
|
|
7987
8007
|
},
|
|
7988
8008
|
isMutating() {
|
|
7989
8009
|
return !!this.sourceSchema.mutate;
|
|
@@ -8070,7 +8090,7 @@ var wc = /*#__PURE__*/ X(Y.component("DitoForm", {
|
|
|
8070
8090
|
}
|
|
8071
8091
|
},
|
|
8072
8092
|
created() {
|
|
8073
|
-
this.
|
|
8093
|
+
this.ownDataModel = new xo({
|
|
8074
8094
|
component: this,
|
|
8075
8095
|
getSchema: () => this.schema,
|
|
8076
8096
|
getData: () => this.data,
|
|
@@ -8078,7 +8098,7 @@ var wc = /*#__PURE__*/ X(Y.component("DitoForm", {
|
|
|
8078
8098
|
});
|
|
8079
8099
|
},
|
|
8080
8100
|
beforeUnmount() {
|
|
8081
|
-
this.
|
|
8101
|
+
this.ownDataModel.stop();
|
|
8082
8102
|
},
|
|
8083
8103
|
methods: {
|
|
8084
8104
|
emitSchemaEvent(e, t) {
|
|
@@ -8111,7 +8131,7 @@ var wc = /*#__PURE__*/ X(Y.component("DitoForm", {
|
|
|
8111
8131
|
return this.isTransient ? (this.setSourceData(e), this.sourceItem) : (this.createdData = null, this.loadedData = e, this.data);
|
|
8112
8132
|
},
|
|
8113
8133
|
applyCleanChanges(e) {
|
|
8114
|
-
return this.
|
|
8134
|
+
return this.dataModel.applyCleanChanges(e);
|
|
8115
8135
|
},
|
|
8116
8136
|
async cancel() {
|
|
8117
8137
|
return this.close();
|
|
@@ -8123,7 +8143,7 @@ var wc = /*#__PURE__*/ X(Y.component("DitoForm", {
|
|
|
8123
8143
|
return this.isCreating ? e ? "create" : "created" : e ? "submit" : "submitted";
|
|
8124
8144
|
},
|
|
8125
8145
|
async submit(e, { validate: t = !0, closeForm: n = !1 } = {}) {
|
|
8126
|
-
if (await this.waitForPendingLoadsOf(this.
|
|
8146
|
+
if (await this.waitForPendingLoadsOf(this.dataModel), t && !this.validateAll()) return !1;
|
|
8127
8147
|
let r = (e) => this.verbs[this.getSubmitVerb(e)], { method: i } = this, a = this.getResource({ method: i }), o = J(e.schema.resource, { parent: a });
|
|
8128
8148
|
a = o || a, i = a?.method || i;
|
|
8129
8149
|
let s = this.getPayloadData(e, i), c;
|
|
@@ -8169,7 +8189,7 @@ var wc = /*#__PURE__*/ X(Y.component("DitoForm", {
|
|
|
8169
8189
|
});
|
|
8170
8190
|
}
|
|
8171
8191
|
}), c) {
|
|
8172
|
-
if (this.resetValidation(), this.
|
|
8192
|
+
if (this.resetValidation(), this.dataModel.takeProcessedDataSnapshot().catch(console.error), n || e.closeForm) this.close();
|
|
8173
8193
|
else if (this.isCreating) {
|
|
8174
8194
|
let e = this.getItemId(this.schema, this.data);
|
|
8175
8195
|
this.$router.replace({
|
|
@@ -9222,7 +9242,7 @@ var jl = /*#__PURE__*/ X(Q.register("checkbox", { nativeField: !0 }), [["render"
|
|
|
9222
9242
|
return this.getOptionForValue(this.selectedValue);
|
|
9223
9243
|
},
|
|
9224
9244
|
optionsResolver() {
|
|
9225
|
-
return this.
|
|
9245
|
+
return this.dataModel.getOptionsResolver({
|
|
9226
9246
|
schema: this.schema,
|
|
9227
9247
|
data: this.data,
|
|
9228
9248
|
name: this.name,
|
|
@@ -9319,7 +9339,7 @@ var jl = /*#__PURE__*/ X(Q.register("checkbox", { nativeField: !0 }), [["render"
|
|
|
9319
9339
|
},
|
|
9320
9340
|
replaceValueWithSelectedValue() {
|
|
9321
9341
|
let { selectedValue: e } = this;
|
|
9322
|
-
this.
|
|
9342
|
+
this.dataModel.applyCleanChanges(() => {
|
|
9323
9343
|
this.selectedValue = e;
|
|
9324
9344
|
}).catch(console.error);
|
|
9325
9345
|
},
|
|
@@ -10064,7 +10084,7 @@ var iu = {
|
|
|
10064
10084
|
this.setLoadedValue(Ir(this.sourceSchema, e, this.paginationRange));
|
|
10065
10085
|
},
|
|
10066
10086
|
setLoadedValue(e) {
|
|
10067
|
-
this.
|
|
10087
|
+
this.dataModel.applyCleanChanges(() => {
|
|
10068
10088
|
this.value = e;
|
|
10069
10089
|
}).catch(console.error);
|
|
10070
10090
|
},
|
|
@@ -13541,6 +13561,7 @@ var mp = [
|
|
|
13541
13561
|
$sourceComponent: () => null,
|
|
13542
13562
|
$resourceComponent: () => null,
|
|
13543
13563
|
$dialogComponent: () => null,
|
|
13564
|
+
$dataModel: () => null,
|
|
13544
13565
|
$panelComponent: () => null,
|
|
13545
13566
|
$tabComponent: () => null
|
|
13546
13567
|
},
|