refactor: refs #8647 simplify filter handling logic in VnSelect component
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
73b73cba62
commit
13a904290c
|
@ -251,26 +251,29 @@ async function filterHandler(val, update) {
|
|||
|
||||
if ($props.filterFn) update($props.filterFn(val));
|
||||
else if (!val && lastVal.value === val) update();
|
||||
else if (
|
||||
$props.url &&
|
||||
($props.limit || (!$props.limit && Object.keys(myOptions.value).length === 0))
|
||||
) {
|
||||
newOptions = await fetchFilter(val);
|
||||
} else newOptions = filter(val, myOptionsOriginal.value);
|
||||
update(
|
||||
() => {
|
||||
if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase()))
|
||||
newOptions.unshift(noOneOpt.value);
|
||||
else {
|
||||
const makeRequest =
|
||||
($props.url && $props.limit) ||
|
||||
(!$props.limit && Object.keys(myOptions.value).length === 0);
|
||||
newOptions = makeRequest
|
||||
? await fetchFilter(val)
|
||||
: filter(val, myOptionsOriginal.value);
|
||||
|
||||
myOptions.value = newOptions;
|
||||
},
|
||||
(ref) => {
|
||||
if (val !== '' && ref.options.length > 0) {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
update(
|
||||
() => {
|
||||
if ($props.noOne && noOneText.toLowerCase().includes(val.toLowerCase()))
|
||||
newOptions.unshift(noOneOpt.value);
|
||||
|
||||
myOptions.value = newOptions;
|
||||
},
|
||||
(ref) => {
|
||||
if (val !== '' && ref.options.length > 0) {
|
||||
ref.setOptionIndex(-1);
|
||||
ref.moveOptionSelection(1, true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
lastVal.value = val;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue