mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
fix: prevent Create from appearing as Link value
This commit is contained in:
parent
110dee04eb
commit
6c5dd3a4f9
@ -82,7 +82,7 @@ export default {
|
||||
value: {
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
this.linkValue = this.getLabel(newValue);
|
||||
this.linkValue = this.getLinkValue(newValue);
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -90,7 +90,7 @@ export default {
|
||||
doc: { default: null },
|
||||
},
|
||||
mounted() {
|
||||
this.linkValue = this.getLabel(this.linkValue || this.value);
|
||||
this.linkValue = this.getLinkValue(this.linkValue || this.value);
|
||||
},
|
||||
computed: {
|
||||
options() {
|
||||
@ -102,7 +102,7 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getLabel(value) {
|
||||
getLinkValue(value) {
|
||||
const oldValue = this.linkValue;
|
||||
let option = this.options.find((o) => o.value === value);
|
||||
if (option === undefined) {
|
||||
@ -111,14 +111,6 @@ export default {
|
||||
|
||||
return option?.label ?? oldValue;
|
||||
},
|
||||
getValue(label) {
|
||||
let option = this.options.find((o) => o.label === label);
|
||||
if (option === undefined) {
|
||||
option = this.options.find((o) => o.value === label);
|
||||
}
|
||||
|
||||
return option?.value ?? label;
|
||||
},
|
||||
async updateSuggestions(keyword) {
|
||||
if (typeof keyword === 'string') {
|
||||
this.linkValue = keyword;
|
||||
@ -156,6 +148,11 @@ export default {
|
||||
.map(({ item }) => item);
|
||||
},
|
||||
setSuggestion(suggestion) {
|
||||
if (suggestion?.actionOnly) {
|
||||
this.linkValue = this.value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (suggestion) {
|
||||
this.linkValue = suggestion.label;
|
||||
this.triggerChange(suggestion.value);
|
||||
|
@ -17,10 +17,6 @@ export default {
|
||||
if (this.value) {
|
||||
this.linkValue = this.value;
|
||||
}
|
||||
|
||||
if (this.df.fieldname === 'incomeAccount') {
|
||||
window.l = this;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
@ -89,6 +85,7 @@ export default {
|
||||
'<span class="text-gray-600">{{ t`No results found` }}</span>',
|
||||
}),
|
||||
action: () => {},
|
||||
actionOnly: true,
|
||||
},
|
||||
];
|
||||
}
|
||||
@ -98,8 +95,8 @@ export default {
|
||||
getCreateNewOption() {
|
||||
return {
|
||||
label: t`Create`,
|
||||
value: 'Create',
|
||||
action: () => this.openNewDoc(),
|
||||
actionOnly: true,
|
||||
component: markRaw({
|
||||
template:
|
||||
'<div class="flex items-center font-semibold">{{ t`Create` }}' +
|
||||
|
Loading…
Reference in New Issue
Block a user