@ramathibodi/nuxt-commons 0.1.15 → 0.1.17

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,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.1.15"
7
+ "version": "0.1.17"
8
8
  }
@@ -16,7 +16,11 @@ const templateItems = ref<Record<string, any>>([])
16
16
  const headers = ref([
17
17
  { title: '',
18
18
  key: 'operation',
19
- width: '100px',
19
+ width: '120px',
20
+ },
21
+ {
22
+ title: 'Rec No.',
23
+ key: 'recNo',
20
24
  },
21
25
  {
22
26
  title: 'Input Type',
@@ -99,6 +103,9 @@ const ruleOptions = (inputType: string) => (value: any) => {
99
103
  Convert To Advance
100
104
  </VBtn>
101
105
  </template>
106
+ <template #item.recNo="{internalItem}">
107
+ {{ internalItem.index }}
108
+ </template>
102
109
  <template #form="{ data, rules }">
103
110
  <v-container fluid>
104
111
  <v-row dense>
@@ -105,7 +105,7 @@ function moveUpItem(currentItem: Record<string, any>, callback?: FormDialogCallb
105
105
  function moveDownItem(currentItem: Record<string, any>, callback?: FormDialogCallback) {
106
106
  const index = items.value.findIndex(item => item[props.modelKey] === currentItem[props.modelKey])
107
107
 
108
- if (index < items.value.length - 1) {
108
+ if (index >= 0 && index < items.value.length - 1) {
109
109
  const temp = items.value[index + 1]
110
110
  items.value[index + 1] = items.value[index]
111
111
  items.value[index] = temp
@@ -114,6 +114,26 @@ function moveDownItem(currentItem: Record<string, any>, callback?: FormDialogCal
114
114
  if (callback) callback.done()
115
115
  }
116
116
 
117
+ function moveToItem(currentItem: Record<string, any>, callback?: FormDialogCallback) {
118
+ const index = items.value.findIndex(item => item[props.modelKey] === currentItem[props.modelKey]);
119
+
120
+ if (index !== -1) {
121
+ const newPosition = prompt("Enter the new position (0-based index):");
122
+ const parsedPosition = parseInt(<string>newPosition, 10);
123
+
124
+ if (isNaN(parsedPosition) || parsedPosition < 0 || parsedPosition >= items.value.length) {
125
+ alert("Invalid position entered. Please enter a number between 0 and " + (items.value.length - 1));
126
+ return
127
+ }
128
+
129
+ const [temp] = items.value.splice(index, 1);
130
+
131
+ items.value.splice(parsedPosition, 0, temp);
132
+ }
133
+
134
+ if (callback) callback.done();
135
+ }
136
+
117
137
  function deleteItem(deleteItem: Record<string, any>, callback?: FormDialogCallback) {
118
138
  const index = items.value.findIndex(item => item[props.modelKey] === deleteItem[props.modelKey])
119
139
 
@@ -131,7 +151,7 @@ function openDialog(item?: object) {
131
151
  })
132
152
  }
133
153
 
134
- const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpItem, moveDownItem })
154
+ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpItem, moveDownItem,moveToItem })
135
155
  </script>
136
156
 
137
157
  <template>
@@ -173,6 +193,7 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
173
193
  icon="mdi mdi-file-upload"
174
194
  variant="flat"
175
195
  @import="importItems"
196
+ :color="toolbarColor"
176
197
  />
177
198
  <ExportCSV
178
199
  v-if="props.exportable && items.length"
@@ -180,6 +201,7 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
180
201
  variant="flat"
181
202
  :file-name="title"
182
203
  :model-value="items"
204
+ :color="toolbarColor"
183
205
  />
184
206
  <VBtn
185
207
  :color="toolbarColor"
@@ -220,6 +242,12 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
220
242
  icon="mdi mdi-arrow-up-thick"
221
243
  @click="moveUpItem(props.item)"
222
244
  />
245
+ <v-btn
246
+ variant="flat"
247
+ density="compact"
248
+ icon="fa fa-arrow-right-to-bracket"
249
+ @click="moveToItem(props.item)"
250
+ />
223
251
  <v-btn
224
252
  :disabled="props.index==items.length-1"
225
253
  variant="flat"
@@ -1,18 +1,24 @@
1
1
  <script lang="ts" setup>
2
+ import {computed} from 'vue'
2
3
  interface Props {
3
4
  label: string
4
5
  value?: string | null | undefined
5
6
  horizontal?: boolean
7
+ size? : 'large' | 'medium'
6
8
  }
7
9
 
8
10
  const props = withDefaults(defineProps<Props>(), {
9
11
  label: '', value: '',
10
12
  })
13
+ const cal_size = computed(()=>{
14
+ if(props.size=='medium') return 'text-subtitle-1'
15
+ else return 'text-h6'
16
+ })
11
17
  </script>
12
18
 
13
19
  <template>
14
20
  <div v-if="horizontal" class="d-flex align-end" :="$attrs">
15
- <div class="text-medium-emphasis">
21
+ <div class="text-medium-emphasis text-no-wrap">
16
22
  <slot name="label">
17
23
  {{ label }}:
18
24
  </slot>
@@ -23,13 +29,13 @@ const props = withDefaults(defineProps<Props>(), {
23
29
  </slot>
24
30
  </div>
25
31
  </div>
26
- <v-card v-else variant="flat" :="$attrs">
32
+ <v-card v-else variant="text" :="$attrs">
27
33
  <VCardSubtitle class="ma-0 pa-0 text-black">
28
34
  <slot name="label">
29
35
  {{ label }}
30
36
  </slot>
31
37
  </VCardSubtitle>
32
- <VCardText class="text-h6 pa-0 mb-2">
38
+ <VCardText :class="`pa-0 mb-2 ${cal_size}`">
33
39
  <slot name="value">
34
40
  {{ value }}
35
41
  </slot>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramathibodi/nuxt-commons",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "Ramathibodi Nuxt modules for common components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -116,5 +116,5 @@
116
116
  "vitest": "^1.5.1",
117
117
  "vue-tsc": "^1.8.27"
118
118
  },
119
- "packageManager": "pnpm@9.6.0+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e"
119
+ "packageManager": "pnpm@9.7.1+sha512.faf344af2d6ca65c4c5c8c2224ea77a81a5e8859cbc4e06b1511ddce2f0151512431dd19e6aff31f2c6a8f5f2aced9bd2273e1fed7dd4de1868984059d2c4247"
120
120
  }
@@ -105,20 +105,27 @@ module.exports = {
105
105
 
106
106
  export const scalarType = ${JSON.stringify(scalarType)}
107
107
 
108
- function operationCall${'<' + 'T,U>'}(operationType:string, operation: string,fields?: ${'Array' + '<string | Object>'},variables?: U) {
109
- return useGraphQlOperation${'<' + 'T>'}(operationType,operation,fields,variables as {[p: string] : any} | undefined)
108
+ function operationCall${'<' + 'T,U>'}(operationType:string, operation: string,fields?: ${'Array' + '<string | Object>'},variables?: U,cache: boolean = false) {
109
+ return useGraphQlOperation${'<' + 'T>'}(operationType,operation,fields,variables as {[p: string] : any} | undefined,cache)
110
110
  }
111
111
 
112
112
  function createGraphQLOperation${'<' + 'T,U>'}(operationType: "Query" | "Mutation",name: string,variables?: graphqlVariable[],fields?: graphqlTypeObject): graphqlOperationObject${'<' + 'T,U>'} {
113
- return {
113
+ let returnGraphqlOperation = {
114
114
  operationType,
115
115
  name,
116
116
  variables,
117
117
  fields,
118
- call: async function(fields?: ${'Array' + '<string | Object>'}, variables?: U): Promise${'<' + 'T>'} {
119
- return operationCall(operationType,name, fields, variables);
120
- }
121
118
  }
119
+ if (operationType === "Mutation") {
120
+ returnGraphqlOperation['call'] = async function(fields?: ${'Array' + '<string | Object>'}, variables?: U): Promise${'<' + 'T>'} {
121
+ return operationCall(operationType,name, fields, variables);
122
+ }
123
+ } else {
124
+ returnGraphqlOperation['call'] = async function(fields?: ${'Array' + '<string | Object>'}, variables?: U,cache: boolean = false): Promise${'<' + 'T>'} {
125
+ return operationCall(operationType,name, fields, variables,cache);
126
+ }
127
+ }
128
+ return returnGraphqlOperation
122
129
  }
123
130
 
124
131
  interface graphqlTypeObjects extends ${'Record<string,' + 'graphqlTypeObject>'} {