mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Fix pickers (#20315)
* Fix not found area picker * Fix no match for categories
This commit is contained in:
parent
bc8012dcc9
commit
db59e138e9
@ -136,20 +136,6 @@ export class HaAreaPicker extends LitElement {
|
|||||||
noAdd: this["noAdd"],
|
noAdd: this["noAdd"],
|
||||||
excludeAreas: this["excludeAreas"]
|
excludeAreas: this["excludeAreas"]
|
||||||
): AreaRegistryEntry[] => {
|
): AreaRegistryEntry[] => {
|
||||||
if (!areas.length) {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
area_id: NO_ITEMS_ID,
|
|
||||||
floor_id: null,
|
|
||||||
name: this.hass.localize("ui.components.area-picker.no_areas"),
|
|
||||||
picture: null,
|
|
||||||
icon: null,
|
|
||||||
aliases: [],
|
|
||||||
labels: [],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
let deviceEntityLookup: DeviceEntityDisplayLookup = {};
|
let deviceEntityLookup: DeviceEntityDisplayLookup = {};
|
||||||
let inputDevices: DeviceRegistryEntry[] | undefined;
|
let inputDevices: DeviceRegistryEntry[] | undefined;
|
||||||
let inputEntities: EntityRegistryDisplayEntry[] | undefined;
|
let inputEntities: EntityRegistryDisplayEntry[] | undefined;
|
||||||
@ -288,7 +274,7 @@ export class HaAreaPicker extends LitElement {
|
|||||||
{
|
{
|
||||||
area_id: NO_ITEMS_ID,
|
area_id: NO_ITEMS_ID,
|
||||||
floor_id: null,
|
floor_id: null,
|
||||||
name: this.hass.localize("ui.components.area-picker.no_match"),
|
name: this.hass.localize("ui.components.area-picker.no_areas"),
|
||||||
picture: null,
|
picture: null,
|
||||||
icon: null,
|
icon: null,
|
||||||
aliases: [],
|
aliases: [],
|
||||||
@ -376,20 +362,40 @@ export class HaAreaPicker extends LitElement {
|
|||||||
|
|
||||||
const filteredItems = fuzzyFilterSort<ScorableAreaRegistryEntry>(
|
const filteredItems = fuzzyFilterSort<ScorableAreaRegistryEntry>(
|
||||||
filterString,
|
filterString,
|
||||||
target.items || []
|
target.items?.filter(
|
||||||
|
(item) => ![NO_ITEMS_ID, ADD_NEW_ID].includes(item.label_id)
|
||||||
|
) || []
|
||||||
);
|
);
|
||||||
if (!this.noAdd && filteredItems?.length === 0) {
|
if (filteredItems.length === 0) {
|
||||||
this._suggestion = filterString;
|
if (!this.noAdd) {
|
||||||
this.comboBox.filteredItems = [
|
this.comboBox.filteredItems = [
|
||||||
{
|
{
|
||||||
area_id: ADD_NEW_SUGGESTION_ID,
|
area_id: NO_ITEMS_ID,
|
||||||
name: this.hass.localize(
|
floor_id: null,
|
||||||
"ui.components.area-picker.add_new_sugestion",
|
name: this.hass.localize("ui.components.area-picker.no_match"),
|
||||||
{ name: this._suggestion }
|
icon: null,
|
||||||
),
|
picture: null,
|
||||||
picture: null,
|
labels: [],
|
||||||
},
|
aliases: [],
|
||||||
];
|
},
|
||||||
|
] as AreaRegistryEntry[];
|
||||||
|
} else {
|
||||||
|
this._suggestion = filterString;
|
||||||
|
this.comboBox.filteredItems = [
|
||||||
|
{
|
||||||
|
area_id: ADD_NEW_SUGGESTION_ID,
|
||||||
|
floor_id: null,
|
||||||
|
name: this.hass.localize(
|
||||||
|
"ui.components.area-picker.add_new_sugestion",
|
||||||
|
{ name: this._suggestion }
|
||||||
|
),
|
||||||
|
icon: "mdi:plus",
|
||||||
|
picture: null,
|
||||||
|
labels: [],
|
||||||
|
aliases: [],
|
||||||
|
},
|
||||||
|
] as AreaRegistryEntry[];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.comboBox.filteredItems = filteredItems;
|
this.comboBox.filteredItems = filteredItems;
|
||||||
}
|
}
|
||||||
@ -409,6 +415,8 @@ export class HaAreaPicker extends LitElement {
|
|||||||
|
|
||||||
if (newValue === NO_ITEMS_ID) {
|
if (newValue === NO_ITEMS_ID) {
|
||||||
newValue = "";
|
newValue = "";
|
||||||
|
this.comboBox.setInputValue("");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![ADD_NEW_SUGGESTION_ID, ADD_NEW_ID].includes(newValue)) {
|
if (![ADD_NEW_SUGGESTION_ID, ADD_NEW_ID].includes(newValue)) {
|
||||||
|
@ -384,7 +384,7 @@ export class HaFloorPicker extends SubscribeMixin(LitElement) {
|
|||||||
this.comboBox.filteredItems = [
|
this.comboBox.filteredItems = [
|
||||||
{
|
{
|
||||||
floor_id: NO_FLOORS_ID,
|
floor_id: NO_FLOORS_ID,
|
||||||
name: this.hass.localize("ui.components.floor-picker.no_floors"),
|
name: this.hass.localize("ui.components.floor-picker.no_match"),
|
||||||
icon: null,
|
icon: null,
|
||||||
level: null,
|
level: null,
|
||||||
aliases: [],
|
aliases: [],
|
||||||
|
@ -188,9 +188,7 @@ export class HaCategoryPicker extends SubscribeMixin(LitElement) {
|
|||||||
this.comboBox.filteredItems = [
|
this.comboBox.filteredItems = [
|
||||||
{
|
{
|
||||||
category_id: NO_CATEGORIES_ID,
|
category_id: NO_CATEGORIES_ID,
|
||||||
name: this.hass.localize(
|
name: this.hass.localize("ui.components.category-picker.no_match"),
|
||||||
"ui.components.category-picker.no_categories"
|
|
||||||
),
|
|
||||||
icon: null,
|
icon: null,
|
||||||
},
|
},
|
||||||
] as ScorableCategoryRegistryEntry[];
|
] as ScorableCategoryRegistryEntry[];
|
||||||
|
@ -571,6 +571,7 @@
|
|||||||
"add_new_sugestion": "Add new category ''{name}''",
|
"add_new_sugestion": "Add new category ''{name}''",
|
||||||
"add_new": "Add new category…",
|
"add_new": "Add new category…",
|
||||||
"no_categories": "You don't have any categories",
|
"no_categories": "You don't have any categories",
|
||||||
|
"no_match": "No matching categories found",
|
||||||
"add_dialog": {
|
"add_dialog": {
|
||||||
"title": "Add new category",
|
"title": "Add new category",
|
||||||
"text": "Enter the name of the new category.",
|
"text": "Enter the name of the new category.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user