fix: removed SearchComplete component and replaced it with Link component
This commit is contained in:
parent
5b05a4e519
commit
fc4c144abe
@ -44,7 +44,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div id="value" class="!min-w-[140px]">
|
<div id="value" class="!min-w-[140px]">
|
||||||
<SearchComplete
|
<Link
|
||||||
v-if="typeLink.includes(f.field.fieldtype)"
|
v-if="typeLink.includes(f.field.fieldtype)"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
:value="f.value"
|
:value="f.value"
|
||||||
@ -105,7 +105,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import NestedPopover from '@/components/NestedPopover.vue'
|
import NestedPopover from '@/components/NestedPopover.vue'
|
||||||
import FilterIcon from '@/components/Icons/FilterIcon.vue'
|
import FilterIcon from '@/components/Icons/FilterIcon.vue'
|
||||||
import SearchComplete from '@/components/SearchComplete.vue'
|
import Link from '@/components/Controls/Link.vue'
|
||||||
import {
|
import {
|
||||||
FeatherIcon,
|
FeatherIcon,
|
||||||
Autocomplete,
|
Autocomplete,
|
||||||
|
|||||||
@ -1,85 +0,0 @@
|
|||||||
<template>
|
|
||||||
<Autocomplete
|
|
||||||
placeholder="Select an option"
|
|
||||||
:options="options"
|
|
||||||
:value="selection"
|
|
||||||
@update:query="(q) => onUpdateQuery(q)"
|
|
||||||
@change="(v) => (selection = v)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { Autocomplete, createListResource } from 'frappe-ui'
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
doctype: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
searchField: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: 'name',
|
|
||||||
},
|
|
||||||
labelField: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: 'name',
|
|
||||||
},
|
|
||||||
valueField: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: 'name',
|
|
||||||
},
|
|
||||||
pageLength: {
|
|
||||||
type: Number,
|
|
||||||
required: false,
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.doctype,
|
|
||||||
(value) => {
|
|
||||||
r.doctype = value
|
|
||||||
r.reload()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const r = createListResource({
|
|
||||||
doctype: props.doctype,
|
|
||||||
pageLength: props.pageLength,
|
|
||||||
cache: ['link_doctype', props.doctype],
|
|
||||||
auto: true,
|
|
||||||
fields: [props.labelField, props.searchField, props.valueField],
|
|
||||||
onSuccess: () => {
|
|
||||||
selection.value = props.value
|
|
||||||
? options.value.find((o) => o.value === props.value)
|
|
||||||
: null
|
|
||||||
},
|
|
||||||
})
|
|
||||||
const options = computed(
|
|
||||||
() =>
|
|
||||||
r.data?.map((result) => ({
|
|
||||||
label: result[props.labelField],
|
|
||||||
value: result[props.valueField],
|
|
||||||
})) || []
|
|
||||||
)
|
|
||||||
const selection = ref(null)
|
|
||||||
|
|
||||||
function onUpdateQuery(query) {
|
|
||||||
r.update({
|
|
||||||
filters: {
|
|
||||||
[props.searchField]: ['like', `%${query}%`],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
r.reload()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user