@adminforth/universal-search 1.3.0 → 1.4.1
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/build.log +2 -2
- package/custom/UniversalSearchInput.vue +42 -17
- package/dist/custom/UniversalSearchInput.vue +42 -17
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="af-universal-search flex items-center gap-1">
|
|
3
3
|
<slot name="prefix" />
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
<div class="relative w-64">
|
|
5
|
+
<input
|
|
6
|
+
v-model="localValue"
|
|
7
|
+
type="text"
|
|
8
|
+
:placeholder="props.meta?.placeholder ?? ''"
|
|
9
|
+
class="w-full border rounded text-sm dark:bg-gray-800 dark:border-gray-600 dark:text-white px-2 py-1 pr-6"
|
|
10
|
+
@keyup.enter="applyImmediate"
|
|
11
|
+
>
|
|
12
|
+
<p
|
|
13
|
+
v-if="localValue"
|
|
14
|
+
@click="clear"
|
|
15
|
+
class="absolute right-2 top-1/2 -translate-y-1/2 hover:cursor-pointer hover:text-gray-600 dark:text-white dark:hover:text-gray-400 "
|
|
16
|
+
>
|
|
17
|
+
✕
|
|
18
|
+
</p>
|
|
19
|
+
</div>
|
|
19
20
|
<slot name="suffix" />
|
|
20
21
|
</div>
|
|
21
22
|
</template>
|
|
22
23
|
<script setup lang="ts">
|
|
23
|
-
import { ref, watch } from 'vue';
|
|
24
|
+
import { ref, watch, onMounted } from 'vue';
|
|
24
25
|
import adminforth from '@/adminforth';
|
|
25
26
|
import { AdminForthFilterOperators } from '@/types/Common';
|
|
27
|
+
import { useRoute } from 'vue-router';
|
|
28
|
+
|
|
29
|
+
const route = useRoute();
|
|
26
30
|
|
|
27
31
|
const props = defineProps<{ meta?: any; resource?: any; adminUser?: any }>();
|
|
28
32
|
const localValue = ref('');
|
|
29
33
|
let t: any = null;
|
|
34
|
+
let blockFilterUpdate = false;
|
|
35
|
+
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
const filters = Object.keys(route.query).filter(k => k.startsWith('filter__')).map(k => {
|
|
38
|
+
const [_, field, operator] = k.split('__');
|
|
39
|
+
return {
|
|
40
|
+
field,
|
|
41
|
+
operator,
|
|
42
|
+
value: JSON.parse(decodeURIComponent(route.query[k] as string))
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const isUniversalSearchFilterApplied = filters.find(f => f.field === '_universal_search');
|
|
46
|
+
if (isUniversalSearchFilterApplied) {
|
|
47
|
+
localValue.value = isUniversalSearchFilterApplied.value;
|
|
48
|
+
blockFilterUpdate = true;
|
|
49
|
+
};
|
|
50
|
+
});
|
|
30
51
|
|
|
31
52
|
function send(term?: string) {
|
|
32
53
|
adminforth?.list?.updateFilter?.({
|
|
@@ -34,7 +55,6 @@ function send(term?: string) {
|
|
|
34
55
|
operator: AdminForthFilterOperators.EQ,
|
|
35
56
|
value: term || '',
|
|
36
57
|
});
|
|
37
|
-
adminforth?.list?.refresh?.();
|
|
38
58
|
}
|
|
39
59
|
|
|
40
60
|
function apply() {
|
|
@@ -49,12 +69,17 @@ function applyImmediate() {
|
|
|
49
69
|
}
|
|
50
70
|
|
|
51
71
|
watch(localValue, () => {
|
|
72
|
+
if (blockFilterUpdate) {
|
|
73
|
+
blockFilterUpdate = false;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
52
76
|
const delay = props.meta?.debounceMs ?? 500;
|
|
53
77
|
if (t) clearTimeout(t);
|
|
54
78
|
t = setTimeout(apply, delay);
|
|
55
79
|
});
|
|
56
80
|
|
|
57
81
|
function clear() {
|
|
82
|
+
blockFilterUpdate = true;
|
|
58
83
|
localValue.value = '';
|
|
59
84
|
applyImmediate();
|
|
60
85
|
}
|
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="af-universal-search flex items-center gap-1">
|
|
3
3
|
<slot name="prefix" />
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
<div class="relative w-64">
|
|
5
|
+
<input
|
|
6
|
+
v-model="localValue"
|
|
7
|
+
type="text"
|
|
8
|
+
:placeholder="props.meta?.placeholder ?? ''"
|
|
9
|
+
class="w-full border rounded text-sm dark:bg-gray-800 dark:border-gray-600 dark:text-white px-2 py-1 pr-6"
|
|
10
|
+
@keyup.enter="applyImmediate"
|
|
11
|
+
>
|
|
12
|
+
<p
|
|
13
|
+
v-if="localValue"
|
|
14
|
+
@click="clear"
|
|
15
|
+
class="absolute right-2 top-1/2 -translate-y-1/2 hover:cursor-pointer hover:text-gray-600 dark:text-white dark:hover:text-gray-400 "
|
|
16
|
+
>
|
|
17
|
+
✕
|
|
18
|
+
</p>
|
|
19
|
+
</div>
|
|
19
20
|
<slot name="suffix" />
|
|
20
21
|
</div>
|
|
21
22
|
</template>
|
|
22
23
|
<script setup lang="ts">
|
|
23
|
-
import { ref, watch } from 'vue';
|
|
24
|
+
import { ref, watch, onMounted } from 'vue';
|
|
24
25
|
import adminforth from '@/adminforth';
|
|
25
26
|
import { AdminForthFilterOperators } from '@/types/Common';
|
|
27
|
+
import { useRoute } from 'vue-router';
|
|
28
|
+
|
|
29
|
+
const route = useRoute();
|
|
26
30
|
|
|
27
31
|
const props = defineProps<{ meta?: any; resource?: any; adminUser?: any }>();
|
|
28
32
|
const localValue = ref('');
|
|
29
33
|
let t: any = null;
|
|
34
|
+
let blockFilterUpdate = false;
|
|
35
|
+
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
const filters = Object.keys(route.query).filter(k => k.startsWith('filter__')).map(k => {
|
|
38
|
+
const [_, field, operator] = k.split('__');
|
|
39
|
+
return {
|
|
40
|
+
field,
|
|
41
|
+
operator,
|
|
42
|
+
value: JSON.parse(decodeURIComponent(route.query[k] as string))
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const isUniversalSearchFilterApplied = filters.find(f => f.field === '_universal_search');
|
|
46
|
+
if (isUniversalSearchFilterApplied) {
|
|
47
|
+
localValue.value = isUniversalSearchFilterApplied.value;
|
|
48
|
+
blockFilterUpdate = true;
|
|
49
|
+
};
|
|
50
|
+
});
|
|
30
51
|
|
|
31
52
|
function send(term?: string) {
|
|
32
53
|
adminforth?.list?.updateFilter?.({
|
|
@@ -34,7 +55,6 @@ function send(term?: string) {
|
|
|
34
55
|
operator: AdminForthFilterOperators.EQ,
|
|
35
56
|
value: term || '',
|
|
36
57
|
});
|
|
37
|
-
adminforth?.list?.refresh?.();
|
|
38
58
|
}
|
|
39
59
|
|
|
40
60
|
function apply() {
|
|
@@ -49,12 +69,17 @@ function applyImmediate() {
|
|
|
49
69
|
}
|
|
50
70
|
|
|
51
71
|
watch(localValue, () => {
|
|
72
|
+
if (blockFilterUpdate) {
|
|
73
|
+
blockFilterUpdate = false;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
52
76
|
const delay = props.meta?.debounceMs ?? 500;
|
|
53
77
|
if (t) clearTimeout(t);
|
|
54
78
|
t = setTimeout(apply, delay);
|
|
55
79
|
});
|
|
56
80
|
|
|
57
81
|
function clear() {
|
|
82
|
+
blockFilterUpdate = true;
|
|
58
83
|
localValue.value = '';
|
|
59
84
|
applyImmediate();
|
|
60
85
|
}
|