@d-mok/quasar-app-extension-quasar-axe 2.1.96 → 2.1.98
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.1.
|
|
3
|
+
"version": "2.1.98",
|
|
4
4
|
"description": "A Quasar App Extension",
|
|
5
5
|
"author": "d-mok <49301824+d-mok@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"mime-types": "^2.1.35",
|
|
29
29
|
"papaparse": "^5.4.1",
|
|
30
30
|
"sapphire-js": "^2.1.9",
|
|
31
|
-
"sortablejs": "^1.15.0"
|
|
32
|
-
"vuedraggable": "^4.1.0"
|
|
31
|
+
"sortablejs": "^1.15.0"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
34
|
"@quasar/app-vite": "^1.7.1",
|
|
@@ -24,7 +24,10 @@ async function base(options: QDialogOptions): Promise<string> {
|
|
|
24
24
|
|
|
25
25
|
return new Promise<string>((resolve, reject) =>
|
|
26
26
|
Dialog.create(opt)
|
|
27
|
-
.onOk((data: unknown) =>
|
|
27
|
+
.onOk((data: unknown) => {
|
|
28
|
+
if (Array.isArray(data)) resolve(JSON.stringify(data))
|
|
29
|
+
resolve(String(data))
|
|
30
|
+
})
|
|
28
31
|
.onCancel(() => reject('dialog cancelled by user.'))
|
|
29
32
|
)
|
|
30
33
|
}
|
|
@@ -141,7 +144,8 @@ export async function askRadio<T>(
|
|
|
141
144
|
title: string,
|
|
142
145
|
message: string = '',
|
|
143
146
|
items: T[],
|
|
144
|
-
|
|
147
|
+
prefill: T = items[0],
|
|
148
|
+
label?: (string & keyof T) | Mapper<T, string>
|
|
145
149
|
): Promise<T> {
|
|
146
150
|
let labelFunc = ($: any) => getLabelFunc(label)($)
|
|
147
151
|
let values = items.map(labelFunc)
|
|
@@ -150,7 +154,7 @@ export async function askRadio<T>(
|
|
|
150
154
|
title,
|
|
151
155
|
message,
|
|
152
156
|
options: {
|
|
153
|
-
model:
|
|
157
|
+
model: labelFunc(prefill),
|
|
154
158
|
type: 'radio',
|
|
155
159
|
items: values.map($ => ({ label: $, value: $ })),
|
|
156
160
|
isValid: $ => typeof $ === 'string' && values.includes($),
|
|
@@ -159,3 +163,31 @@ export async function askRadio<T>(
|
|
|
159
163
|
|
|
160
164
|
return items.find($ => labelFunc($) === value)!
|
|
161
165
|
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Ask to select multiple object by a checkbox button group.
|
|
169
|
+
*/
|
|
170
|
+
export async function askCheckbox<T>(
|
|
171
|
+
title: string,
|
|
172
|
+
message: string = '',
|
|
173
|
+
items: T[],
|
|
174
|
+
prefill: T[] = [],
|
|
175
|
+
label?: (string & keyof T) | Mapper<T, string>
|
|
176
|
+
): Promise<T[]> {
|
|
177
|
+
let labelFunc = ($: any) => getLabelFunc(label)($)
|
|
178
|
+
let values = items.map(labelFunc)
|
|
179
|
+
|
|
180
|
+
let value = await base({
|
|
181
|
+
title,
|
|
182
|
+
message,
|
|
183
|
+
options: {
|
|
184
|
+
model: prefill.map(labelFunc),
|
|
185
|
+
type: 'checkbox',
|
|
186
|
+
items: values.map($ => ({ label: $, value: $ })),
|
|
187
|
+
// isValid: $ => typeof $ === 'string' && values.includes($),
|
|
188
|
+
},
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
let selected: string[] = JSON.parse(value)
|
|
192
|
+
return items.filter($ => selected.includes(labelFunc($)))
|
|
193
|
+
}
|
|
@@ -66,7 +66,6 @@ import { ref } from 'vue'
|
|
|
66
66
|
import { toSchema, isMatchSchema, isPrimitive, clone } from './schema'
|
|
67
67
|
import { unparseCSV } from '../../csv'
|
|
68
68
|
import { copyToClipboard } from 'quasar'
|
|
69
|
-
import { validate } from 'json-schema'
|
|
70
69
|
|
|
71
70
|
defineEmits([...useDialogPluginComponent.emits])
|
|
72
71
|
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<q-markup-table
|
|
3
|
-
bordered
|
|
4
|
-
flat
|
|
5
|
-
:dense="dense"
|
|
6
|
-
>
|
|
7
|
-
<thead>
|
|
8
|
-
<tr>
|
|
9
|
-
<th style="width: 50px">#</th>
|
|
10
|
-
<th>{{ header }}</th>
|
|
11
|
-
</tr>
|
|
12
|
-
</thead>
|
|
13
|
-
<draggable
|
|
14
|
-
tag="tbody"
|
|
15
|
-
:modelValue="modelValue"
|
|
16
|
-
@update:modelValue="e => (modelValue = e)"
|
|
17
|
-
:item-key="identity"
|
|
18
|
-
:animation="200"
|
|
19
|
-
ghostClass="sortable-ghost"
|
|
20
|
-
>
|
|
21
|
-
<template #item="{ element, index }">
|
|
22
|
-
<tr style="cursor: move">
|
|
23
|
-
<td>{{ index + 1 }}</td>
|
|
24
|
-
<td>
|
|
25
|
-
<b>{{ labeler(element) }}</b>
|
|
26
|
-
</td>
|
|
27
|
-
</tr>
|
|
28
|
-
</template>
|
|
29
|
-
</draggable>
|
|
30
|
-
</q-markup-table>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<script lang="ts" setup generic="T extends Object">
|
|
34
|
-
import draggable from 'vuedraggable'
|
|
35
|
-
import { getLabelFunc } from '../../../utils/tool'
|
|
36
|
-
|
|
37
|
-
let modelValue = defineModel<T[]>()
|
|
38
|
-
|
|
39
|
-
const {
|
|
40
|
-
header,
|
|
41
|
-
label,
|
|
42
|
-
dense = false,
|
|
43
|
-
} = defineProps<{
|
|
44
|
-
header: string
|
|
45
|
-
label?: (string & keyof T) | ((_: T) => string)
|
|
46
|
-
dense?: boolean
|
|
47
|
-
}>()
|
|
48
|
-
|
|
49
|
-
function identity($: any) {
|
|
50
|
-
return $
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function labeler(v: any) {
|
|
54
|
-
return getLabelFunc(label)(v)
|
|
55
|
-
}
|
|
56
|
-
</script>
|
|
57
|
-
|
|
58
|
-
<style scoped>
|
|
59
|
-
.sortable-ghost {
|
|
60
|
-
opacity: 0.5;
|
|
61
|
-
background: #cbc4ff;
|
|
62
|
-
}
|
|
63
|
-
th {
|
|
64
|
-
text-align: left;
|
|
65
|
-
}
|
|
66
|
-
</style>
|