grantthomas-nuxt 1.0.19 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@grantthomas/nuxt",
3
3
  "configKey": "grantThomasNuxt",
4
- "version": "1.0.19",
4
+ "version": "1.0.21",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -34,7 +34,7 @@ const hasErrors = computed(() => {
34
34
  </template>
35
35
  <template v-if="showAll">
36
36
  <div v-for="(errorGroup, groupKey) in errors" :key="`${random}-group-${groupKey}`">
37
- <div v-for="(error, errorIndex) in errorGroup" :key="`${random}-error-${groupKey}-${errorIndex}`">
37
+ <div v-if="Array.isArray(errorGroup)" v-for="(error, errorIndex) in errorGroup" :key="`${random}-error-${groupKey}-${errorIndex}`">
38
38
  {{ error }}
39
39
  </div>
40
40
  </div>
@@ -19,6 +19,7 @@ declare const __VLS_component: import("vue").DefineComponent<{}, {
19
19
  contentClasses: string;
20
20
  showPerPageSelector: boolean;
21
21
  perPageOptions: unknown[];
22
+ onSaveQueryParams: Record<string, any>;
22
23
  title?: string | undefined;
23
24
  loaderKey?: string | undefined;
24
25
  initialItem?: Record<string, any> | undefined;
@@ -125,6 +125,13 @@ const props = defineProps({
125
125
  type: Array,
126
126
  required: false,
127
127
  default: () => [10, 25, 50, 100, 250, 500, 1e3]
128
+ },
129
+ onSaveQueryParams: {
130
+ type: Object,
131
+ required: false,
132
+ default: () => {
133
+ return {};
134
+ }
128
135
  }
129
136
  });
130
137
  const {
@@ -285,17 +292,17 @@ const saveAction = async () => {
285
292
  if (props.beforeCreate != null) {
286
293
  itemToSave = await props.beforeCreate(itemToSave);
287
294
  }
288
- await createItem(itemToSave);
295
+ await createItem(itemToSave, {}, props.onSaveQueryParams);
289
296
  } else if (action.value === "update") {
290
297
  if (props.beforeUpdate != null) {
291
298
  itemToSave = await props.beforeUpdate(itemToSave);
292
299
  }
293
- await updateItem(itemToSave.id, itemToSave);
300
+ await updateItem(itemToSave.id, itemToSave, {}, props.onSaveQueryParams);
294
301
  } else if (action.value === "delete") {
295
302
  if (props.beforeDelete != null) {
296
303
  itemToSave = await props.beforeDelete(itemToSave);
297
304
  }
298
- await deleteItem(itemToSave.id);
305
+ await deleteItem(itemToSave.id, {}, props.onSaveQueryParams);
299
306
  }
300
307
  if (formErrors.value == null || Object.keys(formErrors.value).length === 0) {
301
308
  const savedPath = props.path;
@@ -19,6 +19,7 @@ declare const __VLS_component: import("vue").DefineComponent<{}, {
19
19
  contentClasses: string;
20
20
  showPerPageSelector: boolean;
21
21
  perPageOptions: unknown[];
22
+ onSaveQueryParams: Record<string, any>;
22
23
  title?: string | undefined;
23
24
  loaderKey?: string | undefined;
24
25
  initialItem?: Record<string, any> | undefined;
@@ -11,6 +11,7 @@ declare const __VLS_component: import("vue").DefineComponent<{}, {
11
11
  aspectRatio: string;
12
12
  defaultAspectRatio: string;
13
13
  crop: boolean;
14
+ onSaveQueryParams: Record<string, any>;
14
15
  mimeKey: string;
15
16
  fileNameKey: string;
16
17
  replaceable: boolean;
@@ -68,10 +68,18 @@ const props = defineProps({
68
68
  clearable: {
69
69
  type: Boolean,
70
70
  default: true
71
+ },
72
+ onSaveQueryParams: {
73
+ type: Object,
74
+ default: () => {
75
+ return {};
76
+ }
71
77
  }
72
78
  });
73
79
  const model = defineModel();
80
+ const objectsModel = defineModel("objects");
74
81
  const dialog = ref(false);
82
+ const selectedObjects = ref(null);
75
83
  const filesToUpload = ref([]);
76
84
  const fileToUpload = ref(null);
77
85
  const searchValue = ref(null);
@@ -237,7 +245,7 @@ const handleCropComplete = async (croppedBase64) => {
237
245
  originalFilename: fileForCrop.value.name,
238
246
  ...props.additionalPostData
239
247
  };
240
- await createUpload(upload);
248
+ await createUpload(upload, {}, props.onSaveQueryParams);
241
249
  if (!hasUploadErrors.value && hasItem.value) {
242
250
  onSelectImage(completedUpload.value.id);
243
251
  }
@@ -250,7 +258,7 @@ const handleCropComplete = async (croppedBase64) => {
250
258
  originalFilename: fileForCrop.value.name,
251
259
  ...props.additionalPostData
252
260
  };
253
- await createUpload(upload);
261
+ await createUpload(upload, {}, props.onSaveQueryParams);
254
262
  if (!hasUploadErrors.value && hasItem.value) {
255
263
  model.value = completedUpload.value.id;
256
264
  dialog.value = false;
@@ -312,7 +320,7 @@ const processUploads = async () => {
312
320
  originalFilename: file.name,
313
321
  ...props.additionalPostData
314
322
  };
315
- await createUpload(upload);
323
+ await createUpload(upload, {}, props.onSaveQueryParams);
316
324
  if (!hasUploadErrors.value && hasItem.value) {
317
325
  onSelectImage(completedUpload.value.id);
318
326
  }
@@ -344,7 +352,7 @@ const processUploads = async () => {
344
352
  originalFilename: fileToUpload.value.name,
345
353
  ...props.additionalPostData
346
354
  };
347
- await createUpload(upload);
355
+ await createUpload(upload, {}, props.onSaveQueryParams);
348
356
  if (!hasUploadErrors.value && hasItem.value) {
349
357
  model.value = completedUpload.value.id;
350
358
  dialog.value = false;
@@ -409,6 +417,12 @@ watch(() => fileToUpload.value, (newVal, oldVal) => {
409
417
  processUploads();
410
418
  }
411
419
  });
420
+ const updateSelectedObjects = (items) => {
421
+ selectedObjects.value = items;
422
+ };
423
+ watch(selectedObjects, (newObjects) => {
424
+ objectsModel.value = newObjects;
425
+ }, { deep: true });
412
426
  </script>
413
427
 
414
428
  <template>
@@ -442,6 +456,7 @@ watch(() => fileToUpload.value, (newVal, oldVal) => {
442
456
  :path="path"
443
457
  >
444
458
  <template #default="uploadSlot">
459
+ {{ updateSelectedObjects(uploadSlot.items) }}
445
460
  <div v-for="item in uploadSlot.items" :key="item.id">
446
461
  <crud-upload-field-selection
447
462
  :hide-title="true"
@@ -11,6 +11,7 @@ declare const __VLS_component: import("vue").DefineComponent<{}, {
11
11
  aspectRatio: string;
12
12
  defaultAspectRatio: string;
13
13
  crop: boolean;
14
+ onSaveQueryParams: Record<string, any>;
14
15
  mimeKey: string;
15
16
  fileNameKey: string;
16
17
  replaceable: boolean;
@@ -22,9 +22,9 @@ export declare const useCrudApi: (path: string, watchPage?: boolean, transformIt
22
22
  getItems: (page?: number | null, perPageLimit?: number | null, filterValues?: Record<string, any> | null, headers?: Record<string, string>) => Promise<void>;
23
23
  getItem: (id: string | number, headers?: Record<string, string>) => Promise<void>;
24
24
  getCount: (filterValues?: Record<string, any> | null, headers?: Record<string, string>) => Promise<void>;
25
- createItem: (itemData: any, headers?: Record<string, string>) => Promise<void>;
26
- updateItem: (id: string | number, itemData: any, headers?: Record<string, string>) => Promise<void>;
27
- deleteItem: (id: string | number, headers?: Record<string, string>) => Promise<void>;
25
+ createItem: (itemData: any, headers?: Record<string, string>, queryParams?: Record<string, any> | null) => Promise<void>;
26
+ updateItem: (id: string | number, itemData: any, headers?: Record<string, string>, queryParams?: Record<string, any> | null) => Promise<void>;
27
+ deleteItem: (id: string | number, headers?: Record<string, string>, queryParams?: Record<string, any> | null) => Promise<void>;
28
28
  exportItems: (filterValues?: Record<string, any> | null) => Promise<void>;
29
29
  exportUrl: Ref<any, any>;
30
30
  hasFormErrors: import("vue").ComputedRef<boolean>;
@@ -221,8 +221,12 @@ export const useCrudApi = (path, watchPage = true, transformItem = null, transfo
221
221
  originalItem.value = cloneDeep(res);
222
222
  }
223
223
  };
224
- const createItem = async (itemData, headers = {}) => {
225
- const url = `${crudNuxtConfig.apiBaseUrl}/${path}`;
224
+ const createItem = async (itemData, headers = {}, queryParams = null) => {
225
+ let url = `${crudNuxtConfig.apiBaseUrl}/${path}`;
226
+ if (queryParams) {
227
+ const queryString = stringifyQuery(queryParams, "?");
228
+ url += queryString;
229
+ }
226
230
  const options = {
227
231
  method: "POST",
228
232
  headers: {
@@ -240,8 +244,12 @@ export const useCrudApi = (path, watchPage = true, transformItem = null, transfo
240
244
  originalItem.value = cloneDeep(res);
241
245
  }
242
246
  };
243
- const updateItem = async (id, itemData, headers = {}) => {
244
- const url = `${crudNuxtConfig.apiBaseUrl}/${path}/${id}`;
247
+ const updateItem = async (id, itemData, headers = {}, queryParams = null) => {
248
+ let url = `${crudNuxtConfig.apiBaseUrl}/${path}/${id}`;
249
+ if (queryParams) {
250
+ const queryString = stringifyQuery(queryParams, "?");
251
+ url += queryString;
252
+ }
245
253
  const options = {
246
254
  method: "PUT",
247
255
  headers: {
@@ -259,8 +267,12 @@ export const useCrudApi = (path, watchPage = true, transformItem = null, transfo
259
267
  originalItem.value = cloneDeep(res);
260
268
  }
261
269
  };
262
- const deleteItem = async (id, headers = {}) => {
263
- const url = `${crudNuxtConfig.apiBaseUrl}/${path}/${id}`;
270
+ const deleteItem = async (id, headers = {}, queryParams = null) => {
271
+ let url = `${crudNuxtConfig.apiBaseUrl}/${path}/${id}`;
272
+ if (queryParams) {
273
+ const queryString = stringifyQuery(queryParams, "?");
274
+ url += queryString;
275
+ }
264
276
  const options = {
265
277
  method: "DELETE",
266
278
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grantthomas-nuxt",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Crud module for Nuxt 3 interacting with sibling .net project",
5
5
  "repository": "Tap-Leagues/GrantThomas.Nuxt",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@azure/msal-browser": "^4.13.1",
31
31
  "@nuxt/image": "^1.10.0",
32
- "@nuxt/kit": "^3.17.5",
32
+ "@nuxt/kit": "^4.3.0",
33
33
  "@nuxt/scripts": "^0.11.8",
34
34
  "@vueuse/core": "^13.3.0",
35
35
  "@vueuse/nuxt": "^13.3.0",
@@ -48,8 +48,8 @@
48
48
  "@nuxt/devtools": "1.7.0",
49
49
  "@nuxt/eslint-config": "^1.4.1",
50
50
  "@nuxt/module-builder": "^1.0.1",
51
- "@nuxt/schema": "^3.17.5",
52
- "@nuxt/test-utils": "^3.19.1",
51
+ "@nuxt/schema": "^4.3.0",
52
+ "@nuxt/test-utils": "^4.0.0",
53
53
  "@types/luxon": "^3.6.2",
54
54
  "@types/node": "^22.15.32",
55
55
  "@types/uuid": "^8.3.0",
@@ -58,7 +58,7 @@
58
58
  "eslint-config-prettier": "^8.8.0",
59
59
  "sass": "^1.89.2",
60
60
  "typescript": "^5.8.3",
61
- "vitest": "^3.2.3",
61
+ "vitest": "^4.0.2",
62
62
  "vue-tsc": "^2.2.10"
63
63
  }
64
64
  }