@d-mok/quasar-app-extension-quasar-axe 2.1.45 → 2.1.46
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
|
@@ -89,7 +89,7 @@ export async function askTable<T extends object>(
|
|
|
89
89
|
title: string,
|
|
90
90
|
message: string = '',
|
|
91
91
|
prefills: T[][],
|
|
92
|
-
|
|
92
|
+
validator: (_: T) => true | string = $ => true
|
|
93
93
|
): Promise<T[]> {
|
|
94
94
|
if (prefills.flat().length === 0)
|
|
95
95
|
throwError('Error', 'All prefills are empty array.')
|
|
@@ -98,7 +98,7 @@ export async function askTable<T extends object>(
|
|
|
98
98
|
message,
|
|
99
99
|
content: prefills.find($ => $.length > 0),
|
|
100
100
|
sample: [...prefills].reverse().find($ => $.length > 0)![0],
|
|
101
|
-
|
|
101
|
+
validator,
|
|
102
102
|
cancel: true,
|
|
103
103
|
})
|
|
104
104
|
}
|
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
v-if="exist"
|
|
28
28
|
></handson>
|
|
29
29
|
</q-card>
|
|
30
|
+
<div
|
|
31
|
+
v-for="e in errorMsg()"
|
|
32
|
+
class="text-red"
|
|
33
|
+
style="text-align: right"
|
|
34
|
+
>
|
|
35
|
+
{{ e }}
|
|
36
|
+
</div>
|
|
30
37
|
</q-card-section>
|
|
31
38
|
|
|
32
39
|
<q-card-actions align="right">
|
|
@@ -59,6 +66,7 @@ import { ref } from 'vue'
|
|
|
59
66
|
import { toSchema, isMatchSchema, isPrimitive, clone } from './schema'
|
|
60
67
|
import { unparseCSV } from '../../csv'
|
|
61
68
|
import { copyToClipboard } from 'quasar'
|
|
69
|
+
import { validate } from 'json-schema'
|
|
62
70
|
|
|
63
71
|
defineEmits([...useDialogPluginComponent.emits])
|
|
64
72
|
|
|
@@ -72,7 +80,7 @@ const props = defineProps<{
|
|
|
72
80
|
message: string
|
|
73
81
|
content: row[]
|
|
74
82
|
sample: row
|
|
75
|
-
|
|
83
|
+
validator: (_: row) => true | string
|
|
76
84
|
cancel: boolean
|
|
77
85
|
}>()
|
|
78
86
|
|
|
@@ -93,10 +101,22 @@ setTimeout(() => {
|
|
|
93
101
|
function allValid() {
|
|
94
102
|
if (!props.cancel) return true
|
|
95
103
|
return dummy.value.every(
|
|
96
|
-
$ =>
|
|
104
|
+
$ =>
|
|
105
|
+
props.validator($) === true &&
|
|
106
|
+
isPrimitive($) &&
|
|
107
|
+
isMatchSchema($, schema)
|
|
97
108
|
)
|
|
98
109
|
}
|
|
99
110
|
|
|
111
|
+
function errorMsg(): string[] {
|
|
112
|
+
let msgs: string[] = []
|
|
113
|
+
for (let i = 0; i < dummy.value.length; i++) {
|
|
114
|
+
let valid = props.validator(dummy.value[i])
|
|
115
|
+
if (valid !== true) msgs.push(`row ${i + 1}: ${valid}`)
|
|
116
|
+
}
|
|
117
|
+
return msgs
|
|
118
|
+
}
|
|
119
|
+
|
|
100
120
|
// filter blank
|
|
101
121
|
|
|
102
122
|
function isEmptyVal(x: any): boolean {
|