@ramathibodi/nuxt-commons 0.1.31 → 0.1.33
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/form/Iterator.vue +6 -3
- package/dist/runtime/components/form/Table.vue +37 -34
- package/dist/runtime/components/form/images/Field.vue +1 -2
- package/dist/runtime/components/model/iterator.vue +2 -2
- package/dist/runtime/composables/document/template.js +1 -1
- package/dist/runtime/composables/graphqlModel.js +10 -11
- package/package.json +3 -2
package/dist/module.json
CHANGED
|
@@ -19,6 +19,7 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof VDataIterator['$pr
|
|
|
19
19
|
toolbarColor?: string
|
|
20
20
|
importable?: boolean
|
|
21
21
|
exportable?: boolean
|
|
22
|
+
insertable?: boolean
|
|
22
23
|
|
|
23
24
|
viewSwitch?: boolean
|
|
24
25
|
viewSwitchMultiple?: boolean
|
|
@@ -39,6 +40,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
39
40
|
toolbarColor: 'primary',
|
|
40
41
|
importable: true,
|
|
41
42
|
exportable: true,
|
|
43
|
+
insertable: true,
|
|
42
44
|
|
|
43
45
|
viewSwitch: false,
|
|
44
46
|
viewSwitchMultiple:false,
|
|
@@ -46,8 +48,8 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
46
48
|
cols: 12,
|
|
47
49
|
xxl: false,
|
|
48
50
|
xl: false,
|
|
49
|
-
lg:
|
|
50
|
-
md:
|
|
51
|
+
lg: 2,
|
|
52
|
+
md: 4,
|
|
51
53
|
sm: 6,
|
|
52
54
|
itemsPerPage: 12,
|
|
53
55
|
})
|
|
@@ -308,6 +310,7 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
|
|
|
308
310
|
:color="toolbarColor"
|
|
309
311
|
/>
|
|
310
312
|
<VBtn
|
|
313
|
+
v-if="props.insertable"
|
|
311
314
|
:color="toolbarColor"
|
|
312
315
|
prepend-icon="mdi:mdi-plus"
|
|
313
316
|
variant="flat"
|
|
@@ -316,7 +319,7 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
|
|
|
316
319
|
add
|
|
317
320
|
</VBtn>
|
|
318
321
|
<v-row align="center" class="mr-2 ml-2" v-if="viewSwitch">
|
|
319
|
-
<v-btn-toggle v-model="viewType" :multiple="viewSwitchMultiple">
|
|
322
|
+
<v-btn-toggle v-model="viewType" :multiple="viewSwitchMultiple" mandatory>
|
|
320
323
|
<v-btn icon="mdi mdi-view-grid-outline" value="iterator"></v-btn>
|
|
321
324
|
<v-btn icon="mdi mdi-table-large" value="table"></v-btn>
|
|
322
325
|
</v-btn-toggle>
|
|
@@ -18,6 +18,7 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof VDataTable['$props
|
|
|
18
18
|
toolbarColor?: string
|
|
19
19
|
importable?: boolean
|
|
20
20
|
exportable?: boolean
|
|
21
|
+
insertable?: boolean
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -27,6 +28,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
27
28
|
toolbarColor: 'primary',
|
|
28
29
|
importable: true,
|
|
29
30
|
exportable: true,
|
|
31
|
+
insertable: true,
|
|
30
32
|
})
|
|
31
33
|
|
|
32
34
|
const emit = defineEmits(['update:modelValue'])
|
|
@@ -158,11 +160,11 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
|
|
|
158
160
|
<v-card>
|
|
159
161
|
<VToolbar :color="toolbarColor">
|
|
160
162
|
<v-row
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
justify="end"
|
|
164
|
+
class="ma-1"
|
|
165
|
+
dense
|
|
166
|
+
no-gutters
|
|
167
|
+
align="center"
|
|
166
168
|
>
|
|
167
169
|
<v-col cols="7">
|
|
168
170
|
<VToolbarTitle class="pl-3">
|
|
@@ -174,13 +176,13 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
|
|
|
174
176
|
<v-col cols="5">
|
|
175
177
|
<slot name="search">
|
|
176
178
|
<VTextField
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
v-model="search"
|
|
180
|
+
class="justify-end w-100"
|
|
181
|
+
density="compact"
|
|
182
|
+
hide-details
|
|
183
|
+
placeholder="ค้นหา"
|
|
184
|
+
clearable
|
|
185
|
+
variant="solo"
|
|
184
186
|
/>
|
|
185
187
|
</slot>
|
|
186
188
|
</v-col>
|
|
@@ -189,25 +191,26 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
|
|
|
189
191
|
<VToolbarItems>
|
|
190
192
|
<slot name="toolbarItems" />
|
|
191
193
|
<ImportCSV
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
v-if="props.importable"
|
|
195
|
+
icon="mdi:mdi-file-upload"
|
|
196
|
+
variant="flat"
|
|
197
|
+
@import="importItems"
|
|
198
|
+
:color="toolbarColor"
|
|
197
199
|
/>
|
|
198
200
|
<ExportCSV
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
v-if="props.exportable && items.length"
|
|
202
|
+
icon="mdi:mdi-file-download"
|
|
203
|
+
variant="flat"
|
|
204
|
+
:file-name="title"
|
|
205
|
+
:model-value="items"
|
|
206
|
+
:color="toolbarColor"
|
|
205
207
|
/>
|
|
206
208
|
<VBtn
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
v-if="props.insertable"
|
|
210
|
+
:color="toolbarColor"
|
|
211
|
+
prepend-icon="mdi:mdi-plus"
|
|
212
|
+
variant="flat"
|
|
213
|
+
@click="openDialog()"
|
|
211
214
|
>
|
|
212
215
|
add
|
|
213
216
|
</VBtn>
|
|
@@ -258,13 +261,13 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
|
|
|
258
261
|
</template>
|
|
259
262
|
</v-data-table>
|
|
260
263
|
<FormDialog
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
264
|
+
v-model="isDialogOpen"
|
|
265
|
+
:title="title"
|
|
266
|
+
:fullscreen="dialogFullscreen"
|
|
267
|
+
:initial-data="initialData"
|
|
268
|
+
:form-data="currentItem"
|
|
269
|
+
@create="createItem"
|
|
270
|
+
@update="updateItem"
|
|
268
271
|
>
|
|
269
272
|
<template #default="slotData">
|
|
270
273
|
<slot
|
|
@@ -175,7 +175,6 @@ onMounted(() => {
|
|
|
175
175
|
})
|
|
176
176
|
}
|
|
177
177
|
})
|
|
178
|
-
|
|
179
178
|
</script>
|
|
180
179
|
|
|
181
180
|
<template>
|
|
@@ -224,7 +223,7 @@ onMounted(() => {
|
|
|
224
223
|
</VToolbar>
|
|
225
224
|
<v-img
|
|
226
225
|
:src="image.data"
|
|
227
|
-
@click="readonly ? openImageFullScreen(image) : setDataUpdate(image)"
|
|
226
|
+
@click="() => { (readonly) ? openImageFullScreen(image) : setDataUpdate(image)}"
|
|
228
227
|
height="250"
|
|
229
228
|
/>
|
|
230
229
|
</VCard>
|
|
@@ -28,7 +28,7 @@ function templateItemToString(item) {
|
|
|
28
28
|
}
|
|
29
29
|
if (item.inputType == "VRadio" || item.inputType == "VRadioInline") {
|
|
30
30
|
const choice = optionStringToChoiceObject(item.inputOptions);
|
|
31
|
-
optionString = choice.map((choiceItem) => `<v-radio label="${choiceItem.label}" value="${choiceItem.value}"></v-radio>`).join("");
|
|
31
|
+
optionString = choice.map((choiceItem) => `<v-radio label="${choiceItem.label}" value="${choiceItem.value}" ${item.inputAttributes ? " " + item.inputAttributes : ""}></v-radio>`).join("");
|
|
32
32
|
}
|
|
33
33
|
if (item.inputType == "Header") {
|
|
34
34
|
optionString = item.inputOptions.split(",").join(" ");
|
|
@@ -3,6 +3,7 @@ import { watchDebounced } from "@vueuse/core";
|
|
|
3
3
|
import { useAlert } from "./alert.js";
|
|
4
4
|
import { buildRequiredInputFields } from "./graphqlOperation.js";
|
|
5
5
|
import { useGraphqlModelOperation } from "./graphqlModelOperation.js";
|
|
6
|
+
import pLimit from "p-limit";
|
|
6
7
|
export function useGraphqlModel(props) {
|
|
7
8
|
const alert = useAlert();
|
|
8
9
|
const items = ref([]);
|
|
@@ -69,21 +70,19 @@ export function useGraphqlModel(props) {
|
|
|
69
70
|
}
|
|
70
71
|
function importItems(importItems2, callback) {
|
|
71
72
|
isLoading.value = true;
|
|
72
|
-
const
|
|
73
|
-
importItems2.
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const limit = pLimit(50);
|
|
74
|
+
const importPromises = importItems2.map(
|
|
75
|
+
(item) => limit(
|
|
76
|
+
() => (item[props.modelKey || "id"] ? operationUpdate.value?.call(fields.value, { input: item }).then((result) => {
|
|
76
77
|
if (!result) {
|
|
77
78
|
return createItem(Object.assign({}, props.initialData, item), void 0, true);
|
|
78
79
|
}
|
|
79
|
-
}).catch((error) => {
|
|
80
|
+
}) : createItem(Object.assign({}, props.initialData, item), void 0, true)).catch((error) => {
|
|
80
81
|
alert?.addAlert({ alertType: "error", message: error });
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
Promise.all(importPromise).finally(() => {
|
|
82
|
+
})
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
Promise.all(importPromises).finally(() => {
|
|
87
86
|
isLoading.value = false;
|
|
88
87
|
reload();
|
|
89
88
|
if (callback) callback.done();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramathibodi/nuxt-commons",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "Ramathibodi Nuxt modules for common components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"lodash": "^4.17.21",
|
|
84
84
|
"luxon": "^3.5.0",
|
|
85
85
|
"maska": "^2.1.11",
|
|
86
|
+
"p-limit": "^6.1.0",
|
|
86
87
|
"painterro": "^1.2.87",
|
|
87
88
|
"pdf-vue3": "^1.0.12",
|
|
88
89
|
"prettier": "3.3.2",
|
|
@@ -114,5 +115,5 @@
|
|
|
114
115
|
"vitest": "^1.6.0",
|
|
115
116
|
"vue-tsc": "2.0.29"
|
|
116
117
|
},
|
|
117
|
-
"packageManager": "pnpm@9.12.
|
|
118
|
+
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
|
|
118
119
|
}
|