@ramathibodi/nuxt-commons 4.0.11 → 4.0.12
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 +2 -2
- package/dist/runtime/components/document/TemplateBuilder.vue +1 -1
- package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +2 -2
- package/dist/runtime/components/form/ActionPad.vue +1 -0
- package/dist/runtime/components/form/Birthdate.d.vue.ts +3 -3
- package/dist/runtime/components/form/Birthdate.vue.d.ts +3 -3
- package/dist/runtime/components/form/Date.vue +11 -6
- package/dist/runtime/components/form/Dialog.d.vue.ts +1 -5
- package/dist/runtime/components/form/Dialog.vue +1 -0
- package/dist/runtime/components/form/Dialog.vue.d.ts +1 -5
- package/dist/runtime/components/form/EditPad.vue +1 -0
- package/dist/runtime/components/form/Pad.d.vue.ts +24 -0
- package/dist/runtime/components/form/Pad.vue +11 -6
- package/dist/runtime/components/form/Pad.vue.d.ts +24 -0
- package/dist/runtime/components/form/Time.vue +10 -5
- package/dist/runtime/components/form/images/Edit.d.vue.ts +1 -3
- package/dist/runtime/components/form/images/Edit.vue.d.ts +1 -3
- package/dist/runtime/components/model/AutoRefreshChip.d.vue.ts +16 -0
- package/dist/runtime/components/model/AutoRefreshChip.vue +34 -0
- package/dist/runtime/components/model/AutoRefreshChip.vue.d.ts +16 -0
- package/dist/runtime/components/model/Table.d.vue.ts +91 -61
- package/dist/runtime/components/model/Table.vue +24 -5
- package/dist/runtime/components/model/Table.vue.d.ts +91 -61
- package/dist/runtime/components/model/iterator.d.vue.ts +103 -71
- package/dist/runtime/components/model/iterator.vue +24 -5
- package/dist/runtime/components/model/iterator.vue.d.ts +103 -71
- package/dist/runtime/composables/apiModel.d.ts +2 -2
- package/dist/runtime/composables/apiModel.js +3 -3
- package/dist/runtime/composables/autoRefresh.d.ts +42 -0
- package/dist/runtime/composables/autoRefresh.js +57 -0
- package/dist/runtime/composables/document/template.js +1 -1
- package/dist/runtime/composables/graphqlModel.d.ts +2 -2
- package/dist/runtime/composables/graphqlModel.js +3 -3
- package/dist/runtime/composables/modelAutoRefresh.d.ts +29 -0
- package/dist/runtime/composables/modelAutoRefresh.js +16 -0
- package/dist/runtime/composables/utils/validation.d.ts +4 -0
- package/dist/runtime/composables/utils/validation.js +2 -0
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed, nextTick, ref, useAttrs, useSlots, watch } from "vue";
|
|
2
|
+
import { computed, nextTick, ref, markRaw, useAttrs, useSlots, watch } from "vue";
|
|
3
|
+
import { useModelAutoRefresh } from "../../composables/modelAutoRefresh";
|
|
3
4
|
import { VDataIterator } from "vuetify/components/VDataIterator";
|
|
4
5
|
import { VDataTable } from "vuetify/components/VDataTable";
|
|
5
6
|
import { omit } from "lodash-es";
|
|
@@ -39,6 +40,9 @@ const props = defineProps({
|
|
|
39
40
|
api: { type: Boolean, required: false, default: false },
|
|
40
41
|
perPageStorageKey: { type: String, required: false },
|
|
41
42
|
perPageStorageEnabled: { type: Boolean, required: false, default: true },
|
|
43
|
+
autoRefresh: { type: [Number, Boolean], required: false, default: false },
|
|
44
|
+
autoRefreshDefault: { type: Number, required: false, default: 60 },
|
|
45
|
+
autoRefreshControl: { type: Boolean, required: false, default: true },
|
|
42
46
|
modelName: { type: String, required: true },
|
|
43
47
|
modelKey: { type: String, required: false, default: "id" },
|
|
44
48
|
modelBy: { type: Object, required: false, default: void 0 },
|
|
@@ -114,6 +118,11 @@ const {
|
|
|
114
118
|
reload,
|
|
115
119
|
isLoading
|
|
116
120
|
} = props.api ? useApiModel(props) : useGraphqlModel(props);
|
|
121
|
+
const { autoRefresh, manualReload } = useModelAutoRefresh(props, {
|
|
122
|
+
reload,
|
|
123
|
+
isLoading,
|
|
124
|
+
isDialogOpen
|
|
125
|
+
});
|
|
117
126
|
function openDialog(item) {
|
|
118
127
|
currentItem.value = item;
|
|
119
128
|
nextTick(() => {
|
|
@@ -158,7 +167,7 @@ watch(
|
|
|
158
167
|
},
|
|
159
168
|
{ immediate: true }
|
|
160
169
|
);
|
|
161
|
-
const operation = ref({ openDialog, createItem, importItems, updateItem, deleteItem, reload, setSearch, canServerPageable, canServerSearch, canCreate, canUpdate, canDelete });
|
|
170
|
+
const operation = ref({ openDialog, createItem, importItems, updateItem, deleteItem, reload, setSearch, canServerPageable, canServerSearch, canCreate, canUpdate, canDelete, autoRefresh: markRaw(autoRefresh) });
|
|
162
171
|
const computedInitialData = computed(() => {
|
|
163
172
|
return Object.assign({}, props.initialData, props.modelBy);
|
|
164
173
|
});
|
|
@@ -169,7 +178,7 @@ const computedSkeletonPerPage = computed(() => {
|
|
|
169
178
|
watch(() => props.search, () => {
|
|
170
179
|
search.value = props.search;
|
|
171
180
|
}, { immediate: true });
|
|
172
|
-
defineExpose({ reload, operation });
|
|
181
|
+
defineExpose({ reload, operation, autoRefresh });
|
|
173
182
|
</script>
|
|
174
183
|
|
|
175
184
|
<template>
|
|
@@ -256,16 +265,26 @@ defineExpose({ reload, operation });
|
|
|
256
265
|
<VToolbarTitle class="pl-3">
|
|
257
266
|
<slot
|
|
258
267
|
name="title"
|
|
259
|
-
:reload="
|
|
268
|
+
:reload="manualReload"
|
|
260
269
|
>
|
|
261
270
|
{{ title }}
|
|
262
271
|
<v-icon
|
|
263
272
|
size="small"
|
|
264
|
-
@click="
|
|
273
|
+
@click="manualReload"
|
|
265
274
|
>
|
|
266
275
|
mdi mdi-refresh
|
|
267
276
|
</v-icon>
|
|
268
277
|
</slot>
|
|
278
|
+
<slot
|
|
279
|
+
name="autoRefreshControl"
|
|
280
|
+
v-bind="autoRefresh"
|
|
281
|
+
>
|
|
282
|
+
<ModelAutoRefreshChip
|
|
283
|
+
v-if="props.autoRefreshControl"
|
|
284
|
+
:control="autoRefresh"
|
|
285
|
+
:color="toolbarColor"
|
|
286
|
+
/>
|
|
287
|
+
</slot>
|
|
269
288
|
</VToolbarTitle>
|
|
270
289
|
</v-col>
|
|
271
290
|
<v-col cols="5">
|
|
@@ -29,6 +29,9 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof VDataIterator['$pr
|
|
|
29
29
|
api?: boolean;
|
|
30
30
|
perPageStorageKey?: string;
|
|
31
31
|
perPageStorageEnabled?: boolean;
|
|
32
|
+
autoRefresh?: number | boolean;
|
|
33
|
+
autoRefreshDefault?: number;
|
|
34
|
+
autoRefreshControl?: boolean;
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
37
|
* Public props accepted by ModelIterator.
|
|
@@ -39,17 +42,18 @@ declare function openDialog(item?: object): void;
|
|
|
39
42
|
declare var __VLS_15: {
|
|
40
43
|
operation: {
|
|
41
44
|
openDialog: typeof openDialog;
|
|
42
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
43
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
44
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
45
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
46
|
-
reload: () => void;
|
|
47
|
-
setSearch: (keyword: string) => void;
|
|
45
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
46
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
47
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
48
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
49
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
50
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
48
51
|
canServerPageable: boolean;
|
|
49
52
|
canServerSearch: boolean;
|
|
50
53
|
canCreate: boolean;
|
|
51
54
|
canUpdate: boolean;
|
|
52
55
|
canDelete: boolean;
|
|
56
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
53
57
|
};
|
|
54
58
|
page: number;
|
|
55
59
|
itemsPerPage: number;
|
|
@@ -75,17 +79,18 @@ declare var __VLS_15: {
|
|
|
75
79
|
item: import("vuetify/lib/components/VDataIterator/composables/items.mjs").DataIteratorItem<Record<string, any>>;
|
|
76
80
|
operation: {
|
|
77
81
|
openDialog: typeof openDialog;
|
|
78
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
79
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
80
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
81
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
82
|
-
reload: () => void;
|
|
83
|
-
setSearch: (keyword: string) => void;
|
|
82
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
83
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
84
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
85
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
86
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
87
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
84
88
|
canServerPageable: boolean;
|
|
85
89
|
canServerSearch: boolean;
|
|
86
90
|
canCreate: boolean;
|
|
87
91
|
canUpdate: boolean;
|
|
88
92
|
canDelete: boolean;
|
|
93
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
89
94
|
};
|
|
90
95
|
}, __VLS_38: {
|
|
91
96
|
color: string | undefined;
|
|
@@ -94,17 +99,18 @@ declare var __VLS_15: {
|
|
|
94
99
|
items: Record<string, any>[];
|
|
95
100
|
operation: {
|
|
96
101
|
openDialog: typeof openDialog;
|
|
97
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
98
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
99
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
100
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
101
|
-
reload: () => void;
|
|
102
|
-
setSearch: (keyword: string) => void;
|
|
102
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
103
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
104
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
105
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
106
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
107
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
103
108
|
canServerPageable: boolean;
|
|
104
109
|
canServerSearch: boolean;
|
|
105
110
|
canCreate: boolean;
|
|
106
111
|
canUpdate: boolean;
|
|
107
112
|
canDelete: boolean;
|
|
113
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
108
114
|
};
|
|
109
115
|
page: number;
|
|
110
116
|
itemsPerPage: number;
|
|
@@ -127,73 +133,87 @@ declare var __VLS_15: {
|
|
|
127
133
|
groupedItems: readonly (import("vuetify/lib/components/VDataIterator/composables/items.mjs").DataIteratorItem<Record<string, any>> | import("vuetify/lib/components/VDataTable/composables/group.mjs").Group<import("vuetify/lib/components/VDataIterator/composables/items.mjs").DataIteratorItem<Record<string, any>>> | import("vuetify/lib/components/VDataTable/composables/group.mjs").GroupSummary<import("vuetify/lib/components/VDataIterator/composables/items.mjs").DataIteratorItem<Record<string, any>>>)[];
|
|
128
134
|
}, __VLS_92: {
|
|
129
135
|
reload: () => void;
|
|
130
|
-
},
|
|
136
|
+
}, __VLS_102: {
|
|
137
|
+
enabled: import("vue").ComputedRef<boolean>;
|
|
138
|
+
isActive: import("vue").ComputedRef<boolean>;
|
|
139
|
+
isLoading: import("vue").ComputedRef<boolean>;
|
|
140
|
+
intervalSeconds: import("vue").ComputedRef<number>;
|
|
141
|
+
remainingSeconds: import("vue").Ref<number>;
|
|
142
|
+
isUserPaused: import("vue").Ref<boolean>;
|
|
143
|
+
togglePause: () => void;
|
|
144
|
+
reset: () => void;
|
|
145
|
+
reload: () => void | Promise<void>;
|
|
146
|
+
}, __VLS_115: {
|
|
131
147
|
items: Record<string, any>[];
|
|
132
148
|
operation: {
|
|
133
149
|
openDialog: typeof openDialog;
|
|
134
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
135
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
136
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
137
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
138
|
-
reload: () => void;
|
|
139
|
-
setSearch: (keyword: string) => void;
|
|
150
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
151
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
152
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
153
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
154
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
155
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
140
156
|
canServerPageable: boolean;
|
|
141
157
|
canServerSearch: boolean;
|
|
142
158
|
canCreate: boolean;
|
|
143
159
|
canUpdate: boolean;
|
|
144
160
|
canDelete: boolean;
|
|
161
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
145
162
|
};
|
|
146
|
-
},
|
|
163
|
+
}, __VLS_128: {
|
|
147
164
|
items: Record<string, any>[];
|
|
148
165
|
operation: {
|
|
149
166
|
openDialog: typeof openDialog;
|
|
150
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
151
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
152
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
153
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
154
|
-
reload: () => void;
|
|
155
|
-
setSearch: (keyword: string) => void;
|
|
167
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
168
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
169
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
170
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
171
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
172
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
156
173
|
canServerPageable: boolean;
|
|
157
174
|
canServerSearch: boolean;
|
|
158
175
|
canCreate: boolean;
|
|
159
176
|
canUpdate: boolean;
|
|
160
177
|
canDelete: boolean;
|
|
178
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
161
179
|
};
|
|
162
|
-
},
|
|
180
|
+
}, __VLS_182: never, __VLS_183: {
|
|
163
181
|
operation: {
|
|
164
182
|
openDialog: typeof openDialog;
|
|
165
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
166
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
167
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
168
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
169
|
-
reload: () => void;
|
|
170
|
-
setSearch: (keyword: string) => void;
|
|
183
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
184
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
185
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
186
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
187
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
188
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
171
189
|
canServerPageable: boolean;
|
|
172
190
|
canServerSearch: boolean;
|
|
173
191
|
canCreate: boolean;
|
|
174
192
|
canUpdate: boolean;
|
|
175
193
|
canDelete: boolean;
|
|
194
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
176
195
|
};
|
|
177
|
-
},
|
|
196
|
+
}, __VLS_208: never, __VLS_209: {
|
|
178
197
|
operation: {
|
|
179
198
|
openDialog: typeof openDialog;
|
|
180
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
181
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
182
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
183
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
184
|
-
reload: () => void;
|
|
185
|
-
setSearch: (keyword: string) => void;
|
|
199
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
200
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
201
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
202
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
203
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
204
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
186
205
|
canServerPageable: boolean;
|
|
187
206
|
canServerSearch: boolean;
|
|
188
207
|
canCreate: boolean;
|
|
189
208
|
canUpdate: boolean;
|
|
190
209
|
canDelete: boolean;
|
|
210
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
191
211
|
};
|
|
192
|
-
},
|
|
212
|
+
}, __VLS_277: any;
|
|
193
213
|
type __VLS_Slots = {} & {
|
|
194
|
-
[K in NonNullable<typeof
|
|
214
|
+
[K in NonNullable<typeof __VLS_182>]?: (props: typeof __VLS_183) => any;
|
|
195
215
|
} & {
|
|
196
|
-
[K in NonNullable<typeof
|
|
216
|
+
[K in NonNullable<typeof __VLS_208>]?: (props: typeof __VLS_209) => any;
|
|
197
217
|
} & {
|
|
198
218
|
default?: (props: typeof __VLS_15) => any;
|
|
199
219
|
} & {
|
|
@@ -207,11 +227,13 @@ type __VLS_Slots = {} & {
|
|
|
207
227
|
} & {
|
|
208
228
|
title?: (props: typeof __VLS_92) => any;
|
|
209
229
|
} & {
|
|
210
|
-
|
|
230
|
+
autoRefreshControl?: (props: typeof __VLS_102) => any;
|
|
211
231
|
} & {
|
|
212
|
-
|
|
232
|
+
search?: (props: typeof __VLS_115) => any;
|
|
213
233
|
} & {
|
|
214
|
-
|
|
234
|
+
toolbarItems?: (props: typeof __VLS_128) => any;
|
|
235
|
+
} & {
|
|
236
|
+
form?: (props: typeof __VLS_277) => any;
|
|
215
237
|
};
|
|
216
238
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
217
239
|
noDataText: string;
|
|
@@ -235,48 +257,55 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
235
257
|
itemsPerPage: number;
|
|
236
258
|
api: boolean;
|
|
237
259
|
perPageStorageEnabled: boolean;
|
|
260
|
+
autoRefresh: boolean;
|
|
261
|
+
autoRefreshDefault: number;
|
|
262
|
+
autoRefreshControl: boolean;
|
|
238
263
|
}>>, {
|
|
239
|
-
reload: () => void;
|
|
264
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
240
265
|
operation: import("vue").Ref<{
|
|
241
266
|
openDialog: typeof openDialog;
|
|
242
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
243
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
244
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
245
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
246
|
-
reload: () => void;
|
|
247
|
-
setSearch: (keyword: string) => void;
|
|
267
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
268
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
269
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
270
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
271
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
272
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
248
273
|
canServerPageable: boolean;
|
|
249
274
|
canServerSearch: boolean;
|
|
250
275
|
canCreate: boolean;
|
|
251
276
|
canUpdate: boolean;
|
|
252
277
|
canDelete: boolean;
|
|
278
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
253
279
|
}, {
|
|
254
280
|
openDialog: typeof openDialog;
|
|
255
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
256
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
257
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
258
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
259
|
-
reload: () => void;
|
|
260
|
-
setSearch: (keyword: string) => void;
|
|
281
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
282
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
283
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
284
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
285
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
286
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
261
287
|
canServerPageable: import("vue").ComputedRef<boolean>;
|
|
262
288
|
canServerSearch: import("vue").ComputedRef<boolean>;
|
|
263
289
|
canCreate: import("vue").ComputedRef<boolean>;
|
|
264
290
|
canUpdate: import("vue").ComputedRef<boolean>;
|
|
265
291
|
canDelete: import("vue").ComputedRef<boolean>;
|
|
292
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
266
293
|
} | {
|
|
267
294
|
openDialog: typeof openDialog;
|
|
268
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
269
|
-
importItems: (importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void;
|
|
270
|
-
updateItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
271
|
-
deleteItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any
|
|
272
|
-
reload: () => void;
|
|
273
|
-
setSearch: (keyword: string) => void;
|
|
295
|
+
createItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any>);
|
|
296
|
+
importItems: ((importItems: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importItemsList: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
297
|
+
updateItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<void>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
298
|
+
deleteItem: ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>) | ((item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback) => Promise<any>);
|
|
299
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
300
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
274
301
|
canServerPageable: boolean;
|
|
275
302
|
canServerSearch: boolean;
|
|
276
303
|
canCreate: boolean;
|
|
277
304
|
canUpdate: boolean;
|
|
278
305
|
canDelete: boolean;
|
|
306
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
279
307
|
}>;
|
|
308
|
+
autoRefresh: import("../../composables/autoRefresh.js").UseAutoRefreshHandle;
|
|
280
309
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
281
310
|
noDataText: string;
|
|
282
311
|
dialogFullscreen: boolean;
|
|
@@ -299,6 +328,9 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
299
328
|
itemsPerPage: number;
|
|
300
329
|
api: boolean;
|
|
301
330
|
perPageStorageEnabled: boolean;
|
|
331
|
+
autoRefresh: boolean;
|
|
332
|
+
autoRefreshDefault: number;
|
|
333
|
+
autoRefreshControl: boolean;
|
|
302
334
|
}>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
303
335
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
304
336
|
declare const _default: typeof __VLS_export;
|
|
@@ -34,7 +34,7 @@ export declare function useApiModel<T extends ApiModelComposableProps>(props: T)
|
|
|
34
34
|
importItems: (importItemsList: Record<string, any>[], callback?: FormDialogCallback) => void;
|
|
35
35
|
updateItem: (item: Record<string, any>, callback?: FormDialogCallback) => Promise<any>;
|
|
36
36
|
deleteItem: (item: Record<string, any>, callback?: FormDialogCallback) => Promise<any>;
|
|
37
|
-
loadItems: (options: any) => void
|
|
38
|
-
reload: () => void
|
|
37
|
+
loadItems: (options: any) => Promise<void>;
|
|
38
|
+
reload: () => Promise<void>;
|
|
39
39
|
isLoading: import("vue").Ref<boolean, boolean>;
|
|
40
40
|
};
|
|
@@ -119,7 +119,7 @@ export function useApiModel(props) {
|
|
|
119
119
|
function loadItems(options) {
|
|
120
120
|
currentOptions.value = options;
|
|
121
121
|
isLoading.value = true;
|
|
122
|
-
ops.value.readPageable(
|
|
122
|
+
return ops.value.readPageable(
|
|
123
123
|
fields.value,
|
|
124
124
|
props.modelBy,
|
|
125
125
|
{
|
|
@@ -140,10 +140,10 @@ export function useApiModel(props) {
|
|
|
140
140
|
}
|
|
141
141
|
function reload() {
|
|
142
142
|
if (currentOptions.value) {
|
|
143
|
-
loadItems(currentOptions.value);
|
|
143
|
+
return loadItems(currentOptions.value);
|
|
144
144
|
} else {
|
|
145
145
|
isLoading.value = true;
|
|
146
|
-
ops.value.read(
|
|
146
|
+
return ops.value.read(
|
|
147
147
|
fields.value,
|
|
148
148
|
props.modelBy
|
|
149
149
|
).then((result) => {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-refresh composable: drives a countdown that fires a `reload()` at a configurable
|
|
3
|
+
* interval (in seconds), with four pause sources — document visibility, external paused
|
|
4
|
+
* ref, in-flight loading, and user toggle. Designed for `<ModelTable>` and
|
|
5
|
+
* `<ModelIterator>` but composable-shaped so any consumer can use it.
|
|
6
|
+
*/
|
|
7
|
+
import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
8
|
+
export interface UseAutoRefreshOptions {
|
|
9
|
+
/** Polling interval. Number ⇒ seconds. `true` ⇒ `defaultSeconds`. Falsy ⇒ disabled. */
|
|
10
|
+
interval: MaybeRefOrGetter<number | boolean | undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* Function called when a tick fires. If it returns a Promise it is awaited before the
|
|
13
|
+
* countdown resets, so the next cycle starts only after the reload has settled (rather
|
|
14
|
+
* than restarting while data is still in flight). Overlapping reloads are prevented by the
|
|
15
|
+
* `isLoading` gate below, which freezes ticks for as long as a request is in flight — wire
|
|
16
|
+
* it for that guarantee, since the per-second timer itself keeps ticking during a slow reload.
|
|
17
|
+
*/
|
|
18
|
+
reload: () => void | Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Optional. While true the countdown freezes and ticks are suppressed. Wire this to the
|
|
21
|
+
* model's loading flag. Note: a model that never clears `isLoading` (e.g. an error path
|
|
22
|
+
* that leaves it set) will halt polling — by design, since polling-while-loading is the
|
|
23
|
+
* thing this gate prevents.
|
|
24
|
+
*/
|
|
25
|
+
isLoading?: Ref<boolean>;
|
|
26
|
+
/** Optional external pause signal (e.g. dialog open). */
|
|
27
|
+
paused?: Ref<boolean>;
|
|
28
|
+
/** Seconds used when `interval === true`. Defaults to 60. */
|
|
29
|
+
defaultSeconds?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface UseAutoRefreshHandle {
|
|
32
|
+
enabled: ComputedRef<boolean>;
|
|
33
|
+
isActive: ComputedRef<boolean>;
|
|
34
|
+
isLoading: ComputedRef<boolean>;
|
|
35
|
+
intervalSeconds: ComputedRef<number>;
|
|
36
|
+
remainingSeconds: Ref<number>;
|
|
37
|
+
isUserPaused: Ref<boolean>;
|
|
38
|
+
togglePause: () => void;
|
|
39
|
+
reset: () => void;
|
|
40
|
+
reload: () => void | Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export declare function useAutoRefresh(opts: UseAutoRefreshOptions): UseAutoRefreshHandle;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { computed, ref, toValue, watch } from "vue";
|
|
2
|
+
import { useDocumentVisibility, useIntervalFn } from "@vueuse/core";
|
|
3
|
+
function resolveInterval(raw, def) {
|
|
4
|
+
if (raw === true) return def;
|
|
5
|
+
if (typeof raw === "number" && raw > 0) return raw;
|
|
6
|
+
return 0;
|
|
7
|
+
}
|
|
8
|
+
export function useAutoRefresh(opts) {
|
|
9
|
+
const documentVisibility = useDocumentVisibility();
|
|
10
|
+
const defaultSeconds = opts.defaultSeconds ?? 60;
|
|
11
|
+
const intervalSeconds = computed(() => resolveInterval(toValue(opts.interval), defaultSeconds));
|
|
12
|
+
const enabled = computed(() => intervalSeconds.value > 0);
|
|
13
|
+
const isUserPaused = ref(false);
|
|
14
|
+
const remainingSeconds = ref(0);
|
|
15
|
+
const isLoadingMirror = computed(() => opts.isLoading?.value === true);
|
|
16
|
+
const paused = computed(
|
|
17
|
+
() => !enabled.value || isUserPaused.value || documentVisibility.value === "hidden" || opts.paused?.value === true || isLoadingMirror.value
|
|
18
|
+
);
|
|
19
|
+
const isActive = computed(() => enabled.value && !paused.value);
|
|
20
|
+
const ticker = useIntervalFn(async () => {
|
|
21
|
+
if (paused.value) return;
|
|
22
|
+
if (remainingSeconds.value <= 1) {
|
|
23
|
+
try {
|
|
24
|
+
await opts.reload();
|
|
25
|
+
} finally {
|
|
26
|
+
remainingSeconds.value = intervalSeconds.value;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
remainingSeconds.value -= 1;
|
|
30
|
+
}
|
|
31
|
+
}, 1e3, { immediate: false });
|
|
32
|
+
watch(enabled, (on) => {
|
|
33
|
+
remainingSeconds.value = on ? intervalSeconds.value : 0;
|
|
34
|
+
}, { immediate: true });
|
|
35
|
+
watch(isActive, (active) => {
|
|
36
|
+
if (active && typeof document !== "undefined") ticker.resume();
|
|
37
|
+
else ticker.pause();
|
|
38
|
+
}, { immediate: true });
|
|
39
|
+
watch(intervalSeconds, (s) => {
|
|
40
|
+
if (enabled.value && remainingSeconds.value > s) remainingSeconds.value = s;
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
enabled,
|
|
44
|
+
isActive,
|
|
45
|
+
isLoading: isLoadingMirror,
|
|
46
|
+
intervalSeconds,
|
|
47
|
+
remainingSeconds,
|
|
48
|
+
isUserPaused,
|
|
49
|
+
togglePause: () => {
|
|
50
|
+
isUserPaused.value = !isUserPaused.value;
|
|
51
|
+
},
|
|
52
|
+
reset: () => {
|
|
53
|
+
remainingSeconds.value = intervalSeconds.value;
|
|
54
|
+
},
|
|
55
|
+
reload: opts.reload
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -4,7 +4,7 @@ import { processTemplateFormHidden } from "./templateFormHidden.js";
|
|
|
4
4
|
import { some, includes, cloneDeep } from "lodash-es";
|
|
5
5
|
import { migrateInputAttributes, migrateTemplateString } from "./templateMigrate.js";
|
|
6
6
|
import { getDocumentTemplateInputTypeEntry } from "./templateInputTypes.js";
|
|
7
|
-
export const validationRulesRegex = /^(require(?:\([^)]*\))?|requireIf\([^)]*\)|requireTrue(?:\([^)]*\))?|requireTrueIf\([^)]*\)|numeric(?:\([^)]*\))?|range\([^)]*\)|integer(?:\([^)]*\))?|unique\([^)]*\)|length(?:\([^)]*\))?|lengthGreater\([^)]*\)|lengthLess\([^)]*\)|telephone(?:\([^)]*\))?|email(?:\([^)]*\))?|regex\([^)]*\)|idcard(?:\([^)]*\))?|DateFuture(?:\([^)]*\))?|DatetimeFuture(?:\([^)]*\))?|DateHappen(?:\([^)]*\))?|DatetimeHappen(?:\([^)]*\))?|DateAfter\([^)]*\)|DateBefore\([^)]*\)|DateEqual\([^)]*\))(,(require(?:\([^)]*\))?|requireIf\([^)]*\)|requireTrue(?:\([^)]*\))?|requireTrueIf\([^)]*\)|numeric(?:\([^)]*\))?|range\([^)]*\)|integer(?:\([^)]*\))?|unique\([^)]*\)|length(?:\([^)]*\))?|lengthGreater\([^)]*\)|lengthLess\([^)]*\)|telephone(?:\([^)]*\))?|email(?:\([^)]*\))?|regex\([^)]*\)|idcard(?:\([^)]*\))?|DateFuture(?:\([^)]*\))?|DatetimeFuture(?:\([^)]*\))?|DateHappen(?:\([^)]*\))?|DatetimeHappen(?:\([^)]*\))?|DateAfter\([^)]*\)|DateBefore\([^)]*\)|DateEqual\([^)]*\)))*$/;
|
|
7
|
+
export const validationRulesRegex = /^(require(?:\([^)]*\))?|requireIf\([^)]*\)|requireTrue(?:\([^)]*\))?|requireTrueIf\([^)]*\)|requireNotEmpty(?:\([^)]*\))?|numeric(?:\([^)]*\))?|range\([^)]*\)|integer(?:\([^)]*\))?|unique\([^)]*\)|length(?:\([^)]*\))?|lengthGreater\([^)]*\)|lengthLess\([^)]*\)|telephone(?:\([^)]*\))?|email(?:\([^)]*\))?|regex\([^)]*\)|idcard(?:\([^)]*\))?|DateFuture(?:\([^)]*\))?|DatetimeFuture(?:\([^)]*\))?|DateHappen(?:\([^)]*\))?|DatetimeHappen(?:\([^)]*\))?|DateAfter\([^)]*\)|DateBefore\([^)]*\)|DateEqual\([^)]*\))(,(require(?:\([^)]*\))?|requireIf\([^)]*\)|requireTrue(?:\([^)]*\))?|requireTrueIf\([^)]*\)|requireNotEmpty(?:\([^)]*\))?|numeric(?:\([^)]*\))?|range\([^)]*\)|integer(?:\([^)]*\))?|unique\([^)]*\)|length(?:\([^)]*\))?|lengthGreater\([^)]*\)|lengthLess\([^)]*\)|telephone(?:\([^)]*\))?|email(?:\([^)]*\))?|regex\([^)]*\)|idcard(?:\([^)]*\))?|DateFuture(?:\([^)]*\))?|DatetimeFuture(?:\([^)]*\))?|DateHappen(?:\([^)]*\))?|DatetimeHappen(?:\([^)]*\))?|DateAfter\([^)]*\)|DateBefore\([^)]*\)|DateEqual\([^)]*\)))*$/;
|
|
8
8
|
export function useDocumentTemplate(items, parentTemplates) {
|
|
9
9
|
if (!items) return "";
|
|
10
10
|
if (typeof items === "string") {
|
|
@@ -29,7 +29,7 @@ export declare function useGraphqlModel<T extends GraphqlModelProps>(props: T):
|
|
|
29
29
|
importItems: (importItems: Record<string, any>[], callback?: FormDialogCallback) => void;
|
|
30
30
|
updateItem: (item: Record<string, any>, callback?: FormDialogCallback) => Promise<void>;
|
|
31
31
|
deleteItem: (item: Record<string, any>, callback?: FormDialogCallback) => Promise<any>;
|
|
32
|
-
loadItems: (options: any) => void;
|
|
33
|
-
reload: () => void;
|
|
32
|
+
loadItems: (options: any) => Promise<void> | undefined;
|
|
33
|
+
reload: () => Promise<void> | undefined;
|
|
34
34
|
isLoading: import("vue").Ref<boolean, boolean>;
|
|
35
35
|
};
|
|
@@ -127,7 +127,7 @@ export function useGraphqlModel(props) {
|
|
|
127
127
|
sortBy: options.sortBy
|
|
128
128
|
};
|
|
129
129
|
isLoading.value = true;
|
|
130
|
-
operationReadPageable.value?.call([{ data: fields.value }, "meta"], Object.assign({}, props.modelBy, { pageable: pageableVariable })).then((result) => {
|
|
130
|
+
return operationReadPageable.value?.call([{ data: fields.value }, "meta"], Object.assign({}, props.modelBy, { pageable: pageableVariable })).then((result) => {
|
|
131
131
|
items.value = result.data;
|
|
132
132
|
itemsLength.value = result.meta.totalItems;
|
|
133
133
|
}).catch((error) => {
|
|
@@ -141,10 +141,10 @@ export function useGraphqlModel(props) {
|
|
|
141
141
|
}
|
|
142
142
|
function reload() {
|
|
143
143
|
if (canServerPageable.value) {
|
|
144
|
-
if (currentOptions.value) loadItems(currentOptions.value);
|
|
144
|
+
if (currentOptions.value) return loadItems(currentOptions.value);
|
|
145
145
|
} else {
|
|
146
146
|
isLoading.value = true;
|
|
147
|
-
operationRead.value?.call(fields.value, props.modelBy).then((result) => {
|
|
147
|
+
return operationRead.value?.call(fields.value, props.modelBy).then((result) => {
|
|
148
148
|
items.value = arrayWrap(result);
|
|
149
149
|
}).catch((error) => {
|
|
150
150
|
items.value = [];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared auto-refresh wiring for `<ModelTable>` and `<ModelIterator>`.
|
|
3
|
+
*
|
|
4
|
+
* Both components expose the same `autoRefresh` / `autoRefreshDefault` / `autoRefreshControl`
|
|
5
|
+
* props and gate polling on the same signals (dialog open + in-flight loading). This helper
|
|
6
|
+
* keeps that contract in one place: pass the model's `reload`/`isLoading` and the dialog-open
|
|
7
|
+
* ref, get back the `useAutoRefresh` handle plus a `manualReload` that reloads and restarts
|
|
8
|
+
* the countdown (used by the toolbar refresh icon).
|
|
9
|
+
*/
|
|
10
|
+
import { type Ref } from 'vue';
|
|
11
|
+
import { type UseAutoRefreshHandle } from './autoRefresh.js';
|
|
12
|
+
export interface ModelAutoRefreshProps {
|
|
13
|
+
autoRefresh?: number | boolean;
|
|
14
|
+
autoRefreshDefault?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface UseModelAutoRefreshDeps {
|
|
17
|
+
/** The model composable's reload(). */
|
|
18
|
+
reload: () => void | Promise<void>;
|
|
19
|
+
/** The model composable's loading flag. */
|
|
20
|
+
isLoading: Ref<boolean>;
|
|
21
|
+
/** Component ref that is true while a create/edit dialog is open. */
|
|
22
|
+
isDialogOpen: Ref<boolean>;
|
|
23
|
+
}
|
|
24
|
+
export interface UseModelAutoRefreshHandle {
|
|
25
|
+
autoRefresh: UseAutoRefreshHandle;
|
|
26
|
+
/** Reload now and restart the countdown — wired to the toolbar refresh icon. */
|
|
27
|
+
manualReload: () => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function useModelAutoRefresh(props: ModelAutoRefreshProps, deps: UseModelAutoRefreshDeps): UseModelAutoRefreshHandle;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useAutoRefresh } from "./autoRefresh.js";
|
|
3
|
+
export function useModelAutoRefresh(props, deps) {
|
|
4
|
+
const autoRefresh = useAutoRefresh({
|
|
5
|
+
interval: () => props.autoRefresh,
|
|
6
|
+
defaultSeconds: props.autoRefreshDefault,
|
|
7
|
+
reload: deps.reload,
|
|
8
|
+
isLoading: deps.isLoading,
|
|
9
|
+
paused: computed(() => deps.isDialogOpen.value)
|
|
10
|
+
});
|
|
11
|
+
function manualReload() {
|
|
12
|
+
deps.reload();
|
|
13
|
+
autoRefresh.reset();
|
|
14
|
+
}
|
|
15
|
+
return { autoRefresh, manualReload };
|
|
16
|
+
}
|