@ramathibodi/nuxt-commons 0.1.31 → 0.1.32

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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.1.31",
7
+ "version": "0.1.32",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.3",
10
10
  "unbuild": "2.0.0"
@@ -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,
@@ -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"
@@ -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
- justify="end"
162
- class="ma-1"
163
- dense
164
- no-gutters
165
- align="center"
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
- v-model="search"
178
- class="justify-end w-100"
179
- density="compact"
180
- hide-details
181
- placeholder="ค้นหา"
182
- clearable
183
- variant="solo"
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
- v-if="props.importable"
193
- icon="mdi:mdi-file-upload"
194
- variant="flat"
195
- @import="importItems"
196
- :color="toolbarColor"
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
- v-if="props.exportable && items.length"
200
- icon="mdi:mdi-file-download"
201
- variant="flat"
202
- :file-name="title"
203
- :model-value="items"
204
- :color="toolbarColor"
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
- :color="toolbarColor"
208
- prepend-icon="mdi:mdi-plus"
209
- variant="flat"
210
- @click="openDialog()"
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
- v-model="isDialogOpen"
262
- :title="title"
263
- :fullscreen="dialogFullscreen"
264
- :initial-data="initialData"
265
- :form-data="currentItem"
266
- @create="createItem"
267
- @update="updateItem"
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>
@@ -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 importPromise = [];
73
- importItems2.forEach((item) => {
74
- if (item[props.modelKey || "id"]) {
75
- importPromise.push(operationUpdate.value?.call(fields.value, { input: item }).then((result) => {
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
- } else {
83
- importPromise.push(createItem(Object.assign({}, props.initialData, item), void 0, true));
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.31",
3
+ "version": "0.1.32",
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.2+sha512.22721b3a11f81661ae1ec68ce1a7b879425a1ca5b991c975b074ac220b187ce56c708fe5db69f4c962c989452eee76c82877f4ee80f474cebd61ee13461b6228"
118
+ "packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
118
119
  }