atom-nuxt 1.0.155 → 1.1.0

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": "@atomengine/atom-nuxt",
3
3
  "configKey": "atomNuxt",
4
- "version": "1.0.155",
4
+ "version": "1.1.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "3.5.0"
@@ -16,7 +16,7 @@ const selectionModel = defineModel();
16
16
  const search = ref("");
17
17
  const searchDialog = ref(false);
18
18
  const searchDialogSelectedValue = ref(null);
19
- const hasSelection = computed(() => selectionModel.value !== null);
19
+ const hasSelection = computed(() => props.multiple ? selectionModel.value !== null && Array.isArray(selectionModel.value) && selectionModel.value.length > 0 : selectionModel.value !== null);
20
20
  const onAction = () => {
21
21
  searchDialogSelectedValue.value = selectionModel.value ? Array.isArray(selectionModel.value) ? [...selectionModel.value] : selectionModel.value : null;
22
22
  searchDialog.value = true;
@@ -54,6 +54,11 @@ const props = defineProps({
54
54
  required: false,
55
55
  default: "Delete item"
56
56
  },
57
+ viewTitle: {
58
+ type: String,
59
+ required: false,
60
+ default: "View item"
61
+ },
57
62
  saveAction: {
58
63
  type: Function,
59
64
  required: true
@@ -94,13 +99,14 @@ const item = defineModel();
94
99
  const dialogOpen = defineModel("dialog");
95
100
  const hasItem = computed(() => item.value && Object.keys(item.value).length > 0);
96
101
  const buttonTitle = computed(() => {
97
- return props.btnText ? props.btnText : props.action === "create" ? props.createTitle : props.action === "update" ? props.updateTitle : props.action === "delete" ? props.deleteTitle : "";
102
+ return props.btnText ? props.btnText : props.action === "create" ? props.createTitle : props.action === "update" ? props.updateTitle : props.action === "delete" ? props.deleteTitle : props.action === "view" ? props.viewTitle : "";
98
103
  });
99
104
  const buttonIcon = computed(() => {
100
- return props.btnIcon ? props.btnIcon : props.action === "create" ? "mdi-plus" : props.action === "update" ? "mdi-pencil" : props.action === "delete" ? "mdi-delete" : "mdi-timer-sand";
105
+ return props.btnIcon ? props.btnIcon : props.action === "create" ? "mdi-plus" : props.action === "update" ? "mdi-pencil" : props.action === "delete" ? "mdi-delete" : props.action === "view" ? "mdi-eye" : "mdi-timer-sand";
101
106
  });
102
107
  const display = useDisplay();
103
108
  const isLarge = computed(() => display.lgAndUp.value);
109
+ const readonly = computed(() => props.action === "view");
104
110
  </script>
105
111
 
106
112
  <template>
@@ -129,7 +135,7 @@ const isLarge = computed(() => display.lgAndUp.value);
129
135
  Loading
130
136
  </v-toolbar-title>
131
137
  <v-toolbar-title v-else>{{
132
- action === 'create' ? createTitle : (action === 'update' ? updateTitle : (action === 'delete' ? deleteTitle : ''))
138
+ action === 'create' ? createTitle : (action === 'update' ? updateTitle : (action === 'delete' ? deleteTitle : (action === 'view' ? viewTitle : '')))
133
139
  }}
134
140
  </v-toolbar-title>
135
141
  </v-toolbar>
@@ -143,7 +149,7 @@ const isLarge = computed(() => display.lgAndUp.value);
143
149
  <v-progress-circular indeterminate color="primary"></v-progress-circular>
144
150
  </div>
145
151
 
146
- <div v-if="(hasItem && !itemPending) || action === 'create'" class="flex-fill">
152
+ <div v-if="(hasItem && !itemPending) || action === 'create' || action === 'view'" class="flex-fill">
147
153
  <suspense>
148
154
  <template #fallback>
149
155
  <div v-if="!itemPending" class="d-flex flex-fill flex-column justify-center align-center"
@@ -151,21 +157,22 @@ const isLarge = computed(() => display.lgAndUp.value);
151
157
  <v-progress-circular indeterminate color="primary"></v-progress-circular>
152
158
  </div>
153
159
  </template>
154
- <slot v-bind:action="action"
155
- v-bind:item="item"
156
- v-bind:errors="formErrors">
160
+ <slot :action="action"
161
+ :readonly="readonly"
162
+ :item="item"
163
+ :errors="formErrors">
157
164
 
158
165
  </slot>
159
166
  </suspense>
160
167
  </div>
161
168
  </div>
162
- <v-card-actions v-if="!hideActions" class="pa-0 border-t pa-4 elevation-5">
169
+ <v-card-actions v-if="!hideActions && action !== 'view'" class="pa-0 border-t pa-4 elevation-5">
163
170
  <v-btn
164
171
  size="large"
165
172
  class="px-5"
166
173
  :width="isLarge ? 'auto' : '100%'"
167
174
  :disabled="disabled || !action"
168
- :color="btnColor ? btnColor : (action === 'create' ? 'success' : (action === 'update' ? 'info' : (action === 'delete' ? 'error' : 'light')))"
175
+ :color="btnColor ? btnColor : (action === 'create' ? 'success' : (action === 'update' ? 'info' : (action === 'delete' ? 'error' : (action === 'view' ? 'primary' : 'light'))))"
169
176
  variant="flat"
170
177
  @click="saveAction"
171
178
  :loading="formPending"
@@ -13,6 +13,7 @@ declare const __VLS_component: import("vue").DefineComponent<{}, {
13
13
  createTitle: string;
14
14
  updateTitle: string;
15
15
  deleteTitle: string;
16
+ viewTitle: string;
16
17
  saveAction: Function;
17
18
  btnIcon: string;
18
19
  btnColor: string;
@@ -25,6 +26,7 @@ declare const __VLS_component: import("vue").DefineComponent<{}, {
25
26
  type __VLS_Slots = {
26
27
  default?: ((props: {
27
28
  action: any;
29
+ readonly: any;
28
30
  item: any;
29
31
  errors: any;
30
32
  }) => any) | undefined;
@@ -90,6 +90,13 @@ const props = defineProps({
90
90
  return "Create item";
91
91
  }
92
92
  },
93
+ viewTitle: {
94
+ type: String,
95
+ required: false,
96
+ default() {
97
+ return "View item";
98
+ }
99
+ },
93
100
  customFilters: {
94
101
  type: Object,
95
102
  required: false,
@@ -151,7 +158,7 @@ const previousRoute = usePreviousRoute();
151
158
  const action = computed(() => route.query[(props.loaderKey ?? "") + "action"]);
152
159
  const actionId = computed(() => route.query[(props.loaderKey ?? "") + "actionId"]);
153
160
  const dialogOpen = computed({
154
- get: () => !!(action.value === "create" || action.value === "update" && actionId.value || action.value === "delete" && actionId.value),
161
+ get: () => !!(action.value === "create" || action.value === "update" && actionId.value || action.value === "delete" && actionId.value || action.value === "view" && actionId.value),
155
162
  set: (value) => {
156
163
  if (!value) {
157
164
  const hasBackState = router.options.history.state.back;
@@ -254,6 +261,17 @@ const deleteForm = async (id) => {
254
261
  }
255
262
  await router.push(newQuery);
256
263
  };
264
+ const viewForm = async (id) => {
265
+ const newQuery = { query: { ...route.query } };
266
+ if (props.loaderKey) {
267
+ newQuery.query[(props.loaderKey ?? "") + "action"] = "view";
268
+ newQuery.query[(props.loaderKey ?? "") + "actionId"] = id;
269
+ } else {
270
+ newQuery.query.action = "view";
271
+ newQuery.query.actionId = id;
272
+ }
273
+ await router.push(newQuery);
274
+ };
257
275
  const createForm = () => {
258
276
  item.value = props.initialItem ? cloneDeep(props.initialItem) : {};
259
277
  const newQuery = { query: { ...route.query } };
@@ -308,6 +326,8 @@ watch(action, (newVal, oldValue) => {
308
326
  item.value = props.initialItem ? cloneDeep(props.initialItem) : {};
309
327
  } else if (action.value === "delete" && actionId.value) {
310
328
  getItem(actionId.value);
329
+ } else if (action.value === "view" && actionId.value) {
330
+ getItem(actionId.value);
311
331
  }
312
332
  } catch (error) {
313
333
  console.error("Error in actionId watcher:", error);
@@ -339,9 +359,12 @@ const exportAction = async () => {
339
359
  <slot
340
360
  name="before"
341
361
  :items="items"
362
+ :total-items="totalItems"
363
+ :total-pages="totalPages"
342
364
  :pending="listPending"
343
365
  :create-action="createForm"
344
366
  :update-action="updateForm"
367
+ :view-action="viewForm"
345
368
  :delete-action="deleteForm"
346
369
  :form-pending="formPending"
347
370
  :export-action="exportAction"
@@ -374,6 +397,7 @@ const exportAction = async () => {
374
397
  :items="items"
375
398
  :pending="listPending"
376
399
  :update-action="updateForm"
400
+ :view-action="viewForm"
377
401
  :delete-action="deleteForm"
378
402
  :form-pending="formPending"
379
403
  >
@@ -403,6 +427,7 @@ const exportAction = async () => {
403
427
  :create-title="createTitle"
404
428
  :update-title="updateTitle"
405
429
  :delete-title="deleteTitle"
430
+ :view-title="viewTitle"
406
431
  :save-action="saveAction"
407
432
  :full-screen="fullScreenDialog"
408
433
  >
@@ -13,6 +13,7 @@ declare const __VLS_component: import("vue").DefineComponent<{}, {
13
13
  createTitle: string;
14
14
  updateTitle: string;
15
15
  deleteTitle: string;
16
+ viewTitle: string;
16
17
  allowCreate: boolean;
17
18
  hideFilters: boolean;
18
19
  fullScreenDialog: boolean;
@@ -31,9 +32,12 @@ declare const __VLS_component: import("vue").DefineComponent<{}, {
31
32
  type __VLS_Slots = {
32
33
  before?: ((props: {
33
34
  items: any;
35
+ totalItems: any;
36
+ totalPages: any;
34
37
  pending: any;
35
38
  createAction: any;
36
39
  updateAction: any;
40
+ viewAction: any;
37
41
  deleteAction: any;
38
42
  formPending: any;
39
43
  exportAction: any;
@@ -57,6 +61,7 @@ type __VLS_Slots = {
57
61
  items: any;
58
62
  pending: any;
59
63
  updateAction: any;
64
+ viewAction: any;
60
65
  deleteAction: any;
61
66
  formPending: any;
62
67
  }) => any) | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atom-nuxt",
3
- "version": "1.0.155",
3
+ "version": "1.1.0",
4
4
  "description": "My new Nuxt module",
5
5
  "repository": "atomengine/atom-nuxt",
6
6
  "license": "MIT",