fix(webui): ordering of attributes in Selector
parent
b78d1be240
commit
de9f808b7a
|
@ -232,12 +232,13 @@
|
|||
}
|
||||
|
||||
if (types.includes('Attribute')) {
|
||||
let selectorOptions: SelectorOption[] = [];
|
||||
const allAttributes = await api.fetchAllAttributes({ abortController });
|
||||
const attributes = attributeOptions
|
||||
? allAttributes.filter((attr) => attributeOptions!.includes(attr.name))
|
||||
: allAttributes;
|
||||
if (emptyOptions === undefined || query.length > 0) {
|
||||
result.push(
|
||||
selectorOptions.push(
|
||||
...attributes
|
||||
.filter(
|
||||
(attr) =>
|
||||
|
@ -254,6 +255,10 @@
|
|||
);
|
||||
}
|
||||
|
||||
selectorOptions = matchSorter(selectorOptions, inputValue, {
|
||||
keys: [(i) => (i.t === 'Attribute' && i.labels) || [], 'name']
|
||||
});
|
||||
|
||||
const attributeToCreate = query.toUpperCase().replaceAll(/[^A-Z0-9]/g, '_');
|
||||
if (
|
||||
!attributeOptions &&
|
||||
|
@ -261,12 +266,14 @@
|
|||
!allAttributes.map((attr) => attr.name).includes(attributeToCreate) &&
|
||||
types.includes('NewAttribute')
|
||||
) {
|
||||
result.push({
|
||||
selectorOptions.push({
|
||||
t: 'NewAttribute',
|
||||
name: attributeToCreate,
|
||||
label: query
|
||||
});
|
||||
}
|
||||
|
||||
result.push(...selectorOptions);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
if (e && (e as Error).name !== 'AbortError') {
|
||||
|
|
Loading…
Reference in New Issue