@ghentcdh/json-forms-vue 0.6.7 → 0.6.9
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/form-with-actions.component.vue.d.ts +17 -2
- package/form.component.vue.d.ts +2 -0
- package/form.store.d.ts +1 -1
- package/index.js +436 -331
- package/index.mjs +442 -337
- package/package.json +4 -4
- package/renderes/array/ArrayRenderer.vue.d.ts +72 -184
- package/renderes/array/index.d.ts +75 -2
- package/renderes/controls/{autocomplete/AutocompleteControlRenderer.vue.d.ts → AutocompleteControlRenderer.vue.d.ts} +2 -2
- package/renderes/controls/BooleanControlRenderer.vue.d.ts +1 -1
- package/renderes/controls/IntegerControlRenderer.vue.d.ts +1 -1
- package/renderes/controls/MarkdownControlRenderer.vue.d.ts +1 -1
- package/renderes/controls/MultiSelectControlRender.vue.d.ts +74 -0
- package/renderes/controls/NumberControlRenderer.vue.d.ts +1 -1
- package/renderes/controls/SelectControlRender.vue.d.ts +74 -0
- package/renderes/controls/StringControlRenderer.vue.d.ts +1 -1
- package/renderes/controls/TextAreaControlRenderer.vue.d.ts +1 -1
- package/renderes/controls/index.d.ts +157 -7
- package/renderes/index.d.ts +302 -6
- package/renderes/layouts/CollapseLayout.vue.d.ts +73 -0
- package/renderes/layouts/HorizontalLayout.vue.d.ts +73 -0
- package/renderes/layouts/VerticalLayout.vue.d.ts +73 -0
- package/renderes/layouts/index.d.ts +75 -1
- package/renderes/tester.d.ts +2 -1
- package/utils/style.d.ts +3 -1
- package/utils/vanillaControl.d.ts +6 -4
- package/renderes/array/FixedArrayRenderer.vue.d.ts +0 -127
package/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { useApi } from "@ghentcdh/tools-vue";
|
|
2
|
-
import { NotificationService, Checkbox, InputNumber, Markdown, Input, Textarea,
|
|
3
|
-
import { uiTypeIs, rankWith, isNumberControl, isIntegerControl, isBooleanControl, createDefaultValue, composePaths
|
|
4
|
-
import { ref, computed, defineComponent, openBlock, createBlock, unref, mergeProps,
|
|
5
|
-
import { useJsonFormsControl, rendererProps, DispatchRenderer,
|
|
1
|
+
import { useApi, Debugger } from "@ghentcdh/tools-vue";
|
|
2
|
+
import { NotificationService, Autocomplete, Checkbox, InputNumber, Markdown, MultiSelect, SelectComponent, Input, Textarea, IconEnum, Btn, Collapse, BtnBadge, TextCell, Table, hasCustomEventListener, Card, ModalService, myStyles, Alert, Color, Modal } from "@ghentcdh/ui";
|
|
3
|
+
import { uiTypeIs, rankWith, isNumberControl, isIntegerControl, isBooleanControl, createDefaultValue, composePaths } from "@jsonforms/core";
|
|
4
|
+
import { ref, computed, defineComponent, openBlock, createBlock, unref, mergeProps, createElementBlock, createElementVNode, normalizeClass, Fragment, renderList, createVNode, createCommentVNode, withCtx, createTextVNode, watch, toDisplayString, useModel, provide, mergeModels, renderSlot } from "vue";
|
|
5
|
+
import { useJsonFormsControl, rendererProps, useJsonFormsArrayControl, DispatchRenderer, useJsonFormsLayout, JsonForms } from "@jsonforms/vue";
|
|
6
|
+
import axios from "axios";
|
|
6
7
|
import { useVanillaControl, useVanillaArrayControl, vanillaRenderers } from "@jsonforms/vue-vanilla";
|
|
8
|
+
import { pick, omit, isArray } from "lodash-es";
|
|
7
9
|
import { and, optionIs, or, schemaTypeIs } from "@jsonforms/core/src/testers/testers";
|
|
8
|
-
import { ControlType, RequestSchema, extractFilters, findColumnDef } from "@ghentcdh/json-forms-core";
|
|
10
|
+
import { ControlType, LayoutTypes, RequestSchema, extractFilters, findColumnDef } from "@ghentcdh/json-forms-core";
|
|
9
11
|
import { useRouter, useRoute } from "vue-router";
|
|
10
|
-
import { isArray } from "lodash-es";
|
|
11
12
|
import { computedAsync } from "@vueuse/core";
|
|
12
13
|
class FormStore {
|
|
13
14
|
constructor(schema) {
|
|
@@ -49,12 +50,15 @@ const useVanillaControlCustom = (input, adaptTarget = (v) => v.value) => {
|
|
|
49
50
|
const controlWrapper = computed(() => {
|
|
50
51
|
return {
|
|
51
52
|
...vanillaControl.controlWrapper.value,
|
|
53
|
+
...omit(vanillaControl.appliedOptions.value, "styles"),
|
|
54
|
+
...pick(vanillaControl.appliedOptions.value.styles, ["width"]),
|
|
52
55
|
isFocused: isFocused.value,
|
|
53
56
|
isTouched: isTouched.value
|
|
54
57
|
};
|
|
55
58
|
});
|
|
56
59
|
return {
|
|
57
60
|
...vanillaControl,
|
|
61
|
+
appliedOptions: vanillaControl.appliedOptions,
|
|
58
62
|
controlWrapper,
|
|
59
63
|
isFocused,
|
|
60
64
|
isTouched,
|
|
@@ -63,7 +67,49 @@ const useVanillaControlCustom = (input, adaptTarget = (v) => v.value) => {
|
|
|
63
67
|
// handleChange,
|
|
64
68
|
};
|
|
65
69
|
};
|
|
66
|
-
const _sfc_main$
|
|
70
|
+
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
71
|
+
__name: "AutocompleteControlRenderer",
|
|
72
|
+
props: { ...rendererProps() },
|
|
73
|
+
setup(__props) {
|
|
74
|
+
const props = __props;
|
|
75
|
+
const {
|
|
76
|
+
control,
|
|
77
|
+
handleChange: _handleChange,
|
|
78
|
+
appliedOptions,
|
|
79
|
+
onFocus,
|
|
80
|
+
onBlur,
|
|
81
|
+
controlWrapper
|
|
82
|
+
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
83
|
+
const bindProperties = computed(() => ({
|
|
84
|
+
...controlWrapper.value,
|
|
85
|
+
...appliedOptions.value
|
|
86
|
+
}));
|
|
87
|
+
const fetchOptions = computed(() => {
|
|
88
|
+
const options = appliedOptions.value;
|
|
89
|
+
if (!options.uri) return null;
|
|
90
|
+
return () => {
|
|
91
|
+
const fetch = options.skipAuth ? axios : useApi();
|
|
92
|
+
return fetch.get(options.uri).then((data) => data.data[options.dataField ?? "data"]);
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
const handleChange = (result) => {
|
|
96
|
+
const { path } = control.value;
|
|
97
|
+
_handleChange(path, result);
|
|
98
|
+
};
|
|
99
|
+
return (_ctx, _cache) => {
|
|
100
|
+
return openBlock(), createBlock(unref(Autocomplete), mergeProps(bindProperties.value, {
|
|
101
|
+
modelValue: unref(control).data,
|
|
102
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(control).data = $event),
|
|
103
|
+
enabled: unref(control).enabled,
|
|
104
|
+
"fetch-options": fetchOptions.value,
|
|
105
|
+
onChange: handleChange,
|
|
106
|
+
onFocus: unref(onFocus),
|
|
107
|
+
onBlur: unref(onBlur)
|
|
108
|
+
}), null, 16, ["modelValue", "enabled", "fetch-options", "onFocus", "onBlur"]);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
67
113
|
__name: "BooleanControlRenderer",
|
|
68
114
|
props: { ...rendererProps() },
|
|
69
115
|
setup(__props) {
|
|
@@ -84,7 +130,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
84
130
|
};
|
|
85
131
|
}
|
|
86
132
|
});
|
|
87
|
-
const _sfc_main$
|
|
133
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
88
134
|
__name: "IntegerControlRenderer",
|
|
89
135
|
props: { ...rendererProps() },
|
|
90
136
|
setup(__props) {
|
|
@@ -108,28 +154,64 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
108
154
|
};
|
|
109
155
|
}
|
|
110
156
|
});
|
|
111
|
-
const _sfc_main$
|
|
157
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
112
158
|
__name: "MarkdownControlRenderer",
|
|
113
159
|
props: { ...rendererProps() },
|
|
114
160
|
setup(__props) {
|
|
115
161
|
const props = __props;
|
|
116
|
-
const {
|
|
117
|
-
|
|
118
|
-
|
|
162
|
+
const {
|
|
163
|
+
control,
|
|
164
|
+
handleChange,
|
|
165
|
+
appliedOptions,
|
|
166
|
+
onFocus,
|
|
167
|
+
onBlur,
|
|
168
|
+
controlWrapper
|
|
169
|
+
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
170
|
+
const changeValue = (value) => {
|
|
171
|
+
handleChange(control.value.path, value);
|
|
172
|
+
};
|
|
119
173
|
return (_ctx, _cache) => {
|
|
120
174
|
return openBlock(), createBlock(unref(Markdown), mergeProps(unref(controlWrapper), {
|
|
121
175
|
modelValue: unref(control).data,
|
|
122
176
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(control).data = $event),
|
|
123
177
|
enabled: unref(control).enabled,
|
|
124
178
|
config: unref(appliedOptions),
|
|
125
|
-
onChange:
|
|
179
|
+
onChange: changeValue,
|
|
126
180
|
onFocus: unref(onFocus),
|
|
127
181
|
onBlur: unref(onBlur)
|
|
128
|
-
}), null, 16, ["modelValue", "enabled", "config", "
|
|
182
|
+
}), null, 16, ["modelValue", "enabled", "config", "onFocus", "onBlur"]);
|
|
129
183
|
};
|
|
130
184
|
}
|
|
131
185
|
});
|
|
132
|
-
const _sfc_main$
|
|
186
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
187
|
+
__name: "MultiSelectControlRender",
|
|
188
|
+
props: { ...rendererProps() },
|
|
189
|
+
setup(__props) {
|
|
190
|
+
const props = __props;
|
|
191
|
+
const {
|
|
192
|
+
control,
|
|
193
|
+
handleChange: _handleChange,
|
|
194
|
+
onFocus,
|
|
195
|
+
onBlur,
|
|
196
|
+
controlWrapper
|
|
197
|
+
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
198
|
+
const handleChange = (result) => {
|
|
199
|
+
const { path } = control.value;
|
|
200
|
+
_handleChange(path, result);
|
|
201
|
+
};
|
|
202
|
+
return (_ctx, _cache) => {
|
|
203
|
+
return openBlock(), createBlock(unref(MultiSelect), mergeProps(unref(controlWrapper), {
|
|
204
|
+
modelValue: unref(control).data,
|
|
205
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(control).data = $event),
|
|
206
|
+
enabled: unref(control).enabled,
|
|
207
|
+
onChange: handleChange,
|
|
208
|
+
onFocus: unref(onFocus),
|
|
209
|
+
onBlur: unref(onBlur)
|
|
210
|
+
}), null, 16, ["modelValue", "enabled", "onFocus", "onBlur"]);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
133
215
|
__name: "NumberControlRenderer",
|
|
134
216
|
props: { ...rendererProps() },
|
|
135
217
|
setup(__props) {
|
|
@@ -153,26 +235,65 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
153
235
|
};
|
|
154
236
|
}
|
|
155
237
|
});
|
|
156
|
-
const _sfc_main$
|
|
238
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
239
|
+
__name: "SelectControlRender",
|
|
240
|
+
props: { ...rendererProps() },
|
|
241
|
+
setup(__props) {
|
|
242
|
+
const props = __props;
|
|
243
|
+
const {
|
|
244
|
+
control,
|
|
245
|
+
handleChange: _handleChange,
|
|
246
|
+
appliedOptions,
|
|
247
|
+
onFocus,
|
|
248
|
+
onBlur,
|
|
249
|
+
controlWrapper
|
|
250
|
+
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
251
|
+
const handleChange = (result) => {
|
|
252
|
+
const { path } = control.value;
|
|
253
|
+
_handleChange(path, result);
|
|
254
|
+
};
|
|
255
|
+
return (_ctx, _cache) => {
|
|
256
|
+
return openBlock(), createBlock(unref(SelectComponent), mergeProps(unref(controlWrapper), {
|
|
257
|
+
modelValue: unref(control).data,
|
|
258
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(control).data = $event),
|
|
259
|
+
enabled: unref(control).enabled,
|
|
260
|
+
options: unref(appliedOptions)?.options,
|
|
261
|
+
onChange: handleChange,
|
|
262
|
+
onFocus: unref(onFocus),
|
|
263
|
+
onBlur: unref(onBlur)
|
|
264
|
+
}), null, 16, ["modelValue", "enabled", "options", "onFocus", "onBlur"]);
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
157
269
|
__name: "StringControlRenderer",
|
|
158
270
|
props: { ...rendererProps() },
|
|
159
271
|
setup(__props) {
|
|
160
272
|
const props = __props;
|
|
161
|
-
const {
|
|
273
|
+
const {
|
|
274
|
+
control,
|
|
275
|
+
onChange,
|
|
276
|
+
appliedOptions,
|
|
277
|
+
onFocus,
|
|
278
|
+
onBlur,
|
|
279
|
+
controlWrapper,
|
|
280
|
+
styles
|
|
281
|
+
} = useVanillaControlCustom(useJsonFormsControl(props));
|
|
162
282
|
return (_ctx, _cache) => {
|
|
163
283
|
return openBlock(), createBlock(unref(Input), mergeProps(unref(controlWrapper), {
|
|
164
284
|
modelValue: unref(control).data,
|
|
165
285
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(control).data = $event),
|
|
166
286
|
enabled: unref(control).enabled,
|
|
167
287
|
config: unref(appliedOptions),
|
|
288
|
+
styles: unref(styles),
|
|
168
289
|
onChange: unref(onChange),
|
|
169
290
|
onFocus: unref(onFocus),
|
|
170
291
|
onBlur: unref(onBlur)
|
|
171
|
-
}), null, 16, ["modelValue", "enabled", "config", "onChange", "onFocus", "onBlur"]);
|
|
292
|
+
}), null, 16, ["modelValue", "enabled", "config", "styles", "onChange", "onFocus", "onBlur"]);
|
|
172
293
|
};
|
|
173
294
|
}
|
|
174
295
|
});
|
|
175
|
-
const _sfc_main$
|
|
296
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
176
297
|
__name: "TextAreaControlRenderer",
|
|
177
298
|
props: { ...rendererProps() },
|
|
178
299
|
setup(__props) {
|
|
@@ -207,10 +328,6 @@ const isMarkdownControl = and(
|
|
|
207
328
|
uiTypeIs("Control"),
|
|
208
329
|
optionIs("format", ControlType.markdown)
|
|
209
330
|
);
|
|
210
|
-
const isFixedArray = and(
|
|
211
|
-
schemaTypeIs("array"),
|
|
212
|
-
optionIs("format", ControlType.fixedArray)
|
|
213
|
-
);
|
|
214
331
|
const isArrayRenderer = and(
|
|
215
332
|
schemaTypeIs("array")
|
|
216
333
|
// optionIs('format', ControlType.array),
|
|
@@ -221,52 +338,41 @@ const isCustomControl = (customType) => {
|
|
|
221
338
|
optionIs("type", customType)
|
|
222
339
|
);
|
|
223
340
|
};
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const field = computed(() => appliedOptions.value.field);
|
|
233
|
-
return (_ctx, _cache) => {
|
|
234
|
-
return openBlock(), createBlock(unref(Autocomplete), mergeProps(unref(controlWrapper), {
|
|
235
|
-
modelValue: unref(control).data,
|
|
236
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(control).data = $event),
|
|
237
|
-
enabled: unref(control).enabled,
|
|
238
|
-
config: unref(appliedOptions),
|
|
239
|
-
"label-key": field.value?.label,
|
|
240
|
-
"value-key": field.value?.id,
|
|
241
|
-
onChange: unref(onChange),
|
|
242
|
-
onFocus: unref(onFocus),
|
|
243
|
-
onBlur: unref(onBlur)
|
|
244
|
-
}), null, 16, ["modelValue", "enabled", "config", "label-key", "value-key", "onChange", "onFocus", "onBlur"]);
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
});
|
|
341
|
+
const isMultiselectControl = and(
|
|
342
|
+
uiTypeIs("Control"),
|
|
343
|
+
optionIs("format", ControlType.mutliSelect)
|
|
344
|
+
);
|
|
345
|
+
const isSelectControl = and(
|
|
346
|
+
uiTypeIs("Control"),
|
|
347
|
+
optionIs("format", ControlType.select)
|
|
348
|
+
);
|
|
248
349
|
const controlRenderers = [
|
|
249
350
|
// First custom renderers on format
|
|
250
351
|
{
|
|
251
352
|
tester: rankWith(10, isMarkdownControl),
|
|
252
|
-
renderer: _sfc_main$
|
|
353
|
+
renderer: _sfc_main$f
|
|
253
354
|
},
|
|
254
355
|
{
|
|
255
356
|
tester: rankWith(10, isAutoCompleteControl),
|
|
256
|
-
renderer: _sfc_main$
|
|
357
|
+
renderer: _sfc_main$i
|
|
257
358
|
},
|
|
258
359
|
{
|
|
259
360
|
tester: rankWith(10, isTextAreaControl),
|
|
260
|
-
renderer: _sfc_main$
|
|
361
|
+
renderer: _sfc_main$a
|
|
261
362
|
},
|
|
262
363
|
// Renderers based on type if no format is provided
|
|
263
|
-
{ tester: rankWith(10, isStringFormat), renderer: _sfc_main$
|
|
264
|
-
{ tester: rankWith(10,
|
|
364
|
+
{ tester: rankWith(10, isStringFormat), renderer: _sfc_main$b },
|
|
365
|
+
{ tester: rankWith(10, isSelectControl), renderer: _sfc_main$c },
|
|
366
|
+
{
|
|
367
|
+
tester: rankWith(10, isMultiselectControl),
|
|
368
|
+
renderer: _sfc_main$e
|
|
369
|
+
},
|
|
370
|
+
{ tester: rankWith(10, isNumberControl), renderer: _sfc_main$d },
|
|
265
371
|
{
|
|
266
372
|
tester: rankWith(10, isIntegerControl),
|
|
267
|
-
renderer: _sfc_main$
|
|
373
|
+
renderer: _sfc_main$g
|
|
268
374
|
},
|
|
269
|
-
{ tester: rankWith(10, isBooleanControl), renderer: _sfc_main$
|
|
375
|
+
{ tester: rankWith(10, isBooleanControl), renderer: _sfc_main$h }
|
|
270
376
|
];
|
|
271
377
|
const actionMap = {
|
|
272
378
|
edit: (router, action) => ({
|
|
@@ -301,262 +407,233 @@ class FormState {
|
|
|
301
407
|
const useFormState = (form) => {
|
|
302
408
|
return FormState.getInstance();
|
|
303
409
|
};
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
},
|
|
313
|
-
setup(
|
|
410
|
+
const _hoisted_1$8 = ["title"];
|
|
411
|
+
const _hoisted_2$2 = { key: 0 };
|
|
412
|
+
const _hoisted_3$1 = {
|
|
413
|
+
key: 1,
|
|
414
|
+
class: "list-row"
|
|
415
|
+
};
|
|
416
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
417
|
+
__name: "ArrayRenderer",
|
|
418
|
+
props: { ...rendererProps() },
|
|
419
|
+
setup(__props) {
|
|
420
|
+
const props = __props;
|
|
314
421
|
const vanillaArrayControl = useVanillaArrayControl(
|
|
315
422
|
useJsonFormsArrayControl(props)
|
|
316
423
|
);
|
|
317
|
-
const control = vanillaArrayControl
|
|
318
|
-
if (!control.data || control.data.length < 1) {
|
|
424
|
+
const { styles, childUiSchema, control, appliedOptions } = vanillaArrayControl;
|
|
425
|
+
if (!control.value.data || control.value.data.length < 1) {
|
|
319
426
|
vanillaArrayControl.addItem(
|
|
320
|
-
control.path,
|
|
321
|
-
createDefaultValue(control.schema, control.rootSchema)
|
|
427
|
+
control.value.path,
|
|
428
|
+
createDefaultValue(control.value.schema, control.value.rootSchema)
|
|
322
429
|
)();
|
|
323
430
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const actions = this.uischema.options?.actions ?? [];
|
|
335
|
-
return mapArrayActions(useRouter(), actions);
|
|
336
|
-
},
|
|
337
|
-
showDelete() {
|
|
338
|
-
return this.control.data?.length > 1;
|
|
339
|
-
},
|
|
340
|
-
translations() {
|
|
341
|
-
const jsonforms = inject("jsonforms");
|
|
342
|
-
return getArrayTranslations(
|
|
343
|
-
jsonforms?.i18n?.translate ?? defaultJsonFormsI18nState.translate,
|
|
344
|
-
arrayDefaultTranslations,
|
|
345
|
-
this.control.i18nKeyPrefix,
|
|
346
|
-
this.control.label
|
|
347
|
-
);
|
|
348
|
-
},
|
|
349
|
-
labelKey() {
|
|
350
|
-
const key = this.uischema?.options?.labelKey;
|
|
431
|
+
const noData = computed(
|
|
432
|
+
() => !control.value.data || control.value.data.length === 0
|
|
433
|
+
);
|
|
434
|
+
const actions = computed(() => {
|
|
435
|
+
const actions2 = props.uischema.options?.actions ?? [];
|
|
436
|
+
return mapArrayActions(useRouter(), actions2);
|
|
437
|
+
});
|
|
438
|
+
const showDelete = computed(() => control.value.data?.length > 1);
|
|
439
|
+
computed(() => {
|
|
440
|
+
const key = control.value.uischema?.options?.labelKey;
|
|
351
441
|
if (!key) return null;
|
|
352
442
|
return key;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
deleteButtonClick(index) {
|
|
359
|
-
this.removeItems(this.control.path, [index])();
|
|
360
|
-
},
|
|
361
|
-
dispatchEvent: (event, data) => {
|
|
443
|
+
});
|
|
444
|
+
const deleteButtonClick = (index) => {
|
|
445
|
+
vanillaArrayControl.removeItems(control.value.path, [index])();
|
|
446
|
+
};
|
|
447
|
+
const dispatchEvent = (event, data) => {
|
|
362
448
|
const form_id = "";
|
|
363
449
|
useFormState().dispatchEvent(form_id, event, data);
|
|
364
|
-
}
|
|
365
|
-
addButtonClick() {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
createDefaultValue(
|
|
450
|
+
};
|
|
451
|
+
const addButtonClick = () => {
|
|
452
|
+
vanillaArrayControl.addItem(
|
|
453
|
+
control.value.path,
|
|
454
|
+
createDefaultValue(control.value.schema, control.value.rootSchema)
|
|
369
455
|
)();
|
|
370
|
-
}
|
|
456
|
+
};
|
|
457
|
+
const showActions = computed(() => {
|
|
458
|
+
return !appliedOptions.value.hideActions;
|
|
459
|
+
});
|
|
460
|
+
return (_ctx, _cache) => {
|
|
461
|
+
return openBlock(), createElementBlock("div", {
|
|
462
|
+
title: unref(control).label
|
|
463
|
+
}, [
|
|
464
|
+
createElementVNode("div", {
|
|
465
|
+
class: normalizeClass([
|
|
466
|
+
"flex gap-2",
|
|
467
|
+
unref(appliedOptions)?.layout === "row" ? "flex-row items-center" : "flex-col"
|
|
468
|
+
])
|
|
469
|
+
}, [
|
|
470
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(control).data, (element, index) => {
|
|
471
|
+
return openBlock(), createElementBlock("div", {
|
|
472
|
+
key: `${unref(control).path}-${index}`,
|
|
473
|
+
class: "flex-1"
|
|
474
|
+
}, [
|
|
475
|
+
createElementVNode("div", {
|
|
476
|
+
class: normalizeClass([
|
|
477
|
+
"flex gap-2",
|
|
478
|
+
unref(appliedOptions)?.layout === "row" ? "flex-col" : "flex-row items-center"
|
|
479
|
+
])
|
|
480
|
+
}, [
|
|
481
|
+
createElementVNode("div", null, [
|
|
482
|
+
createVNode(unref(DispatchRenderer), {
|
|
483
|
+
schema: unref(control).schema,
|
|
484
|
+
uischema: unref(childUiSchema),
|
|
485
|
+
path: unref(composePaths)(unref(control).path, `${index}`),
|
|
486
|
+
enabled: unref(control).enabled,
|
|
487
|
+
renderers: unref(control).renderers,
|
|
488
|
+
cells: unref(control).cells
|
|
489
|
+
}, null, 8, ["schema", "uischema", "path", "enabled", "renderers", "cells"])
|
|
490
|
+
]),
|
|
491
|
+
showActions.value ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
|
|
492
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(actions.value, (action) => {
|
|
493
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
494
|
+
action.show(element) ? (openBlock(), createBlock(unref(Btn), {
|
|
495
|
+
key: action.label,
|
|
496
|
+
icon: action.icon,
|
|
497
|
+
outline: true,
|
|
498
|
+
onClick: ($event) => dispatchEvent(action.label, element)
|
|
499
|
+
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
500
|
+
], 64);
|
|
501
|
+
}), 256)),
|
|
502
|
+
showDelete.value ? (openBlock(), createBlock(unref(Btn), {
|
|
503
|
+
key: 0,
|
|
504
|
+
icon: unref(IconEnum).Delete,
|
|
505
|
+
outline: true,
|
|
506
|
+
onClick: ($event) => deleteButtonClick(index)
|
|
507
|
+
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
508
|
+
])) : createCommentVNode("", true)
|
|
509
|
+
], 2)
|
|
510
|
+
]);
|
|
511
|
+
}), 128)),
|
|
512
|
+
noData.value ? (openBlock(), createElementBlock("div", {
|
|
513
|
+
key: 0,
|
|
514
|
+
class: normalizeClass(["list-row", unref(styles).arrayList.noData])
|
|
515
|
+
}, " No data ", 2)) : createCommentVNode("", true),
|
|
516
|
+
showActions.value ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
|
|
517
|
+
createVNode(unref(Btn), {
|
|
518
|
+
icon: unref(IconEnum).Plus,
|
|
519
|
+
outline: true,
|
|
520
|
+
onClick: addButtonClick
|
|
521
|
+
}, {
|
|
522
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
523
|
+
createTextVNode(" Add ", -1)
|
|
524
|
+
])]),
|
|
525
|
+
_: 1
|
|
526
|
+
}, 8, ["icon"])
|
|
527
|
+
])) : createCommentVNode("", true)
|
|
528
|
+
], 2)
|
|
529
|
+
], 8, _hoisted_1$8);
|
|
530
|
+
};
|
|
371
531
|
}
|
|
372
532
|
});
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const _export_sfc = (sfc, props) => {
|
|
378
|
-
const target = sfc.__vccOpts || sfc;
|
|
379
|
-
for (const [key, val] of props) {
|
|
380
|
-
target[key] = val;
|
|
533
|
+
const arrayRenderers = [
|
|
534
|
+
{
|
|
535
|
+
tester: rankWith(12, isArrayRenderer),
|
|
536
|
+
renderer: _sfc_main$9
|
|
381
537
|
}
|
|
382
|
-
|
|
383
|
-
};
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
class: normalizeClass(_ctx.styles.arrayList.legend)
|
|
412
|
-
}, toDisplayString(element[_ctx.labelKey]?.toLowerCase()), 3)) : createCommentVNode("", true),
|
|
413
|
-
createElementVNode("div", _hoisted_2$2, [
|
|
414
|
-
createVNode(_component_dispatch_renderer, {
|
|
415
|
-
schema: _ctx.control.schema,
|
|
416
|
-
uischema: _ctx.childUiSchema,
|
|
417
|
-
path: _ctx.composePaths(_ctx.control.path, `${index}`),
|
|
418
|
-
enabled: _ctx.control.enabled,
|
|
419
|
-
renderers: _ctx.control.renderers,
|
|
420
|
-
cells: _ctx.control.cells
|
|
421
|
-
}, null, 8, ["schema", "uischema", "path", "enabled", "renderers", "cells"]),
|
|
422
|
-
createElementVNode("div", _hoisted_3$2, [
|
|
423
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.actions, (action) => {
|
|
424
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
425
|
-
action.show(element) ? (openBlock(), createBlock(_component_Btn, {
|
|
426
|
-
key: action.label,
|
|
427
|
-
icon: action.icon,
|
|
428
|
-
outline: true,
|
|
429
|
-
onClick: ($event) => _ctx.dispatchEvent(action.label, element)
|
|
430
|
-
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
431
|
-
], 64);
|
|
432
|
-
}), 256)),
|
|
433
|
-
_ctx.showDelete ? (openBlock(), createBlock(_component_Btn, {
|
|
434
|
-
key: 0,
|
|
435
|
-
icon: _ctx.IconEnum.Delete,
|
|
436
|
-
outline: true,
|
|
437
|
-
onClick: ($event) => _ctx.deleteButtonClick(index)
|
|
438
|
-
}, null, 8, ["icon", "onClick"])) : createCommentVNode("", true)
|
|
439
|
-
])
|
|
440
|
-
])
|
|
538
|
+
];
|
|
539
|
+
const _hoisted_1$7 = { class: "flex flex-col gap-4" };
|
|
540
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
541
|
+
__name: "CollapseLayout",
|
|
542
|
+
props: { ...rendererProps() },
|
|
543
|
+
setup(__props) {
|
|
544
|
+
const props = __props;
|
|
545
|
+
const jsonLayout = useJsonFormsLayout(props);
|
|
546
|
+
const { layout, renderers, cells } = jsonLayout;
|
|
547
|
+
const title = computed(() => {
|
|
548
|
+
const { titleKey, title: title2 } = layout?.value.uischema?.options ?? {};
|
|
549
|
+
if (title2) return title2;
|
|
550
|
+
if (titleKey) return layout?.value.data[titleKey];
|
|
551
|
+
return layout?.value.uischema?.options?.titleKey;
|
|
552
|
+
});
|
|
553
|
+
return (_ctx, _cache) => {
|
|
554
|
+
return openBlock(), createBlock(unref(Collapse), { title: title.value }, {
|
|
555
|
+
default: withCtx(() => [
|
|
556
|
+
createElementVNode("div", _hoisted_1$7, [
|
|
557
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
|
|
558
|
+
return openBlock(), createBlock(unref(DispatchRenderer), {
|
|
559
|
+
key: index,
|
|
560
|
+
schema: unref(layout).schema,
|
|
561
|
+
uischema: element,
|
|
562
|
+
path: unref(layout).path,
|
|
563
|
+
renderers: unref(renderers),
|
|
564
|
+
cells: unref(cells)
|
|
565
|
+
}, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
|
|
566
|
+
}), 128))
|
|
441
567
|
])
|
|
442
|
-
])
|
|
443
|
-
}), 128))
|
|
444
|
-
]),
|
|
445
|
-
createElementVNode("div", _hoisted_4$1, [
|
|
446
|
-
createVNode(_component_Btn, {
|
|
447
|
-
icon: _ctx.IconEnum.Plus,
|
|
448
|
-
outline: true,
|
|
449
|
-
onClick: _ctx.addButtonClick
|
|
450
|
-
}, {
|
|
451
|
-
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
452
|
-
createTextVNode(" Add ", -1)
|
|
453
|
-
])]),
|
|
568
|
+
]),
|
|
454
569
|
_: 1
|
|
455
|
-
}, 8, ["
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
570
|
+
}, 8, ["title"]);
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
const _hoisted_1$6 = { class: "flex flex-row gap-4 items-center" };
|
|
575
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
576
|
+
__name: "HorizontalLayout",
|
|
577
|
+
props: { ...rendererProps() },
|
|
578
|
+
setup(__props) {
|
|
579
|
+
const props = __props;
|
|
580
|
+
const { layout, renderers, cells } = useJsonFormsLayout(props);
|
|
581
|
+
return (_ctx, _cache) => {
|
|
582
|
+
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
583
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
|
|
584
|
+
return openBlock(), createBlock(unref(DispatchRenderer), {
|
|
585
|
+
key: index,
|
|
586
|
+
schema: unref(layout).schema,
|
|
587
|
+
uischema: element,
|
|
588
|
+
path: unref(layout).path,
|
|
589
|
+
renderers: unref(renderers),
|
|
590
|
+
cells: unref(cells)
|
|
591
|
+
}, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
|
|
592
|
+
}), 128))
|
|
593
|
+
]);
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
const _hoisted_1$5 = { class: "flex flex-col gap-4" };
|
|
598
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
599
|
+
__name: "VerticalLayout",
|
|
600
|
+
props: { ...rendererProps() },
|
|
601
|
+
setup(__props) {
|
|
602
|
+
const props = __props;
|
|
603
|
+
const { layout, renderers, cells } = useJsonFormsLayout(props);
|
|
604
|
+
return (_ctx, _cache) => {
|
|
605
|
+
return openBlock(), createElementBlock("div", _hoisted_1$5, [
|
|
606
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(layout).uischema.elements, (element, index) => {
|
|
607
|
+
return openBlock(), createBlock(unref(DispatchRenderer), {
|
|
608
|
+
key: index,
|
|
609
|
+
schema: unref(layout).schema,
|
|
610
|
+
uischema: element,
|
|
611
|
+
path: unref(layout).path,
|
|
612
|
+
renderers: unref(renderers),
|
|
613
|
+
cells: unref(cells)
|
|
614
|
+
}, null, 8, ["schema", "uischema", "path", "renderers", "cells"]);
|
|
615
|
+
}), 128))
|
|
616
|
+
]);
|
|
617
|
+
};
|
|
497
618
|
}
|
|
498
619
|
});
|
|
499
|
-
const entry = {
|
|
500
|
-
renderer: controlRenderer,
|
|
501
|
-
tester: rankWith(2, isFixedArray)
|
|
502
|
-
};
|
|
503
|
-
const _hoisted_1$5 = { class: "fieldset" };
|
|
504
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
505
|
-
const _component_dispatch_renderer = resolveComponent("dispatch-renderer");
|
|
506
|
-
return _ctx.control.visible ? (openBlock(), createElementBlock("fieldset", {
|
|
507
|
-
key: 0,
|
|
508
|
-
class: normalizeClass(_ctx.styles.arrayList.root)
|
|
509
|
-
}, [
|
|
510
|
-
!_ctx.labelKey ? (openBlock(), createElementBlock("legend", {
|
|
511
|
-
key: 0,
|
|
512
|
-
class: normalizeClass(_ctx.styles.arrayList.legend)
|
|
513
|
-
}, [
|
|
514
|
-
createElementVNode("label", {
|
|
515
|
-
class: normalizeClass(_ctx.styles.arrayList.label)
|
|
516
|
-
}, toDisplayString(_ctx.control.label), 3)
|
|
517
|
-
], 2)) : createCommentVNode("", true),
|
|
518
|
-
createElementVNode("div", {
|
|
519
|
-
class: normalizeClass(_ctx.styles.fixedArrayList.root)
|
|
520
|
-
}, [
|
|
521
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.control.data, (element, index) => {
|
|
522
|
-
return openBlock(), createElementBlock("div", {
|
|
523
|
-
key: `${_ctx.control.path}-${index}`,
|
|
524
|
-
class: normalizeClass(_ctx.styles.fixedArrayList.item)
|
|
525
|
-
}, [
|
|
526
|
-
createElementVNode("fieldset", _hoisted_1$5, [
|
|
527
|
-
_ctx.labelKey ? (openBlock(), createElementBlock("legend", {
|
|
528
|
-
key: 0,
|
|
529
|
-
class: normalizeClass(_ctx.styles.arrayList.legend)
|
|
530
|
-
}, toDisplayString(element[_ctx.labelKey]?.toLowerCase()), 3)) : createCommentVNode("", true),
|
|
531
|
-
createVNode(_component_dispatch_renderer, {
|
|
532
|
-
schema: _ctx.control.schema,
|
|
533
|
-
uischema: _ctx.childUiSchema,
|
|
534
|
-
path: _ctx.composePaths(_ctx.control.path, `${index}`),
|
|
535
|
-
enabled: _ctx.control.enabled,
|
|
536
|
-
renderers: _ctx.control.renderers,
|
|
537
|
-
cells: _ctx.control.cells
|
|
538
|
-
}, null, 8, ["schema", "uischema", "path", "enabled", "renderers", "cells"])
|
|
539
|
-
])
|
|
540
|
-
], 2);
|
|
541
|
-
}), 128))
|
|
542
|
-
], 2),
|
|
543
|
-
_ctx.noData ? (openBlock(), createElementBlock("div", {
|
|
544
|
-
key: 1,
|
|
545
|
-
class: normalizeClass(_ctx.styles.arrayList.noData)
|
|
546
|
-
}, toDisplayString(_ctx.translations.noDataMessage), 3)) : createCommentVNode("", true)
|
|
547
|
-
], 2)) : createCommentVNode("", true);
|
|
548
|
-
}
|
|
549
|
-
const FixedArrayRenderer = /* @__PURE__ */ _export_sfc(controlRenderer, [["render", _sfc_render]]);
|
|
550
|
-
const arrayRenderers = [
|
|
551
|
-
entry,
|
|
552
|
-
entry$1
|
|
553
|
-
];
|
|
554
620
|
const layoutRenderers = [
|
|
555
|
-
|
|
621
|
+
{
|
|
622
|
+
tester: rankWith(10, uiTypeIs(LayoutTypes.VerticalLayout)),
|
|
623
|
+
renderer: _sfc_main$6
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
tester: rankWith(10, uiTypeIs(LayoutTypes.HorizontalLayout)),
|
|
627
|
+
renderer: _sfc_main$7
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
tester: rankWith(10, uiTypeIs(LayoutTypes.CollapseLayout)),
|
|
631
|
+
renderer: _sfc_main$8
|
|
632
|
+
}
|
|
556
633
|
];
|
|
557
634
|
const _hoisted_1$4 = { class: "" };
|
|
558
635
|
const _hoisted_2$1 = { class: "flex gap-2 items-center mb-2" };
|
|
559
|
-
const _hoisted_3
|
|
636
|
+
const _hoisted_3 = { class: "flex gap-2" };
|
|
560
637
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
561
638
|
__name: "table-filter",
|
|
562
639
|
props: {
|
|
@@ -600,7 +677,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
600
677
|
_: 1
|
|
601
678
|
})) : createCommentVNode("", true)
|
|
602
679
|
]),
|
|
603
|
-
createElementVNode("div", _hoisted_3
|
|
680
|
+
createElementVNode("div", _hoisted_3, [
|
|
604
681
|
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.filters, (filter) => {
|
|
605
682
|
return openBlock(), createBlock(unref(BtnBadge), {
|
|
606
683
|
key: filter.key,
|
|
@@ -930,12 +1007,12 @@ const customRenderers = [
|
|
|
930
1007
|
const customRenderesName = customRenderers.map((c) => {
|
|
931
1008
|
return c.renderer.name;
|
|
932
1009
|
});
|
|
933
|
-
|
|
1010
|
+
vanillaRenderers.filter(
|
|
934
1011
|
(v) => !customRenderesName.includes(v.renderer.name)
|
|
935
1012
|
);
|
|
936
1013
|
const tailwindRenderers = [
|
|
937
|
-
...
|
|
938
|
-
...
|
|
1014
|
+
...vanillaRenderers,
|
|
1015
|
+
...customRenderers
|
|
939
1016
|
];
|
|
940
1017
|
const _hoisted_1$1 = ["id"];
|
|
941
1018
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
@@ -951,7 +1028,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
951
1028
|
"modelValue": {},
|
|
952
1029
|
"modelModifiers": {}
|
|
953
1030
|
}),
|
|
954
|
-
emits: /* @__PURE__ */ mergeModels(["valid", "change", "submit"], ["update:modelValue"]),
|
|
1031
|
+
emits: /* @__PURE__ */ mergeModels(["valid", "change", "submit", "errors"], ["update:modelValue"]),
|
|
955
1032
|
setup(__props, { emit: __emit }) {
|
|
956
1033
|
const properties = __props;
|
|
957
1034
|
const _JSON_FORM_ID = `json-form-${Date.now()}`;
|
|
@@ -964,6 +1041,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
964
1041
|
valid.value = event.errors.length === 0;
|
|
965
1042
|
emits("valid", valid.value);
|
|
966
1043
|
emits("change", event.data);
|
|
1044
|
+
emits("errors", event.errors);
|
|
1045
|
+
Debugger.debug(event.errors);
|
|
967
1046
|
};
|
|
968
1047
|
const onSubmit = (event) => {
|
|
969
1048
|
event.preventDefault();
|
|
@@ -1004,10 +1083,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1004
1083
|
};
|
|
1005
1084
|
}
|
|
1006
1085
|
});
|
|
1007
|
-
const _hoisted_1 = { class: "card
|
|
1008
|
-
const _hoisted_2 = { class: "
|
|
1009
|
-
const _hoisted_3 = { class: "card-title" };
|
|
1010
|
-
const _hoisted_4 = { class: "card-actions flex justify-end" };
|
|
1086
|
+
const _hoisted_1 = { class: "card-actions flex justify-between" };
|
|
1087
|
+
const _hoisted_2 = { class: "flex justify-end gap-2" };
|
|
1011
1088
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1012
1089
|
__name: "form-with-actions.component",
|
|
1013
1090
|
props: /* @__PURE__ */ mergeModels({
|
|
@@ -1024,25 +1101,35 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1024
1101
|
const properties = __props;
|
|
1025
1102
|
const valid = ref(false);
|
|
1026
1103
|
const formData = useModel(__props, "modelValue");
|
|
1104
|
+
const submitted = ref(false);
|
|
1027
1105
|
const store = new FormStore(properties.formSchema);
|
|
1028
1106
|
const emits = __emit;
|
|
1029
1107
|
const save = () => {
|
|
1108
|
+
submitted.value = true;
|
|
1109
|
+
if (!valid.value) {
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1030
1112
|
store.save(formData.value.id, formData.value).then(() => {
|
|
1031
1113
|
emits("success");
|
|
1032
1114
|
});
|
|
1033
1115
|
};
|
|
1034
1116
|
const clear = () => {
|
|
1035
1117
|
formData.value = { id: null };
|
|
1118
|
+
submitted.value = false;
|
|
1036
1119
|
};
|
|
1037
1120
|
const onValid = (v) => {
|
|
1121
|
+
submitted.value = false;
|
|
1038
1122
|
valid.value = v;
|
|
1039
1123
|
};
|
|
1124
|
+
const title = computed(() => {
|
|
1125
|
+
if (!properties.updateTitle) return properties.createTitle;
|
|
1126
|
+
return formData.value?.id ? properties.updateTitle : properties.createTitle;
|
|
1127
|
+
});
|
|
1040
1128
|
return (_ctx, _cache) => {
|
|
1041
|
-
return openBlock(),
|
|
1042
|
-
|
|
1043
|
-
createElementVNode("h1", _hoisted_3, toDisplayString(formData.value?.id ? __props.updateTitle : __props.createTitle), 1),
|
|
1129
|
+
return openBlock(), createBlock(unref(Collapse), { title: title.value }, {
|
|
1130
|
+
default: withCtx(() => [
|
|
1044
1131
|
createVNode(_sfc_main$2, {
|
|
1045
|
-
id: `form_${
|
|
1132
|
+
id: `form_${__props.id}`,
|
|
1046
1133
|
modelValue: formData.value,
|
|
1047
1134
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formData.value = $event),
|
|
1048
1135
|
schema: __props.formSchema.form.schema,
|
|
@@ -1050,29 +1137,41 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1050
1137
|
onValid: _cache[1] || (_cache[1] = ($event) => onValid($event)),
|
|
1051
1138
|
onSubmit: save
|
|
1052
1139
|
}, null, 8, ["id", "modelValue", "schema", "uischema"]),
|
|
1053
|
-
createElementVNode("div",
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1140
|
+
createElementVNode("div", _hoisted_1, [
|
|
1141
|
+
createElementVNode("div", null, [
|
|
1142
|
+
!valid.value && submitted.value ? (openBlock(), createBlock(unref(Alert), {
|
|
1143
|
+
key: 0,
|
|
1144
|
+
message: "The form is not valid",
|
|
1145
|
+
type: "error"
|
|
1146
|
+
})) : createCommentVNode("", true)
|
|
1147
|
+
]),
|
|
1148
|
+
createElementVNode("div", _hoisted_2, [
|
|
1149
|
+
renderSlot(_ctx.$slots, "actions"),
|
|
1150
|
+
!formData.value.id ? (openBlock(), createBlock(unref(Btn), {
|
|
1151
|
+
key: 0,
|
|
1152
|
+
outline: true,
|
|
1153
|
+
onClick: clear
|
|
1154
|
+
}, {
|
|
1155
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [
|
|
1156
|
+
createTextVNode(" Clear ", -1)
|
|
1157
|
+
])]),
|
|
1158
|
+
_: 1
|
|
1159
|
+
})) : createCommentVNode("", true),
|
|
1160
|
+
createVNode(unref(Btn), {
|
|
1161
|
+
color: unref(Color).primary,
|
|
1162
|
+
disabled: submitted.value,
|
|
1163
|
+
onClick: save
|
|
1164
|
+
}, {
|
|
1165
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [
|
|
1166
|
+
createTextVNode(" Save ", -1)
|
|
1167
|
+
])]),
|
|
1168
|
+
_: 1
|
|
1169
|
+
}, 8, ["color", "disabled"])
|
|
1170
|
+
])
|
|
1073
1171
|
])
|
|
1074
|
-
])
|
|
1075
|
-
|
|
1172
|
+
]),
|
|
1173
|
+
_: 3
|
|
1174
|
+
}, 8, ["title"]);
|
|
1076
1175
|
};
|
|
1077
1176
|
}
|
|
1078
1177
|
});
|
|
@@ -1197,7 +1296,7 @@ const createRepository = (formSchemaModel, httpRequest, options = {}) => {
|
|
|
1197
1296
|
const create = (object, options2) => {
|
|
1198
1297
|
return httpRequest.post(getDataUri(), object, options2).then((response) => {
|
|
1199
1298
|
handleSuccess(`Created ${notificationEntity}`);
|
|
1200
|
-
return response;
|
|
1299
|
+
return response.data;
|
|
1201
1300
|
}).catch((response) => {
|
|
1202
1301
|
handleError(response, `Failed to create ${notificationEntity}`);
|
|
1203
1302
|
});
|
|
@@ -1205,13 +1304,17 @@ const createRepository = (formSchemaModel, httpRequest, options = {}) => {
|
|
|
1205
1304
|
const patch = (id, object, options2) => {
|
|
1206
1305
|
return httpRequest.patch(getDataUri(id), object, options2).then((response) => {
|
|
1207
1306
|
handleSuccess(`Saved ${notificationEntity}`);
|
|
1208
|
-
return response;
|
|
1307
|
+
return response.data;
|
|
1209
1308
|
}).catch((response) => {
|
|
1210
1309
|
handleError(response, `Failed to save ${notificationEntity}`);
|
|
1211
1310
|
});
|
|
1212
1311
|
};
|
|
1213
1312
|
const get = (id, options2) => {
|
|
1214
|
-
return httpRequest.get(getDataUri(id), options2)
|
|
1313
|
+
return httpRequest.get(getDataUri(id), options2).then((response) => {
|
|
1314
|
+
return response.data;
|
|
1315
|
+
}).catch((response) => {
|
|
1316
|
+
handleError(response, `Failed to load data`);
|
|
1317
|
+
});
|
|
1215
1318
|
};
|
|
1216
1319
|
const _delete = (id, options2) => {
|
|
1217
1320
|
return httpRequest.delete(getDataUri(id), options2).then((response) => {
|
|
@@ -1226,7 +1329,7 @@ const createRepository = (formSchemaModel, httpRequest, options = {}) => {
|
|
|
1226
1329
|
objects.map((object) => httpRequest.post(getDataUri(), object, options2))
|
|
1227
1330
|
).then((response) => {
|
|
1228
1331
|
handleSuccess(`Created ${notificationEntity}`);
|
|
1229
|
-
return response;
|
|
1332
|
+
return response.data;
|
|
1230
1333
|
}).catch((response) => {
|
|
1231
1334
|
handleError(response, `Failed to save ${notificationEntity}`);
|
|
1232
1335
|
});
|
|
@@ -1234,19 +1337,20 @@ const createRepository = (formSchemaModel, httpRequest, options = {}) => {
|
|
|
1234
1337
|
return { create, patch, createMulti, delete: _delete, get };
|
|
1235
1338
|
};
|
|
1236
1339
|
export {
|
|
1237
|
-
ArrayRenderer,
|
|
1238
|
-
_sfc_main$
|
|
1239
|
-
_sfc_main$
|
|
1240
|
-
FixedArrayRenderer,
|
|
1340
|
+
_sfc_main$9 as ArrayRenderer,
|
|
1341
|
+
_sfc_main$i as AutocompleteControlRenderer,
|
|
1342
|
+
_sfc_main$h as BooleanControlRenderer,
|
|
1241
1343
|
_sfc_main$2 as FormComponent,
|
|
1242
1344
|
_sfc_main as FormModal,
|
|
1243
1345
|
FormModalService,
|
|
1244
1346
|
FormStore,
|
|
1245
1347
|
_sfc_main$1 as FormWithActions,
|
|
1246
1348
|
_sfc_main$3 as FormWithTableComponent,
|
|
1247
|
-
_sfc_main$
|
|
1248
|
-
_sfc_main$
|
|
1249
|
-
_sfc_main$
|
|
1349
|
+
_sfc_main$g as IntegerControlRenderer,
|
|
1350
|
+
_sfc_main$e as MultiSelectControlRender,
|
|
1351
|
+
_sfc_main$d as NumberControlRenderer,
|
|
1352
|
+
_sfc_main$c as SelectControlRender,
|
|
1353
|
+
_sfc_main$b as StringControlRenderer,
|
|
1250
1354
|
_sfc_main$4 as TableComponent,
|
|
1251
1355
|
arrayRenderers,
|
|
1252
1356
|
controlRenderers,
|
|
@@ -1254,11 +1358,12 @@ export {
|
|
|
1254
1358
|
isArrayRenderer,
|
|
1255
1359
|
isAutoCompleteControl,
|
|
1256
1360
|
isCustomControl,
|
|
1257
|
-
isFixedArray,
|
|
1258
1361
|
isMarkdownControl,
|
|
1362
|
+
isMultiselectControl,
|
|
1363
|
+
isSelectControl,
|
|
1259
1364
|
isStringFormat,
|
|
1260
1365
|
isTextAreaControl,
|
|
1261
1366
|
layoutRenderers,
|
|
1262
|
-
_sfc_main$
|
|
1367
|
+
_sfc_main$f as markdownControlRenderer,
|
|
1263
1368
|
useFormState
|
|
1264
1369
|
};
|