Skip to content

Commit

Permalink
fix: render normal Autocomplete for link fields with predefined options
Browse files Browse the repository at this point in the history
(cherry picked from commit e4c5b9c)
  • Loading branch information
ruchamahabal authored and mergify[bot] committed Jun 7, 2024
1 parent 478343f commit 00228f2
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions frontend/src/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@
{{ props.label }}
</span>

<!-- Link -->
<Link
v-if="props.fieldtype === 'Link'"
:doctype="props.options"
:modelValue="modelValue"
:filters="props.linkFilters"
@update:modelValue="(v) => emit('update:modelValue', v)"
/>

<!-- Select -->
<!-- Select or Link field with predefined options -->
<Autocomplete
v-else-if="props.fieldtype === 'Select'"
v-if="props.fieldtype === 'Select' || props.documentList"
:class="isReadOnly ? 'pointer-events-none' : ''"
:placeholder="`Select ${props.label}`"
:options="selectionList"
@change="(v) => emit('update:modelValue', v?.value)"
:modelValue="modelValue"
@update:modelValue="(v) => emit('update:modelValue', v?.value)"
v-bind="$attrs"
:disabled="isReadOnly"
/>
<!-- Link field -->
<Link
v-else-if="props.fieldtype === 'Link'"
:doctype="props.options"
:modelValue="modelValue"
:filters="props.linkFilters"
@update:modelValue="(v) => emit('update:modelValue', v)"
/>
<!-- Text -->
<Input
v-else-if="
Expand Down Expand Up @@ -189,7 +190,9 @@ const isReadOnly = computed(() => {
})
const selectionList = computed(() => {
if (props.fieldtype == "Select" && props.options) {
if (props.fieldtype === "Link" && props.documentList) {
return props.documentList
} else if (props.fieldtype == "Select" && props.options) {
const options = props.options.split("\n")
return options.map((option) => ({
label: option,
Expand Down

0 comments on commit 00228f2

Please sign in to comment.