@d-mok/quasar-app-extension-quasar-axe 2.2.4 → 2.2.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-mok/quasar-app-extension-quasar-axe",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "A Quasar App Extension",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -100,6 +100,28 @@ export async function askTable<T extends object>(
100
100
  sample: [...prefills].reverse().find($ => $.length > 0)![0],
101
101
  validators,
102
102
  cancel: true,
103
+ allowAddRow: true,
104
+ })
105
+ }
106
+
107
+ /**
108
+ * Edit an array of objects by table.
109
+ */
110
+ export async function editTable<T extends object>(
111
+ title: string,
112
+ message: string = '',
113
+ prefill: T[],
114
+ validators: [(_: T) => boolean, string][] = [[$ => true, '']]
115
+ ): Promise<T[]> {
116
+ if (prefill.length === 0) throwError('Error', 'prefill is empty array.')
117
+ return await base(dialogTable, {
118
+ title,
119
+ message,
120
+ content: prefill,
121
+ sample: prefill[0],
122
+ validators,
123
+ cancel: true,
124
+ allowAddRow: false,
103
125
  })
104
126
  }
105
127
 
@@ -187,6 +209,7 @@ export async function showTable(
187
209
  sample: content[0],
188
210
  validators: [[($: any) => true, '']],
189
211
  cancel: false,
212
+ allowAddRow: false,
190
213
  })
191
214
  }
192
215
 
@@ -24,6 +24,7 @@
24
24
  <handson
25
25
  v-model="dummy"
26
26
  :schema="schema"
27
+ :allowAddRow="allowAddRow"
27
28
  v-if="exist"
28
29
  ></handson>
29
30
  </q-card>
@@ -81,6 +82,7 @@ const props = defineProps<{
81
82
  sample: row
82
83
  validators: [(_: row) => boolean, string][]
83
84
  cancel: boolean
85
+ allowAddRow: boolean
84
86
  }>()
85
87
 
86
88
  let dummy = ref(props.content.map($ => clone($, Object.keys(props.sample))))
@@ -131,6 +133,7 @@ function isBlank(row: row): boolean {
131
133
  }
132
134
 
133
135
  function filterBlank(rows: row[]): row[] {
136
+ if (!props.allowAddRow) return rows
134
137
  return rows.filter($ => !isBlank($))
135
138
  }
136
139
 
@@ -20,7 +20,9 @@
20
20
  :afterRemoveRow="afterRemoveRow"
21
21
  :afterCreateRow="shake"
22
22
  :afterCopy="afterCopy"
23
- :contextMenu="['row_above', 'row_below', 'remove_row']"
23
+ :contextMenu="
24
+ allowAddRow ? ['row_above', 'row_below', 'remove_row'] : []
25
+ "
24
26
  ></hot-table>
25
27
  </template>
26
28
 
@@ -48,6 +50,7 @@ type schema = Record<string, string>
48
50
  const props = defineProps<{
49
51
  modelValue: row[]
50
52
  schema: schema // {id:'number',name:'string'}
53
+ allowAddRow: boolean
51
54
  }>()
52
55
 
53
56
  function columns() {