@ramathibodi/nuxt-commons 4.0.11 → 4.0.13
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/dialog/ImportProgress.d.vue.ts +35 -0
- package/dist/runtime/components/dialog/ImportProgress.vue +53 -0
- package/dist/runtime/components/dialog/ImportProgress.vue.d.ts +35 -0
- package/dist/runtime/components/document/TemplateBuilder.d.vue.ts +2 -2
- package/dist/runtime/components/document/TemplateBuilder.vue +113 -8
- 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/Pad.vue +2 -1
- package/dist/runtime/components/model/Table.d.vue.ts +158 -61
- package/dist/runtime/components/model/Table.vue +129 -7
- package/dist/runtime/components/model/Table.vue.d.ts +158 -61
- package/dist/runtime/components/model/iterator.d.vue.ts +198 -78
- package/dist/runtime/components/model/iterator.vue +140 -9
- package/dist/runtime/components/model/iterator.vue.d.ts +198 -78
- package/dist/runtime/composables/apiModel.d.ts +22 -3
- package/dist/runtime/composables/apiModel.js +27 -19
- package/dist/runtime/composables/autoRefresh.d.ts +42 -0
- package/dist/runtime/composables/autoRefresh.js +57 -0
- package/dist/runtime/composables/document/template.d.ts +61 -0
- package/dist/runtime/composables/document/template.js +60 -1
- package/dist/runtime/composables/document/validateTemplate.d.ts +62 -0
- package/dist/runtime/composables/document/validateTemplate.js +378 -0
- package/dist/runtime/composables/graphqlModel.d.ts +22 -3
- package/dist/runtime/composables/graphqlModel.js +27 -19
- package/dist/runtime/composables/graphqlModelOperation.d.ts +1 -0
- package/dist/runtime/composables/importProgress.d.ts +34 -0
- package/dist/runtime/composables/importProgress.js +50 -0
- 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/dist/runtime/utils/virtualize.d.ts +15 -0
- package/dist/runtime/utils/virtualize.js +10 -0
- package/package.json +3 -2
- package/scripts/validate-document-template.mjs +158 -0
|
@@ -29,6 +29,15 @@ 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;
|
|
35
|
+
importConcurrency?: number;
|
|
36
|
+
virtual?: boolean;
|
|
37
|
+
virtualThreshold?: number;
|
|
38
|
+
virtualHeight?: number | string;
|
|
39
|
+
virtualItemHeight?: number;
|
|
40
|
+
virtualItemsPerRow?: number;
|
|
32
41
|
}
|
|
33
42
|
/**
|
|
34
43
|
* Public props accepted by ModelIterator.
|
|
@@ -39,17 +48,18 @@ declare function openDialog(item?: object): void;
|
|
|
39
48
|
declare var __VLS_15: {
|
|
40
49
|
operation: {
|
|
41
50
|
openDialog: typeof openDialog;
|
|
42
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
43
|
-
importItems: (
|
|
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;
|
|
51
|
+
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>);
|
|
52
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
53
|
+
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>);
|
|
54
|
+
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>);
|
|
55
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
56
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
48
57
|
canServerPageable: boolean;
|
|
49
58
|
canServerSearch: boolean;
|
|
50
59
|
canCreate: boolean;
|
|
51
60
|
canUpdate: boolean;
|
|
52
61
|
canDelete: boolean;
|
|
62
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
53
63
|
};
|
|
54
64
|
page: number;
|
|
55
65
|
itemsPerPage: number;
|
|
@@ -75,36 +85,55 @@ declare var __VLS_15: {
|
|
|
75
85
|
item: import("vuetify/lib/components/VDataIterator/composables/items.mjs").DataIteratorItem<Record<string, any>>;
|
|
76
86
|
operation: {
|
|
77
87
|
openDialog: typeof openDialog;
|
|
78
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
79
|
-
importItems: (
|
|
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;
|
|
88
|
+
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>);
|
|
89
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
90
|
+
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>);
|
|
91
|
+
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>);
|
|
92
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
93
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
84
94
|
canServerPageable: boolean;
|
|
85
95
|
canServerSearch: boolean;
|
|
86
96
|
canCreate: boolean;
|
|
87
97
|
canUpdate: boolean;
|
|
88
98
|
canDelete: boolean;
|
|
99
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
89
100
|
};
|
|
90
|
-
},
|
|
101
|
+
}, __VLS_62: {
|
|
102
|
+
item: any;
|
|
103
|
+
operation: {
|
|
104
|
+
openDialog: typeof openDialog;
|
|
105
|
+
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>);
|
|
106
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
107
|
+
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>);
|
|
108
|
+
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>);
|
|
109
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
110
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
111
|
+
canServerPageable: boolean;
|
|
112
|
+
canServerSearch: boolean;
|
|
113
|
+
canCreate: boolean;
|
|
114
|
+
canUpdate: boolean;
|
|
115
|
+
canDelete: boolean;
|
|
116
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
117
|
+
};
|
|
118
|
+
}, __VLS_65: {
|
|
91
119
|
color: string | undefined;
|
|
92
120
|
isActive: boolean;
|
|
93
|
-
},
|
|
121
|
+
}, __VLS_85: {}, __VLS_93: {
|
|
94
122
|
items: Record<string, any>[];
|
|
95
123
|
operation: {
|
|
96
124
|
openDialog: typeof openDialog;
|
|
97
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
98
|
-
importItems: (
|
|
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;
|
|
125
|
+
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>);
|
|
126
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
127
|
+
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>);
|
|
128
|
+
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>);
|
|
129
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
130
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
103
131
|
canServerPageable: boolean;
|
|
104
132
|
canServerSearch: boolean;
|
|
105
133
|
canCreate: boolean;
|
|
106
134
|
canUpdate: boolean;
|
|
107
135
|
canDelete: boolean;
|
|
136
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
108
137
|
};
|
|
109
138
|
page: number;
|
|
110
139
|
itemsPerPage: number;
|
|
@@ -125,93 +154,138 @@ declare var __VLS_15: {
|
|
|
125
154
|
toggleGroup: ReturnType<typeof import("vuetify/lib/components/VDataTable/composables/group.mjs").provideGroupBy>["toggleGroup"];
|
|
126
155
|
itemsCount: number;
|
|
127
156
|
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
|
-
},
|
|
157
|
+
}, __VLS_119: {
|
|
129
158
|
reload: () => void;
|
|
130
|
-
},
|
|
159
|
+
}, __VLS_129: {
|
|
160
|
+
enabled: import("vue").ComputedRef<boolean>;
|
|
161
|
+
isActive: import("vue").ComputedRef<boolean>;
|
|
162
|
+
isLoading: import("vue").ComputedRef<boolean>;
|
|
163
|
+
intervalSeconds: import("vue").ComputedRef<number>;
|
|
164
|
+
remainingSeconds: import("vue").Ref<number>;
|
|
165
|
+
isUserPaused: import("vue").Ref<boolean>;
|
|
166
|
+
togglePause: () => void;
|
|
167
|
+
reset: () => void;
|
|
168
|
+
reload: () => void | Promise<void>;
|
|
169
|
+
}, __VLS_142: {
|
|
131
170
|
items: Record<string, any>[];
|
|
132
171
|
operation: {
|
|
133
172
|
openDialog: typeof openDialog;
|
|
134
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
135
|
-
importItems: (
|
|
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;
|
|
173
|
+
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>);
|
|
174
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
175
|
+
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>);
|
|
176
|
+
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>);
|
|
177
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
178
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
140
179
|
canServerPageable: boolean;
|
|
141
180
|
canServerSearch: boolean;
|
|
142
181
|
canCreate: boolean;
|
|
143
182
|
canUpdate: boolean;
|
|
144
183
|
canDelete: boolean;
|
|
184
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
145
185
|
};
|
|
146
|
-
},
|
|
186
|
+
}, __VLS_155: {
|
|
147
187
|
items: Record<string, any>[];
|
|
148
188
|
operation: {
|
|
149
189
|
openDialog: typeof openDialog;
|
|
150
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
151
|
-
importItems: (
|
|
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;
|
|
190
|
+
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>);
|
|
191
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
192
|
+
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>);
|
|
193
|
+
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>);
|
|
194
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
195
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
156
196
|
canServerPageable: boolean;
|
|
157
197
|
canServerSearch: boolean;
|
|
158
198
|
canCreate: boolean;
|
|
159
199
|
canUpdate: boolean;
|
|
160
200
|
canDelete: boolean;
|
|
201
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
161
202
|
};
|
|
162
|
-
},
|
|
203
|
+
}, __VLS_209: never, __VLS_210: {
|
|
163
204
|
operation: {
|
|
164
205
|
openDialog: typeof openDialog;
|
|
165
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
166
|
-
importItems: (
|
|
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;
|
|
206
|
+
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>);
|
|
207
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
208
|
+
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>);
|
|
209
|
+
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>);
|
|
210
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
211
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
171
212
|
canServerPageable: boolean;
|
|
172
213
|
canServerSearch: boolean;
|
|
173
214
|
canCreate: boolean;
|
|
174
215
|
canUpdate: boolean;
|
|
175
216
|
canDelete: boolean;
|
|
217
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
176
218
|
};
|
|
177
|
-
},
|
|
219
|
+
}, __VLS_235: never, __VLS_236: {
|
|
178
220
|
operation: {
|
|
179
221
|
openDialog: typeof openDialog;
|
|
180
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
181
|
-
importItems: (
|
|
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;
|
|
222
|
+
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>);
|
|
223
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
224
|
+
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>);
|
|
225
|
+
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>);
|
|
226
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
227
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
186
228
|
canServerPageable: boolean;
|
|
187
229
|
canServerSearch: boolean;
|
|
188
230
|
canCreate: boolean;
|
|
189
231
|
canUpdate: boolean;
|
|
190
232
|
canDelete: boolean;
|
|
233
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
191
234
|
};
|
|
192
|
-
},
|
|
235
|
+
}, __VLS_261: never, __VLS_262: {
|
|
236
|
+
operation: {
|
|
237
|
+
openDialog: typeof openDialog;
|
|
238
|
+
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>);
|
|
239
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
240
|
+
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>);
|
|
241
|
+
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>);
|
|
242
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
243
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
244
|
+
canServerPageable: boolean;
|
|
245
|
+
canServerSearch: boolean;
|
|
246
|
+
canCreate: boolean;
|
|
247
|
+
canUpdate: boolean;
|
|
248
|
+
canDelete: boolean;
|
|
249
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
250
|
+
};
|
|
251
|
+
}, __VLS_330: any, __VLS_332: {
|
|
252
|
+
isImporting: boolean;
|
|
253
|
+
total: number;
|
|
254
|
+
processed: number;
|
|
255
|
+
succeeded: number;
|
|
256
|
+
failed: number;
|
|
257
|
+
percent: number;
|
|
258
|
+
};
|
|
193
259
|
type __VLS_Slots = {} & {
|
|
194
|
-
[K in NonNullable<typeof
|
|
260
|
+
[K in NonNullable<typeof __VLS_209>]?: (props: typeof __VLS_210) => any;
|
|
261
|
+
} & {
|
|
262
|
+
[K in NonNullable<typeof __VLS_235>]?: (props: typeof __VLS_236) => any;
|
|
195
263
|
} & {
|
|
196
|
-
[K in NonNullable<typeof
|
|
264
|
+
[K in NonNullable<typeof __VLS_261>]?: (props: typeof __VLS_262) => any;
|
|
197
265
|
} & {
|
|
198
266
|
default?: (props: typeof __VLS_15) => any;
|
|
199
267
|
} & {
|
|
200
268
|
item?: (props: typeof __VLS_35) => any;
|
|
201
269
|
} & {
|
|
202
|
-
|
|
270
|
+
item?: (props: typeof __VLS_62) => any;
|
|
203
271
|
} & {
|
|
204
|
-
|
|
272
|
+
loader?: (props: typeof __VLS_65) => any;
|
|
205
273
|
} & {
|
|
206
|
-
|
|
274
|
+
loaderItem?: (props: typeof __VLS_85) => any;
|
|
207
275
|
} & {
|
|
208
|
-
|
|
276
|
+
header?: (props: typeof __VLS_93) => any;
|
|
209
277
|
} & {
|
|
210
|
-
|
|
278
|
+
title?: (props: typeof __VLS_119) => any;
|
|
211
279
|
} & {
|
|
212
|
-
|
|
280
|
+
autoRefreshControl?: (props: typeof __VLS_129) => any;
|
|
213
281
|
} & {
|
|
214
|
-
|
|
282
|
+
search?: (props: typeof __VLS_142) => any;
|
|
283
|
+
} & {
|
|
284
|
+
toolbarItems?: (props: typeof __VLS_155) => any;
|
|
285
|
+
} & {
|
|
286
|
+
form?: (props: typeof __VLS_330) => any;
|
|
287
|
+
} & {
|
|
288
|
+
importProgress?: (props: typeof __VLS_332) => any;
|
|
215
289
|
};
|
|
216
290
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
217
291
|
noDataText: string;
|
|
@@ -235,48 +309,85 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
235
309
|
itemsPerPage: number;
|
|
236
310
|
api: boolean;
|
|
237
311
|
perPageStorageEnabled: boolean;
|
|
312
|
+
autoRefresh: boolean;
|
|
313
|
+
autoRefreshDefault: number;
|
|
314
|
+
autoRefreshControl: boolean;
|
|
315
|
+
importConcurrency: number;
|
|
316
|
+
virtual: undefined;
|
|
317
|
+
virtualThreshold: number;
|
|
318
|
+
virtualHeight: string;
|
|
319
|
+
virtualItemHeight: number;
|
|
320
|
+
virtualItemsPerRow: undefined;
|
|
238
321
|
}>>, {
|
|
239
|
-
reload: () => void;
|
|
322
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
240
323
|
operation: import("vue").Ref<{
|
|
241
324
|
openDialog: typeof openDialog;
|
|
242
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
243
|
-
importItems: (
|
|
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;
|
|
325
|
+
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>);
|
|
326
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
327
|
+
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>);
|
|
328
|
+
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>);
|
|
329
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
330
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
248
331
|
canServerPageable: boolean;
|
|
249
332
|
canServerSearch: boolean;
|
|
250
333
|
canCreate: boolean;
|
|
251
334
|
canUpdate: boolean;
|
|
252
335
|
canDelete: boolean;
|
|
336
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
253
337
|
}, {
|
|
254
338
|
openDialog: typeof openDialog;
|
|
255
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
256
|
-
importItems: (
|
|
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;
|
|
339
|
+
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>);
|
|
340
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
341
|
+
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>);
|
|
342
|
+
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>);
|
|
343
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
344
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
261
345
|
canServerPageable: import("vue").ComputedRef<boolean>;
|
|
262
346
|
canServerSearch: import("vue").ComputedRef<boolean>;
|
|
263
347
|
canCreate: import("vue").ComputedRef<boolean>;
|
|
264
348
|
canUpdate: import("vue").ComputedRef<boolean>;
|
|
265
349
|
canDelete: import("vue").ComputedRef<boolean>;
|
|
350
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
266
351
|
} | {
|
|
267
352
|
openDialog: typeof openDialog;
|
|
268
|
-
createItem: (item: Record<string, any>, callback?: import("../../types/formDialog.js").FormDialogCallback, importing?: boolean) => Promise<any
|
|
269
|
-
importItems: (
|
|
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;
|
|
353
|
+
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>);
|
|
354
|
+
importItems: ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void) | ((importData: Record<string, any>[], callback?: import("../../types/formDialog.js").FormDialogCallback) => void);
|
|
355
|
+
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>);
|
|
356
|
+
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>);
|
|
357
|
+
reload: (() => Promise<void> | undefined) | (() => Promise<void>);
|
|
358
|
+
setSearch: ((keyword: string) => void) | ((keyword: string) => void);
|
|
274
359
|
canServerPageable: boolean;
|
|
275
360
|
canServerSearch: boolean;
|
|
276
361
|
canCreate: boolean;
|
|
277
362
|
canUpdate: boolean;
|
|
278
363
|
canDelete: boolean;
|
|
364
|
+
autoRefresh: import("vue").Raw<import("../../composables/autoRefresh.js").UseAutoRefreshHandle>;
|
|
279
365
|
}>;
|
|
366
|
+
autoRefresh: import("../../composables/autoRefresh.js").UseAutoRefreshHandle;
|
|
367
|
+
importProgress: {
|
|
368
|
+
isImporting: import("vue").Ref<boolean, boolean>;
|
|
369
|
+
total: import("vue").Ref<number, number>;
|
|
370
|
+
processed: import("vue").Ref<number, number>;
|
|
371
|
+
succeeded: import("vue").Ref<number, number>;
|
|
372
|
+
failed: import("vue").Ref<number, number>;
|
|
373
|
+
errors: import("vue").Ref<{
|
|
374
|
+
index: number;
|
|
375
|
+
message: string;
|
|
376
|
+
}[], import("../../composables/importProgress.js").ImportError[] | {
|
|
377
|
+
index: number;
|
|
378
|
+
message: string;
|
|
379
|
+
}[]>;
|
|
380
|
+
percent: import("vue").ComputedRef<number>;
|
|
381
|
+
reset: () => void;
|
|
382
|
+
run: <T = any>(items: T[], worker: import("../../composables/importProgress.js").ImportWorker<T>, options?: {
|
|
383
|
+
concurrency
|
|
384
|
+
/**
|
|
385
|
+
* ModelIterator connects model metadata to reusable selection, labeling, iterator, or table UI patterns.
|
|
386
|
+
* This doc block is consumed by vue-docgen for generated API documentation.
|
|
387
|
+
*/
|
|
388
|
+
?: number;
|
|
389
|
+
}) => Promise<import("../../composables/importProgress.js").ImportSummary>;
|
|
390
|
+
};
|
|
280
391
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_Props>, {
|
|
281
392
|
noDataText: string;
|
|
282
393
|
dialogFullscreen: boolean;
|
|
@@ -299,6 +410,15 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
299
410
|
itemsPerPage: number;
|
|
300
411
|
api: boolean;
|
|
301
412
|
perPageStorageEnabled: boolean;
|
|
413
|
+
autoRefresh: boolean;
|
|
414
|
+
autoRefreshDefault: number;
|
|
415
|
+
autoRefreshControl: boolean;
|
|
416
|
+
importConcurrency: number;
|
|
417
|
+
virtual: undefined;
|
|
418
|
+
virtualThreshold: number;
|
|
419
|
+
virtualHeight: string;
|
|
420
|
+
virtualItemHeight: number;
|
|
421
|
+
virtualItemsPerRow: undefined;
|
|
302
422
|
}>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
303
423
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
304
424
|
declare const _default: typeof __VLS_export;
|
|
@@ -31,10 +31,29 @@ export declare function useApiModel<T extends ApiModelComposableProps>(props: T)
|
|
|
31
31
|
canUpdate: import("vue").ComputedRef<boolean>;
|
|
32
32
|
canDelete: import("vue").ComputedRef<boolean>;
|
|
33
33
|
createItem: (item: Record<string, any>, callback?: FormDialogCallback, importing?: boolean) => Promise<any>;
|
|
34
|
-
importItems: (
|
|
34
|
+
importItems: (importData: 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
|
+
importProgress: {
|
|
41
|
+
isImporting: import("vue").Ref<boolean, boolean>;
|
|
42
|
+
total: import("vue").Ref<number, number>;
|
|
43
|
+
processed: import("vue").Ref<number, number>;
|
|
44
|
+
succeeded: import("vue").Ref<number, number>;
|
|
45
|
+
failed: import("vue").Ref<number, number>;
|
|
46
|
+
errors: import("vue").Ref<{
|
|
47
|
+
index: number;
|
|
48
|
+
message: string;
|
|
49
|
+
}[], import("./importProgress.js").ImportError[] | {
|
|
50
|
+
index: number;
|
|
51
|
+
message: string;
|
|
52
|
+
}[]>;
|
|
53
|
+
percent: import("vue").ComputedRef<number>;
|
|
54
|
+
reset: () => void;
|
|
55
|
+
run: <T_1 = any>(items: T_1[], worker: import("./importProgress.js").ImportWorker<T_1>, options?: {
|
|
56
|
+
concurrency?: number;
|
|
57
|
+
}) => Promise<import("./importProgress.js").ImportSummary>;
|
|
58
|
+
};
|
|
40
59
|
};
|
|
@@ -3,7 +3,7 @@ import { watchDebounced } from "@vueuse/core";
|
|
|
3
3
|
import { useAlert } from "./alert.js";
|
|
4
4
|
import { useApiModelOperation } from "./apiModelOperation.js";
|
|
5
5
|
import { arrayWrap } from "../utils/array.js";
|
|
6
|
-
import
|
|
6
|
+
import { useImportProgress } from "./importProgress.js";
|
|
7
7
|
export function stripModelByQualifier(modelName) {
|
|
8
8
|
return modelName.split("By")[0].trim();
|
|
9
9
|
}
|
|
@@ -20,6 +20,7 @@ export function useApiModel(props) {
|
|
|
20
20
|
const search = ref();
|
|
21
21
|
const currentOptions = ref();
|
|
22
22
|
const isLoading = ref(false);
|
|
23
|
+
const importProgress = useImportProgress();
|
|
23
24
|
function setSearch(keyword) {
|
|
24
25
|
search.value = keyword;
|
|
25
26
|
}
|
|
@@ -60,27 +61,33 @@ export function useApiModel(props) {
|
|
|
60
61
|
if (callback && callback.setData) callback.setData(result);
|
|
61
62
|
return result;
|
|
62
63
|
}).catch((error) => {
|
|
64
|
+
if (importing) throw error;
|
|
63
65
|
alert?.addAlert({ alertType: "error", message: error?.message || String(error) });
|
|
64
66
|
}).finally(() => {
|
|
65
67
|
if (!importing) isLoading.value = false;
|
|
66
68
|
if (callback) callback.done();
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
|
-
function importItems(
|
|
71
|
+
function importItems(importData, callback) {
|
|
72
|
+
if (importProgress.isImporting.value) return;
|
|
73
|
+
if (importData.length === 0) {
|
|
74
|
+
if (callback) callback.done();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
70
77
|
isLoading.value = true;
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
(item) =>
|
|
74
|
-
()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
const worker = (item) => {
|
|
79
|
+
const createAsNew = () => createItem(Object.assign({}, props.initialData, item), void 0, true);
|
|
80
|
+
return item[props.modelKey || "id"] ? updateItem(item, void 0).then((result) => {
|
|
81
|
+
if (!result) return createAsNew();
|
|
82
|
+
}) : createAsNew();
|
|
83
|
+
};
|
|
84
|
+
importProgress.run(importData, worker, { concurrency: props.importConcurrency }).then(({ succeeded, failed }) => {
|
|
85
|
+
if (failed > 0) {
|
|
86
|
+
alert?.addAlert({ alertType: "warning", message: `\u0E19\u0E33\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E33\u0E40\u0E23\u0E47\u0E08 ${succeeded} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23, \u0E25\u0E49\u0E21\u0E40\u0E2B\u0E25\u0E27 ${failed} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23` });
|
|
87
|
+
} else {
|
|
88
|
+
alert?.addAlert({ alertType: "success", message: `\u0E19\u0E33\u0E40\u0E02\u0E49\u0E32\u0E2A\u0E33\u0E40\u0E23\u0E47\u0E08 ${succeeded} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23` });
|
|
89
|
+
}
|
|
90
|
+
}).finally(() => {
|
|
84
91
|
isLoading.value = false;
|
|
85
92
|
reload();
|
|
86
93
|
if (callback) callback.done();
|
|
@@ -119,7 +126,7 @@ export function useApiModel(props) {
|
|
|
119
126
|
function loadItems(options) {
|
|
120
127
|
currentOptions.value = options;
|
|
121
128
|
isLoading.value = true;
|
|
122
|
-
ops.value.readPageable(
|
|
129
|
+
return ops.value.readPageable(
|
|
123
130
|
fields.value,
|
|
124
131
|
props.modelBy,
|
|
125
132
|
{
|
|
@@ -140,10 +147,10 @@ export function useApiModel(props) {
|
|
|
140
147
|
}
|
|
141
148
|
function reload() {
|
|
142
149
|
if (currentOptions.value) {
|
|
143
|
-
loadItems(currentOptions.value);
|
|
150
|
+
return loadItems(currentOptions.value);
|
|
144
151
|
} else {
|
|
145
152
|
isLoading.value = true;
|
|
146
|
-
ops.value.read(
|
|
153
|
+
return ops.value.read(
|
|
147
154
|
fields.value,
|
|
148
155
|
props.modelBy
|
|
149
156
|
).then((result) => {
|
|
@@ -180,6 +187,7 @@ export function useApiModel(props) {
|
|
|
180
187
|
deleteItem,
|
|
181
188
|
loadItems,
|
|
182
189
|
reload,
|
|
183
|
-
isLoading
|
|
190
|
+
isLoading,
|
|
191
|
+
importProgress
|
|
184
192
|
};
|
|
185
193
|
}
|
|
@@ -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;
|