style(webui): reorder options in selector
parent
2c75a76446
commit
1890b29624
|
@ -146,49 +146,6 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (types.includes("Attribute")) {
|
||||
const allAttributes = await api.fetchAllAttributes();
|
||||
const attributes = attributeOptions
|
||||
? allAttributes.filter((attr) => attributeOptions.includes(attr.name))
|
||||
: allAttributes;
|
||||
if (emptyOptions === undefined || query.length > 0) {
|
||||
options.push(
|
||||
...attributes
|
||||
.filter(
|
||||
(attr) =>
|
||||
attr.name.toLowerCase().includes(query.toLowerCase()) ||
|
||||
attr.labels.some((label) =>
|
||||
label.toLowerCase().includes(query.toLowerCase()),
|
||||
),
|
||||
)
|
||||
.map(
|
||||
(attribute) =>
|
||||
({
|
||||
t: "Attribute",
|
||||
...attribute,
|
||||
}) as SelectorOption,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const attributeToCreate = query
|
||||
.toUpperCase()
|
||||
.replaceAll(/[^A-Z0-9]/g, "_");
|
||||
if (
|
||||
!attributeOptions &&
|
||||
query &&
|
||||
!allAttributes.map((attr) => attr.name).includes(attributeToCreate) &&
|
||||
types.includes("NewAttribute")
|
||||
) {
|
||||
options.push({
|
||||
t: "NewAttribute",
|
||||
name: attributeToCreate,
|
||||
label: query,
|
||||
});
|
||||
}
|
||||
options = options;
|
||||
}
|
||||
|
||||
if (types.includes("Number")) {
|
||||
const number = parseFloat(query);
|
||||
if (!Number.isNaN(number)) {
|
||||
|
@ -255,6 +212,49 @@
|
|||
);
|
||||
}
|
||||
|
||||
if (types.includes("Attribute")) {
|
||||
const allAttributes = await api.fetchAllAttributes();
|
||||
const attributes = attributeOptions
|
||||
? allAttributes.filter((attr) => attributeOptions.includes(attr.name))
|
||||
: allAttributes;
|
||||
if (emptyOptions === undefined || query.length > 0) {
|
||||
options.push(
|
||||
...attributes
|
||||
.filter(
|
||||
(attr) =>
|
||||
attr.name.toLowerCase().includes(query.toLowerCase()) ||
|
||||
attr.labels.some((label) =>
|
||||
label.toLowerCase().includes(query.toLowerCase()),
|
||||
),
|
||||
)
|
||||
.map(
|
||||
(attribute) =>
|
||||
({
|
||||
t: "Attribute",
|
||||
...attribute,
|
||||
}) as SelectorOption,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const attributeToCreate = query
|
||||
.toUpperCase()
|
||||
.replaceAll(/[^A-Z0-9]/g, "_");
|
||||
if (
|
||||
!attributeOptions &&
|
||||
query &&
|
||||
!allAttributes.map((attr) => attr.name).includes(attributeToCreate) &&
|
||||
types.includes("NewAttribute")
|
||||
) {
|
||||
options.push({
|
||||
t: "NewAttribute",
|
||||
name: attributeToCreate,
|
||||
label: query,
|
||||
});
|
||||
}
|
||||
options = options;
|
||||
}
|
||||
|
||||
options = options;
|
||||
}, 200);
|
||||
|
||||
|
|
Loading…
Reference in New Issue