@ramathibodi/nuxt-commons 4.0.20 → 4.0.21
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/module.json +1 -1
- package/dist/runtime/components/document/TemplateBuilder.d.vue.ts +7 -1
- package/dist/runtime/components/document/TemplateBuilder.vue +7 -461
- package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +7 -1
- package/dist/runtime/components/document/TemplateBuilderLiveView.d.vue.ts +185 -0
- package/dist/runtime/components/document/TemplateBuilderLiveView.vue +579 -0
- package/dist/runtime/components/document/TemplateBuilderLiveView.vue.d.ts +185 -0
- package/dist/runtime/components/document/TemplateItemForm.d.vue.ts +11 -0
- package/dist/runtime/components/document/TemplateItemForm.vue +437 -0
- package/dist/runtime/components/document/TemplateItemForm.vue.d.ts +11 -0
- package/dist/runtime/components/document/TemplatePalette.d.vue.ts +54 -0
- package/dist/runtime/components/document/TemplatePalette.vue +362 -0
- package/dist/runtime/components/document/TemplatePalette.vue.d.ts +54 -0
- package/dist/runtime/components/form/Pad.vue +1 -1
- package/dist/runtime/composables/document/template.d.ts +72 -1
- package/dist/runtime/composables/document/template.js +47 -8
- package/dist/runtime/composables/document/templateBuilderModel.d.ts +51 -0
- package/dist/runtime/composables/document/templateBuilderModel.js +62 -0
- package/dist/runtime/composables/document/templateFormHidden.js +3 -1
- package/dist/runtime/composables/document/templatePalette.d.ts +21 -0
- package/dist/runtime/composables/document/templatePalette.js +10 -0
- package/dist/runtime/composables/document/validateTemplate.js +61 -2
- package/package.json +1 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
export type DocumentTemplateImportMode = 'ask' | 'append' | 'replace';
|
|
2
|
+
interface Props {
|
|
3
|
+
title?: string;
|
|
4
|
+
customCode?: boolean;
|
|
5
|
+
disableAdvanceMode?: boolean;
|
|
6
|
+
templateScript?: string;
|
|
7
|
+
toolbarColor?: string;
|
|
8
|
+
editorWidth?: number | string;
|
|
9
|
+
outline?: boolean;
|
|
10
|
+
initialData?: Record<string, any>;
|
|
11
|
+
importable?: boolean;
|
|
12
|
+
exportable?: boolean;
|
|
13
|
+
importMode?: DocumentTemplateImportMode;
|
|
14
|
+
stringFields?: string[];
|
|
15
|
+
sortable?: boolean;
|
|
16
|
+
palette?: boolean;
|
|
17
|
+
paletteTypes?: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Public props accepted by DocumentTemplateBuilderLiveView.
|
|
21
|
+
*
|
|
22
|
+
* Two surface modes are available from the live view's own bar (above the preview):
|
|
23
|
+
* - **Design** (default) — the preview is a click target: clicking any rendered
|
|
24
|
+
* field opens that item in the side panel. Inputs are not interactive.
|
|
25
|
+
* - **Preview** — the preview is a live, fillable form so you can try the
|
|
26
|
+
* validations; the data typed is shown in the "Preview data" panel.
|
|
27
|
+
*
|
|
28
|
+
* Items with no visual (`FormHidden`, `Separator`) are reachable from the
|
|
29
|
+
* **Outline** list, which also offers reordering for every item.
|
|
30
|
+
*
|
|
31
|
+
* In Design mode every rendered field is also a drag handle: drop it on the
|
|
32
|
+
* left / top half of another field to insert before it, on the right / bottom
|
|
33
|
+
* half to insert after (`sortable`, on by default).
|
|
34
|
+
*
|
|
35
|
+
* The **Palette** column (`palette`, on by default) shows one thumbnail card
|
|
36
|
+
* per input type. Drag a card into the live view to insert a new item of that
|
|
37
|
+
* type where it lands (the same before / after halves apply; anywhere else in
|
|
38
|
+
* the preview appends), or click a card to add one after the selected item.
|
|
39
|
+
* The new item opens in the editor so its label / variable can be filled in.
|
|
40
|
+
*/
|
|
41
|
+
type __VLS_Props = Props;
|
|
42
|
+
declare function openCreate(): void;
|
|
43
|
+
declare function openEdit(index: number): void;
|
|
44
|
+
declare function closeEditor(): void;
|
|
45
|
+
declare function deleteSelected(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Move the item at `from` so it lands at index `to` (its index *after* the
|
|
48
|
+
* move). The editor selection follows the moved item; a selected neighbour
|
|
49
|
+
* that got shifted by the move keeps pointing at the same item.
|
|
50
|
+
*/
|
|
51
|
+
declare function moveItemTo(from: number, to: number): boolean;
|
|
52
|
+
declare function moveSelected(delta: number): void;
|
|
53
|
+
declare function duplicateSelected(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Insert a fresh item of `inputType` at `index` (clamped; defaults to the
|
|
56
|
+
* end) and open it in the editor. The item is seeded from `initialData` plus
|
|
57
|
+
* a unique `variableName` and a default `inputLabel` (when the type needs
|
|
58
|
+
* them) so it renders in the preview right away — an item with no variable
|
|
59
|
+
* name would compile to `v-model="data."` and blank the whole preview.
|
|
60
|
+
* Returns the index it landed at.
|
|
61
|
+
*/
|
|
62
|
+
declare function insertInputType(inputType: string, index?: number): number;
|
|
63
|
+
/**
|
|
64
|
+
* Rows parsed by `<ImportCSV>` (one template item per row). `id` columns left
|
|
65
|
+
* behind by a FormTable export are dropped so appended items never collide;
|
|
66
|
+
* `printConfig` object maps are exploded into editor rows like a v-model load.
|
|
67
|
+
*/
|
|
68
|
+
declare function importItems(rows: Record<string, any>[]): Promise<void>;
|
|
69
|
+
type __VLS_ModelProps = {
|
|
70
|
+
modelValue?: string | Record<string, any>[];
|
|
71
|
+
};
|
|
72
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
73
|
+
declare var __VLS_20: {}, __VLS_28: {
|
|
74
|
+
items: Record<string, any>[];
|
|
75
|
+
operation: {
|
|
76
|
+
openCreate: typeof openCreate;
|
|
77
|
+
openEdit: typeof openEdit;
|
|
78
|
+
closeEditor: typeof closeEditor;
|
|
79
|
+
deleteSelected: typeof deleteSelected;
|
|
80
|
+
moveSelected: typeof moveSelected;
|
|
81
|
+
moveItemTo: typeof moveItemTo;
|
|
82
|
+
duplicateSelected: typeof duplicateSelected;
|
|
83
|
+
insertInputType: typeof insertInputType;
|
|
84
|
+
importItems: typeof importItems;
|
|
85
|
+
convertToAdvanceMode: () => Promise<void>;
|
|
86
|
+
};
|
|
87
|
+
}, __VLS_197: {
|
|
88
|
+
operation: {
|
|
89
|
+
openCreate: typeof openCreate;
|
|
90
|
+
openEdit: typeof openEdit;
|
|
91
|
+
closeEditor: typeof closeEditor;
|
|
92
|
+
deleteSelected: typeof deleteSelected;
|
|
93
|
+
moveSelected: typeof moveSelected;
|
|
94
|
+
moveItemTo: typeof moveItemTo;
|
|
95
|
+
duplicateSelected: typeof duplicateSelected;
|
|
96
|
+
insertInputType: typeof insertInputType;
|
|
97
|
+
importItems: typeof importItems;
|
|
98
|
+
convertToAdvanceMode: () => Promise<void>;
|
|
99
|
+
};
|
|
100
|
+
}, __VLS_248: {
|
|
101
|
+
insert: typeof insertInputType;
|
|
102
|
+
disabled: boolean;
|
|
103
|
+
};
|
|
104
|
+
type __VLS_Slots = {} & {
|
|
105
|
+
title?: (props: typeof __VLS_20) => any;
|
|
106
|
+
} & {
|
|
107
|
+
toolbarItems?: (props: typeof __VLS_28) => any;
|
|
108
|
+
} & {
|
|
109
|
+
empty?: (props: typeof __VLS_197) => any;
|
|
110
|
+
} & {
|
|
111
|
+
palette?: (props: typeof __VLS_248) => any;
|
|
112
|
+
};
|
|
113
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
114
|
+
templateItems: import("vue").Ref<Record<string, any>[], Record<string, any>[]>;
|
|
115
|
+
previewData: import("vue").Ref<Record<string, any>, Record<string, any>>;
|
|
116
|
+
selectedIndex: import("vue").Ref<number | null, number | null>;
|
|
117
|
+
dragIndex: import("vue").Ref<number | null, number | null>;
|
|
118
|
+
mode: import("vue").Ref<"design" | "preview", "design" | "preview">;
|
|
119
|
+
operation: import("vue").Ref<{
|
|
120
|
+
openCreate: typeof openCreate;
|
|
121
|
+
openEdit: typeof openEdit;
|
|
122
|
+
closeEditor: typeof closeEditor;
|
|
123
|
+
deleteSelected: typeof deleteSelected;
|
|
124
|
+
moveSelected: typeof moveSelected;
|
|
125
|
+
moveItemTo: typeof moveItemTo;
|
|
126
|
+
duplicateSelected: typeof duplicateSelected;
|
|
127
|
+
insertInputType: typeof insertInputType;
|
|
128
|
+
importItems: typeof importItems;
|
|
129
|
+
convertToAdvanceMode: () => Promise<void>;
|
|
130
|
+
}, {
|
|
131
|
+
openCreate: typeof openCreate;
|
|
132
|
+
openEdit: typeof openEdit;
|
|
133
|
+
closeEditor: typeof closeEditor;
|
|
134
|
+
deleteSelected: typeof deleteSelected;
|
|
135
|
+
moveSelected: typeof moveSelected;
|
|
136
|
+
moveItemTo: typeof moveItemTo;
|
|
137
|
+
duplicateSelected: typeof duplicateSelected;
|
|
138
|
+
insertInputType: typeof insertInputType;
|
|
139
|
+
importItems: typeof importItems;
|
|
140
|
+
convertToAdvanceMode: () => Promise<void>;
|
|
141
|
+
} | {
|
|
142
|
+
openCreate: typeof openCreate;
|
|
143
|
+
openEdit: typeof openEdit;
|
|
144
|
+
closeEditor: typeof closeEditor;
|
|
145
|
+
deleteSelected: typeof deleteSelected;
|
|
146
|
+
moveSelected: typeof moveSelected;
|
|
147
|
+
moveItemTo: typeof moveItemTo;
|
|
148
|
+
duplicateSelected: typeof duplicateSelected;
|
|
149
|
+
insertInputType: typeof insertInputType;
|
|
150
|
+
importItems: typeof importItems;
|
|
151
|
+
convertToAdvanceMode: () => Promise<void>;
|
|
152
|
+
}>;
|
|
153
|
+
openCreate: typeof openCreate;
|
|
154
|
+
openEdit: typeof openEdit;
|
|
155
|
+
closeEditor: typeof closeEditor;
|
|
156
|
+
moveItemTo: typeof moveItemTo;
|
|
157
|
+
insertInputType: typeof insertInputType;
|
|
158
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
159
|
+
"update:modelValue": (value: string | Record<string, any>[] | undefined) => any;
|
|
160
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
161
|
+
"onUpdate:modelValue"?: ((value: string | Record<string, any>[] | undefined) => any) | undefined;
|
|
162
|
+
}>, {
|
|
163
|
+
title: string;
|
|
164
|
+
stringFields: string[];
|
|
165
|
+
initialData: Record<string, any>;
|
|
166
|
+
customCode: boolean;
|
|
167
|
+
disableAdvanceMode: boolean;
|
|
168
|
+
toolbarColor: string;
|
|
169
|
+
editorWidth: number | string;
|
|
170
|
+
outline: boolean;
|
|
171
|
+
importable: boolean;
|
|
172
|
+
exportable: boolean;
|
|
173
|
+
importMode: DocumentTemplateImportMode;
|
|
174
|
+
sortable: boolean;
|
|
175
|
+
palette: boolean;
|
|
176
|
+
paletteTypes: string[];
|
|
177
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
178
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
179
|
+
declare const _default: typeof __VLS_export;
|
|
180
|
+
export default _default;
|
|
181
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
182
|
+
new (): {
|
|
183
|
+
$slots: S;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
data: Record<string, any>;
|
|
3
|
+
rules?: Record<string, any>;
|
|
4
|
+
customCode?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
7
|
+
rules: Record<string, any>;
|
|
8
|
+
customCode: boolean;
|
|
9
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
validationRulesRegex,
|
|
5
|
+
optionStringToChoiceObject,
|
|
6
|
+
radioChoiceTextVariable,
|
|
7
|
+
printConfigToAttributes,
|
|
8
|
+
rowsToPrintConfig,
|
|
9
|
+
configStringToRows,
|
|
10
|
+
rowsToConfigString
|
|
11
|
+
} from "../../composables/document/template";
|
|
12
|
+
import {
|
|
13
|
+
useDocumentTemplateInputTypes
|
|
14
|
+
} from "../../composables/document/templateInputTypes";
|
|
15
|
+
import { autoActionHeader, templateToHeader } from "../../composables/document/templateFormTable";
|
|
16
|
+
import { useRules } from "../../composables/utils/validation";
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
data: { type: Object, required: true },
|
|
19
|
+
rules: { type: Object, required: false, default: void 0 },
|
|
20
|
+
customCode: { type: Boolean, required: false, default: false }
|
|
21
|
+
});
|
|
22
|
+
const fallbackRules = useRules().rules;
|
|
23
|
+
const rules = computed(() => props.rules ?? fallbackRules.value);
|
|
24
|
+
const formTableHeaders = ref([
|
|
25
|
+
{ title: "Title", key: "title" },
|
|
26
|
+
{ title: "Key", key: "key" },
|
|
27
|
+
{ title: "Width", key: "width" },
|
|
28
|
+
{ title: "Action", key: "action", width: "120px" }
|
|
29
|
+
]);
|
|
30
|
+
const choiceHeaders = ref([
|
|
31
|
+
{ title: "Label", key: "label" },
|
|
32
|
+
{ title: "Value", key: "value" },
|
|
33
|
+
{ title: "Action", key: "action", width: "120px" }
|
|
34
|
+
]);
|
|
35
|
+
const printConfigHeaders = ref([
|
|
36
|
+
{ title: "Attribute", key: "key" },
|
|
37
|
+
{ title: "Value", key: "value" },
|
|
38
|
+
{ title: "Action", key: "action", width: "120px" }
|
|
39
|
+
]);
|
|
40
|
+
function setPrintConfigMode(item, mode) {
|
|
41
|
+
if (mode === "raw") {
|
|
42
|
+
if (typeof item.printConfig === "string") return;
|
|
43
|
+
item.printConfig = rowsToConfigString(Array.isArray(item.printConfig) ? item.printConfig : []);
|
|
44
|
+
} else {
|
|
45
|
+
if (Array.isArray(item.printConfig)) return;
|
|
46
|
+
item.printConfig = configStringToRows(typeof item.printConfig === "string" ? item.printConfig : "");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function printConfigPreview(printConfig) {
|
|
50
|
+
if (Array.isArray(printConfig)) return printConfigToAttributes(rowsToPrintConfig(printConfig));
|
|
51
|
+
return printConfigToAttributes(printConfig);
|
|
52
|
+
}
|
|
53
|
+
const inputTypes = computed(() => useDocumentTemplateInputTypes());
|
|
54
|
+
const inputTypeChoice = computed(() => inputTypes.value.filter((t) => props.customCode || t.value !== "CustomCode").map((t) => ({ label: t.label, value: t.value })));
|
|
55
|
+
const requireOption = computed(() => inputTypes.value.filter((t) => t.requiresOptions).map((t) => t.value));
|
|
56
|
+
const notRequireVariable = computed(() => inputTypes.value.filter((t) => t.needsVariableName === false).map((t) => t.value));
|
|
57
|
+
const notRequireLabel = computed(() => inputTypes.value.filter((t) => t.needsLabel === false).map((t) => t.value));
|
|
58
|
+
const notRequireWidth = computed(() => inputTypes.value.filter((t) => t.needsWidth === false).map((t) => t.value));
|
|
59
|
+
const notRequireOptions = computed(() => inputTypes.value.filter((t) => t.showsOptions === false).map((t) => t.value));
|
|
60
|
+
const notRequireRules = computed(() => inputTypes.value.filter((t) => t.hidesValidationRules).map((t) => t.value));
|
|
61
|
+
const notRequireInputAttributes = computed(() => inputTypes.value.filter((t) => t.hidesInputAttributes).map((t) => t.value));
|
|
62
|
+
const notRequireColumnAttributes = computed(() => inputTypes.value.filter((t) => t.hidesColumnAttributes).map((t) => t.value));
|
|
63
|
+
const notRequireAdvancedSetting = computed(() => inputTypes.value.filter((t) => t.hidesAdvancedSettings).map((t) => t.value));
|
|
64
|
+
const notRequireClassAndStyle = computed(() => inputTypes.value.filter((t) => t.hidesClassAndStyle).map((t) => t.value));
|
|
65
|
+
const hasSpecificOption = computed(() => inputTypes.value.filter((t) => t.hasSpecificOptionEditor).map((t) => t.value));
|
|
66
|
+
const choiceOption = computed(() => inputTypes.value.filter((t) => t.optionsAsChoice).map((t) => t.value));
|
|
67
|
+
const radioOption = ["VRadio", "VRadioInline"];
|
|
68
|
+
const inputOptionsLabel = computed(() => {
|
|
69
|
+
const acc = {};
|
|
70
|
+
for (const t of inputTypes.value) if (t.optionsLabel) acc[t.value] = t.optionsLabel;
|
|
71
|
+
return acc;
|
|
72
|
+
});
|
|
73
|
+
const ruleOptions = (inputType) => (value) => {
|
|
74
|
+
if (choiceOption.value.includes(inputType) && !/^[^'",]+(,[^'",]+)*$/.test(value)) return "Invalid options format";
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<v-container fluid class="doc-item-form">
|
|
81
|
+
<v-row density="compact">
|
|
82
|
+
<v-col class="doc-item-form__type">
|
|
83
|
+
<v-combobox
|
|
84
|
+
v-model="data.inputType"
|
|
85
|
+
label="Input Type"
|
|
86
|
+
:items="inputTypeChoice"
|
|
87
|
+
item-title="label"
|
|
88
|
+
item-value="value"
|
|
89
|
+
:return-object="false"
|
|
90
|
+
:rules="[rules.require()]"
|
|
91
|
+
/>
|
|
92
|
+
</v-col>
|
|
93
|
+
<v-col class="doc-item-form__width" v-if="!notRequireWidth.includes(data.inputType)">
|
|
94
|
+
<v-text-field
|
|
95
|
+
v-model="data.width"
|
|
96
|
+
label="Width"
|
|
97
|
+
:rules="[rules.require()]"
|
|
98
|
+
type="number"
|
|
99
|
+
/>
|
|
100
|
+
<form-hidden v-model="data.inputOptions" :item-value="data.inputType" :hook="(_result, model, newValue, oldValue) => {
|
|
101
|
+
return newValue && oldValue ? void 0 : model;
|
|
102
|
+
}"></form-hidden>
|
|
103
|
+
</v-col>
|
|
104
|
+
<v-col class="doc-item-form__label" v-if="!notRequireLabel.includes(data.inputType)">
|
|
105
|
+
<v-text-field
|
|
106
|
+
v-model="data.inputLabel"
|
|
107
|
+
label="Input Label"
|
|
108
|
+
:rules="[rules.require()]"
|
|
109
|
+
/>
|
|
110
|
+
</v-col>
|
|
111
|
+
<v-col class="doc-item-form__variable" v-if="!notRequireVariable.includes(data.inputType)">
|
|
112
|
+
<v-text-field
|
|
113
|
+
v-model="data.variableName"
|
|
114
|
+
label="Variable Name"
|
|
115
|
+
:rules="[rules.require()]"
|
|
116
|
+
/>
|
|
117
|
+
</v-col>
|
|
118
|
+
<v-col
|
|
119
|
+
v-if="!notRequireOptions.includes(data.inputType)"
|
|
120
|
+
cols="12"
|
|
121
|
+
>
|
|
122
|
+
<form-pad v-model="data.inputOptions" v-if="data.inputType == 'FormTable'">
|
|
123
|
+
<template #default="{ data: optionData }">
|
|
124
|
+
<v-row density="compact">
|
|
125
|
+
<v-col cols="12">
|
|
126
|
+
<form-table v-model="optionData.headers" :headers="formTableHeaders" title="Headers">
|
|
127
|
+
<template #form="{ data: headerData, rules }">
|
|
128
|
+
<v-container fluid>
|
|
129
|
+
<v-row density="compact">
|
|
130
|
+
<v-col cols="6"><v-text-field v-model="headerData.title" label="Title"></v-text-field></v-col>
|
|
131
|
+
<v-col cols="3"><v-text-field v-model="headerData.key" label="Key" :rules="[rules.require()]"></v-text-field></v-col>
|
|
132
|
+
<v-col cols="3"><v-text-field v-model="headerData.width" label="Width"></v-text-field></v-col>
|
|
133
|
+
</v-row>
|
|
134
|
+
<v-row density="compact">
|
|
135
|
+
<v-col cols="12"><v-textarea v-model="headerData.template" label="Item Template"></v-textarea></v-col>
|
|
136
|
+
</v-row>
|
|
137
|
+
</v-container>
|
|
138
|
+
</template>
|
|
139
|
+
</form-table>
|
|
140
|
+
</v-col>
|
|
141
|
+
<v-col cols="12">
|
|
142
|
+
<document-template-builder v-model="optionData.formTemplate" title="Form Template" :custom-code="customCode"></document-template-builder>
|
|
143
|
+
</v-col>
|
|
144
|
+
</v-row>
|
|
145
|
+
</template>
|
|
146
|
+
</form-pad>
|
|
147
|
+
<form-pad v-model="data.inputOptions" v-if="data.inputType == 'FormTableData'">
|
|
148
|
+
<template #default="{ data: optionData }">
|
|
149
|
+
<v-row density="compact">
|
|
150
|
+
<v-col cols="12">
|
|
151
|
+
<tabs-group>
|
|
152
|
+
<template #tabs>
|
|
153
|
+
<v-tab value="itemTemplate">Item Template</v-tab>
|
|
154
|
+
<v-tab value="dataTemplate">Data Template</v-tab>
|
|
155
|
+
<v-tab value="header">Header</v-tab>
|
|
156
|
+
</template>
|
|
157
|
+
<template #items>
|
|
158
|
+
<v-tabs-window-item value="itemTemplate">
|
|
159
|
+
<document-template-builder v-model="optionData.itemTemplate" title="Item Template" :custom-code="customCode" disable-advance-mode></document-template-builder>
|
|
160
|
+
</v-tabs-window-item>
|
|
161
|
+
<v-tabs-window-item value="dataTemplate">
|
|
162
|
+
<document-template-builder v-model="optionData.dataTemplate" title="Data Template" :custom-code="customCode" disable-advance-mode></document-template-builder>
|
|
163
|
+
</v-tabs-window-item>
|
|
164
|
+
<v-tabs-window-item value="header">
|
|
165
|
+
<form-table v-model="optionData.headers" :headers="formTableHeaders" title="Headers">
|
|
166
|
+
<template #form="{ data: headerData, rules }">
|
|
167
|
+
<v-container fluid>
|
|
168
|
+
<v-row density="compact">
|
|
169
|
+
<v-col cols="6"><v-text-field v-model="headerData.title" label="Title"></v-text-field></v-col>
|
|
170
|
+
<v-col cols="3"><v-text-field v-model="headerData.key" label="Key" :rules="[rules.require()]"></v-text-field></v-col>
|
|
171
|
+
<v-col cols="3"><v-text-field v-model="headerData.width" label="Width"></v-text-field></v-col>
|
|
172
|
+
</v-row>
|
|
173
|
+
<v-row density="compact">
|
|
174
|
+
<v-col cols="12"><v-text-field v-model="headerData.value" label="Value"></v-text-field></v-col>
|
|
175
|
+
<v-col cols="12"><v-textarea v-model="headerData.template" label="Item Template"></v-textarea></v-col>
|
|
176
|
+
</v-row>
|
|
177
|
+
</v-container>
|
|
178
|
+
</template>
|
|
179
|
+
</form-table>
|
|
180
|
+
</v-tabs-window-item>
|
|
181
|
+
</template>
|
|
182
|
+
</tabs-group>
|
|
183
|
+
</v-col>
|
|
184
|
+
<v-col cols="12">
|
|
185
|
+
<form-table v-model="optionData.items" :headers="optionData.headers && optionData.headers.length > 0 ? autoActionHeader(optionData.headers) : autoActionHeader(templateToHeader(optionData.itemTemplate))" title="Items">
|
|
186
|
+
<template #form="{ data }">
|
|
187
|
+
<form-pad :model-value="data" :template="optionData.itemTemplate"></form-pad>
|
|
188
|
+
</template>
|
|
189
|
+
</form-table>
|
|
190
|
+
</v-col>
|
|
191
|
+
<v-col cols="12">
|
|
192
|
+
<v-row density="compact">
|
|
193
|
+
<v-col cols="4">
|
|
194
|
+
<v-radio-group v-model="optionData.disableApplyToAll" inline>
|
|
195
|
+
<template #prepend>
|
|
196
|
+
<span class="opacity-60"> Disable Apply to All</span>
|
|
197
|
+
</template>
|
|
198
|
+
<v-radio label="No" value="false" hide-details> </v-radio>
|
|
199
|
+
<v-radio label="Yes" value="true" hide-details> </v-radio>
|
|
200
|
+
<v-radio label="Partial" value="partial" hide-details> </v-radio>
|
|
201
|
+
</v-radio-group>
|
|
202
|
+
</v-col>
|
|
203
|
+
<v-col cols="8">
|
|
204
|
+
<VTextField
|
|
205
|
+
variant="underlined"
|
|
206
|
+
v-model="optionData.disableApplyToAllPartial"
|
|
207
|
+
label="Disable Apply To All Column"
|
|
208
|
+
v-if="optionData.disableApplyToAll == 'partial'"
|
|
209
|
+
>
|
|
210
|
+
</VTextField>
|
|
211
|
+
</v-col>
|
|
212
|
+
</v-row>
|
|
213
|
+
</v-col>
|
|
214
|
+
</v-row>
|
|
215
|
+
</template>
|
|
216
|
+
</form-pad>
|
|
217
|
+
<form-pad v-model="data.inputOptions" v-if="data.inputType == 'FormHidden'">
|
|
218
|
+
<template #default="{ data: optionData }">
|
|
219
|
+
<v-row density="compact">
|
|
220
|
+
<v-col cols="12">
|
|
221
|
+
<v-text-field
|
|
222
|
+
v-model="optionData.hook"
|
|
223
|
+
label="Hook"
|
|
224
|
+
/>
|
|
225
|
+
</v-col>
|
|
226
|
+
<v-col cols="12">
|
|
227
|
+
<v-text-field
|
|
228
|
+
v-model="optionData.itemValue"
|
|
229
|
+
label="Item Value"
|
|
230
|
+
/>
|
|
231
|
+
</v-col>
|
|
232
|
+
</v-row>
|
|
233
|
+
</template>
|
|
234
|
+
</form-pad>
|
|
235
|
+
<form-table v-model="data.inputOptions" :headers="choiceHeaders" title="Choices" v-if="choiceOption.includes(data.inputType) && (!data.inputOptions || typeof data.inputOptions === 'object')">
|
|
236
|
+
<template #form="{ data: optionData, rules }">
|
|
237
|
+
<v-container fluid>
|
|
238
|
+
<v-row density="compact">
|
|
239
|
+
<v-col cols="6"><v-text-field v-model="optionData.label" label="Label"></v-text-field></v-col>
|
|
240
|
+
<v-col cols="6"><v-text-field v-model="optionData.value" label="Value" :rules="[rules.require()]"></v-text-field></v-col>
|
|
241
|
+
<v-col cols="12" v-if="radioOption.includes(data.inputType)">
|
|
242
|
+
<v-radio-group
|
|
243
|
+
:model-value="optionData.textField === true"
|
|
244
|
+
inline
|
|
245
|
+
hide-details
|
|
246
|
+
density="compact"
|
|
247
|
+
@update:model-value="(v) => optionData.textField = v === true"
|
|
248
|
+
>
|
|
249
|
+
<template #prepend><span class="opacity-60 me-2">Text field after label</span></template>
|
|
250
|
+
<v-radio label="No" :value="false"></v-radio>
|
|
251
|
+
<v-radio label="Yes" :value="true"></v-radio>
|
|
252
|
+
</v-radio-group>
|
|
253
|
+
<div class="text-caption text-medium-emphasis mt-1">
|
|
254
|
+
Yes renders a text field beside this option, bound to
|
|
255
|
+
<code>data.{{ radioChoiceTextVariable(data.variableName, optionData.value) }}</code>.
|
|
256
|
+
It is enabled only while this option is selected and cleared when the selection changes.
|
|
257
|
+
</div>
|
|
258
|
+
<v-text-field
|
|
259
|
+
v-if="optionData.textField === true"
|
|
260
|
+
v-model="optionData.textFieldPlaceholder"
|
|
261
|
+
label="Text field placeholder"
|
|
262
|
+
hint="Shown inside the text field while it is empty (optional)."
|
|
263
|
+
persistent-hint
|
|
264
|
+
class="mt-2"
|
|
265
|
+
></v-text-field>
|
|
266
|
+
<v-text-field
|
|
267
|
+
v-if="optionData.textField === true"
|
|
268
|
+
v-model="optionData.textFieldRules"
|
|
269
|
+
label="Text field validation rules"
|
|
270
|
+
hint="Same format as the item's Validation Rules (see Available rules below), e.g. require,length(50). Applied only while this option is selected."
|
|
271
|
+
persistent-hint
|
|
272
|
+
:rules="[rules.regex(validationRulesRegex)]"
|
|
273
|
+
class="mt-2"
|
|
274
|
+
></v-text-field>
|
|
275
|
+
</v-col>
|
|
276
|
+
</v-row>
|
|
277
|
+
</v-container>
|
|
278
|
+
</template>
|
|
279
|
+
</form-table>
|
|
280
|
+
<form-hidden v-model="data.inputOptions" :itemValue="data.inputOptions" :hook="(option) => optionStringToChoiceObject(option)" v-if="choiceOption.includes(data.inputType) && data.inputOptions && typeof data.inputOptions === 'string'"></form-hidden>
|
|
281
|
+
<v-textarea
|
|
282
|
+
v-model="data.inputOptions"
|
|
283
|
+
:label="inputOptionsLabel[data.inputType] || 'Input Options'"
|
|
284
|
+
auto-grow
|
|
285
|
+
:rules="[rules.requireIf(requireOption.includes(data.inputType)), ruleOptions(data.inputType)]"
|
|
286
|
+
v-if="!hasSpecificOption.includes(data.inputType) && !choiceOption.includes(data.inputType)"
|
|
287
|
+
/>
|
|
288
|
+
</v-col>
|
|
289
|
+
|
|
290
|
+
<v-col
|
|
291
|
+
v-if="data.inputType == 'CustomCode'"
|
|
292
|
+
cols="12"
|
|
293
|
+
>
|
|
294
|
+
<FormCodeEditor
|
|
295
|
+
v-model="data.inputCustomCode"
|
|
296
|
+
label="Custom Code"
|
|
297
|
+
:rules="[rules.require()]"
|
|
298
|
+
/>
|
|
299
|
+
</v-col>
|
|
300
|
+
</v-row>
|
|
301
|
+
<v-row density="compact">
|
|
302
|
+
<v-col>
|
|
303
|
+
<v-expansion-panels>
|
|
304
|
+
<v-expansion-panel v-if="!notRequireRules.includes(data.inputType)">
|
|
305
|
+
<v-expansion-panel-title collapse-icon="mdi mdi-minus" expand-icon="mdi mdi-plus" class="font-weight-bold">Validations</v-expansion-panel-title>
|
|
306
|
+
<v-expansion-panel-text>
|
|
307
|
+
<v-container fluid>
|
|
308
|
+
<v-row density="compact">
|
|
309
|
+
<v-col cols="12">
|
|
310
|
+
<v-text-field
|
|
311
|
+
v-model="data.validationRules"
|
|
312
|
+
label="Validation Rules"
|
|
313
|
+
:rules="[rules.regex(validationRulesRegex)]"
|
|
314
|
+
/>
|
|
315
|
+
<b>Available rules :</b> require, requireIf(condition), requireTrue, requireTrueIf(condition), requireNotEmpty, numeric, range(min,max), integer, unique, length(length), lengthGreater(length), lengthLess(length), telephone, email, regex(regex), idcard, DateFuture, DatetimeFuture, DateHappen, DatetimeHappen, DateAfter(date), DateBefore(Date), DateEqual(date)
|
|
316
|
+
</v-col>
|
|
317
|
+
</v-row>
|
|
318
|
+
</v-container>
|
|
319
|
+
</v-expansion-panel-text>
|
|
320
|
+
</v-expansion-panel>
|
|
321
|
+
<v-expansion-panel v-if="!notRequireAdvancedSetting.includes(data.inputType)">
|
|
322
|
+
<v-expansion-panel-title collapse-icon="mdi mdi-minus" expand-icon="mdi mdi-plus" class="font-weight-bold">Advanced settings</v-expansion-panel-title>
|
|
323
|
+
<v-expansion-panel-text>
|
|
324
|
+
<v-container fluid>
|
|
325
|
+
<v-row density="compact">
|
|
326
|
+
<v-col class="doc-item-form__half" v-if="!notRequireInputAttributes.includes(data.inputType)">
|
|
327
|
+
<v-text-field
|
|
328
|
+
v-model="data.inputAttributes"
|
|
329
|
+
label="Input Attributes"
|
|
330
|
+
/>
|
|
331
|
+
</v-col>
|
|
332
|
+
<v-col class="doc-item-form__half" v-if="!notRequireColumnAttributes.includes(data.inputType)">
|
|
333
|
+
<v-text-field
|
|
334
|
+
v-model="data.columnAttributes"
|
|
335
|
+
label="Column Attributes"
|
|
336
|
+
/>
|
|
337
|
+
</v-col>
|
|
338
|
+
<v-col class="doc-item-form__half">
|
|
339
|
+
<v-text-field
|
|
340
|
+
v-model="data.conditionalDisplay"
|
|
341
|
+
label="Conditional Display"
|
|
342
|
+
/>
|
|
343
|
+
</v-col>
|
|
344
|
+
<v-col class="doc-item-form__half">
|
|
345
|
+
<v-text-field
|
|
346
|
+
v-model="data.computedValue"
|
|
347
|
+
label="Computed Value"
|
|
348
|
+
/>
|
|
349
|
+
</v-col>
|
|
350
|
+
<v-col class="doc-item-form__half">
|
|
351
|
+
<v-text-field
|
|
352
|
+
v-model="data.retrievedValue"
|
|
353
|
+
label="Retrieved Value"
|
|
354
|
+
/>
|
|
355
|
+
</v-col>
|
|
356
|
+
<v-col cols="12">
|
|
357
|
+
<div class="d-flex align-center ga-2 mb-1">
|
|
358
|
+
<span class="opacity-60">Print Config</span>
|
|
359
|
+
<span class="text-caption opacity-60">— print/docx-only; ignored by the form renderer</span>
|
|
360
|
+
<v-spacer />
|
|
361
|
+
<v-btn-toggle
|
|
362
|
+
:model-value="typeof data.printConfig === 'string' ? 'raw' : 'map'"
|
|
363
|
+
@update:model-value="(mode) => setPrintConfigMode(data, mode)"
|
|
364
|
+
density="compact"
|
|
365
|
+
variant="outlined"
|
|
366
|
+
divided
|
|
367
|
+
mandatory
|
|
368
|
+
>
|
|
369
|
+
<v-btn value="map" size="small">Key / Value</v-btn>
|
|
370
|
+
<v-btn value="raw" size="small">Raw string</v-btn>
|
|
371
|
+
</v-btn-toggle>
|
|
372
|
+
</div>
|
|
373
|
+
<v-textarea
|
|
374
|
+
v-if="typeof data.printConfig === 'string'"
|
|
375
|
+
v-model="data.printConfig"
|
|
376
|
+
label="Print Config (raw attributes)"
|
|
377
|
+
placeholder="format=dd/MM/yyyy; locale=th_TH"
|
|
378
|
+
auto-grow
|
|
379
|
+
rows="1"
|
|
380
|
+
/>
|
|
381
|
+
<form-table
|
|
382
|
+
v-else
|
|
383
|
+
v-model="data.printConfig"
|
|
384
|
+
:headers="printConfigHeaders"
|
|
385
|
+
title="Print Config"
|
|
386
|
+
>
|
|
387
|
+
<template #form="{ data: rowData, rules }">
|
|
388
|
+
<v-container fluid>
|
|
389
|
+
<v-row density="compact">
|
|
390
|
+
<v-col cols="6">
|
|
391
|
+
<v-text-field v-model="rowData.key" label="Attribute" :rules="[rules.require()]" />
|
|
392
|
+
</v-col>
|
|
393
|
+
<v-col cols="6">
|
|
394
|
+
<v-text-field v-model="rowData.value" label="Value (blank = flag)" />
|
|
395
|
+
</v-col>
|
|
396
|
+
</v-row>
|
|
397
|
+
</v-container>
|
|
398
|
+
</template>
|
|
399
|
+
</form-table>
|
|
400
|
+
<div class="text-caption opacity-60 mt-1" v-if="printConfigPreview(data.printConfig)">
|
|
401
|
+
Appends to placeholder: <code>{{ printConfigPreview(data.printConfig) }}</code>
|
|
402
|
+
</div>
|
|
403
|
+
</v-col>
|
|
404
|
+
</v-row>
|
|
405
|
+
</v-container>
|
|
406
|
+
</v-expansion-panel-text>
|
|
407
|
+
</v-expansion-panel>
|
|
408
|
+
<v-expansion-panel v-if="!notRequireClassAndStyle.includes(data.inputType)">
|
|
409
|
+
<v-expansion-panel-title collapse-icon="mdi mdi-minus" expand-icon="mdi mdi-plus" class="font-weight-bold">Class and Styles</v-expansion-panel-title>
|
|
410
|
+
<v-expansion-panel-text>
|
|
411
|
+
<v-container fluid>
|
|
412
|
+
<v-row density="compact">
|
|
413
|
+
<v-col cols="12">
|
|
414
|
+
<v-text-field
|
|
415
|
+
v-model="data.customClass"
|
|
416
|
+
label="Custom Class"
|
|
417
|
+
/>
|
|
418
|
+
</v-col>
|
|
419
|
+
<v-col cols="12">
|
|
420
|
+
<v-text-field
|
|
421
|
+
v-model="data.customStyle"
|
|
422
|
+
label="Custom Styles"
|
|
423
|
+
/>
|
|
424
|
+
</v-col>
|
|
425
|
+
</v-row>
|
|
426
|
+
</v-container>
|
|
427
|
+
</v-expansion-panel-text>
|
|
428
|
+
</v-expansion-panel>
|
|
429
|
+
</v-expansion-panels>
|
|
430
|
+
</v-col>
|
|
431
|
+
</v-row>
|
|
432
|
+
</v-container>
|
|
433
|
+
</template>
|
|
434
|
+
|
|
435
|
+
<style scoped>
|
|
436
|
+
.doc-item-form{container-type:inline-size}.doc-item-form .doc-item-form__width{flex:0 0 7rem;max-width:7rem}.doc-item-form .doc-item-form__type{flex:1 1 calc(100% - 8.5rem);max-width:100%;min-width:0}.doc-item-form .doc-item-form__half,.doc-item-form .doc-item-form__label,.doc-item-form .doc-item-form__variable{flex:1 1 calc(50% - 1.5rem);max-width:100%;min-width:0}@container (max-width: 559px){.doc-item-form .doc-item-form__half,.doc-item-form .doc-item-form__label,.doc-item-form .doc-item-form__variable{flex-basis:100%}}@container (min-width: 840px){.doc-item-form .doc-item-form__type{flex-basis:calc(34% - 1.5rem)}.doc-item-form .doc-item-form__label,.doc-item-form .doc-item-form__variable{flex-basis:calc(25% - 1.5rem)}}
|
|
437
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
data: Record<string, any>;
|
|
3
|
+
rules?: Record<string, any>;
|
|
4
|
+
customCode?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
7
|
+
rules: Record<string, any>;
|
|
8
|
+
customCode: boolean;
|
|
9
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|