@adminforth/universal-search 1.3.0 → 1.4.0
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
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
v-model="localValue"
|
|
6
6
|
type="text"
|
|
7
7
|
:placeholder="props.meta?.placeholder ?? ''"
|
|
8
|
-
class="border rounded px-2 py-1 text-sm
|
|
8
|
+
class="border rounded px-2 py-1 text-sm dark:bg-gray-800 dark:border-gray-600"
|
|
9
|
+
:class="localValue ? 'w-[222px]' : 'w-64'"
|
|
9
10
|
@keyup.enter="applyImmediate"
|
|
10
11
|
/>
|
|
11
12
|
<button
|
|
@@ -20,13 +21,33 @@
|
|
|
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
|
}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
v-model="localValue"
|
|
6
6
|
type="text"
|
|
7
7
|
:placeholder="props.meta?.placeholder ?? ''"
|
|
8
|
-
class="border rounded px-2 py-1 text-sm
|
|
8
|
+
class="border rounded px-2 py-1 text-sm dark:bg-gray-800 dark:border-gray-600"
|
|
9
|
+
:class="localValue ? 'w-[222px]' : 'w-64'"
|
|
9
10
|
@keyup.enter="applyImmediate"
|
|
10
11
|
/>
|
|
11
12
|
<button
|
|
@@ -20,13 +21,33 @@
|
|
|
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
|
}
|