@d-mok/quasar-app-extension-quasar-axe 2.0.17 → 2.0.20

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.0.17",
3
+ "version": "2.0.20",
4
4
  "description": "A Quasar App Extension",
5
5
  "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <q-select
3
+ v-model="text"
4
+ :use-input="text === null"
5
+ input-debounce="0"
6
+ :options="options"
7
+ @filter="filterFn"
8
+ new-value-mode="add-unique"
9
+ v-bind="$attrs"
10
+ clearable
11
+ >
12
+ </q-select>
13
+ </template>
14
+
15
+ <script lang="ts" setup>
16
+ import { useVModel } from '@vueuse/core'
17
+ import _ from 'lodash'
18
+ import { ref } from 'vue'
19
+
20
+ const props = defineProps<{
21
+ autocomplete: string[]
22
+ modelValue: any
23
+ }>()
24
+
25
+ const emits = defineEmits(['update:modelValue'])
26
+
27
+ const text = useVModel(props, 'modelValue', emits)
28
+ if (!text.value) text.value = null
29
+
30
+ let options = ref<string[]>(props.autocomplete)
31
+
32
+ function filterFn(val: any, update: any) {
33
+ if (val === '') {
34
+ update(() => {
35
+ options.value = props.autocomplete
36
+ })
37
+ } else {
38
+ update(() => {
39
+ const needle = val.toLowerCase()
40
+ options.value = props.autocomplete.filter(
41
+ v => v.toLowerCase().indexOf(needle) > -1
42
+ )
43
+ })
44
+ }
45
+ }
46
+ </script>
@@ -23,6 +23,13 @@ async function base(component: QDialogOptions['component'], props: any) {
23
23
  )
24
24
  }
25
25
 
26
+ export async function custom(
27
+ component: QDialogOptions['component'],
28
+ props: any
29
+ ) {
30
+ await base(component, props)
31
+ }
32
+
26
33
  /**
27
34
  * Ask for a string by a text area. Allow empty.
28
35
  */
@@ -125,6 +132,7 @@ type FormPrefill = Record<
125
132
  | number
126
133
  | boolean
127
134
  | { type: 'select'; value: string; options: string[] }
135
+ | { type: 'autocomplete'; value: string; options: string[] }
128
136
  >
129
137
 
130
138
  type FormFlat<T extends FormPrefill> = {
@@ -33,6 +33,12 @@
33
33
  :options="(prefill[field] as any).options"
34
34
  :label="field"
35
35
  />
36
+ <qx-input-autocomplete
37
+ v-if="getType(field) === 'autocomplete'"
38
+ v-model="dummy[field]"
39
+ :autocomplete="(prefill[field] as any).options"
40
+ :label="field"
41
+ />
36
42
  </div>
37
43
  <div
38
44
  class="text-red"
@@ -77,6 +83,7 @@ type prefill = Record<
77
83
  | number
78
84
  | boolean
79
85
  | { type: 'select'; value: string; options: string[] }
86
+ | { type: 'autocomplete'; value: string; options: string[] }
80
87
  >
81
88
 
82
89
  const props = defineProps<{
@@ -63,9 +63,17 @@ export function TABLE<
63
63
  this.order(...ordering)
64
64
  }
65
65
 
66
- /** Get an item by `criteria`. If not found, return a new object. */
66
+ /** Get an item by `criteria`. If not found, throw error. */
67
67
  got(criteria: Criteria<T>): T {
68
- return this.get(criteria) ?? new EntityClass({})
68
+ let obj = this.get(criteria)
69
+ if (obj === undefined) {
70
+ throw (
71
+ EntityClass.name +
72
+ ' has no element matching ' +
73
+ JSON.stringify(criteria)
74
+ )
75
+ }
76
+ return obj
69
77
  }
70
78
 
71
79
  /** make reactive */