matching tag definitions

This commit is contained in:
ari committed 2022-04-23 22:07:11 -04:00
1 parent bd3cfdf859
commit 46209564f0
7 files changed
+24 -25

No files matched your search

@@ -34,6 +34,5 @@ Basic.args = {
'wowo': '!'
},
mode: 'single',
tags: {},
},
}
@@ -38,6 +38,7 @@ export const Simple = Template.bind({})
Simple.args = {
...Simple.args,
automation: {
tags: {},
metadata: {
id: "random",
alias: "Random",
@@ -46,7 +47,6 @@ Simple.args = {
'wowo': '!'
},
mode: 'single',
tags: {},
},
trigger: [
{
@@ -108,6 +108,7 @@ export const EmptyStart = Template.bind({})
EmptyStart.args = {
...EmptyStart.args,
automation: {
tags: {},
metadata: {
id: "random",
alias: "Random",
@@ -116,7 +117,6 @@ EmptyStart.args = {
'wowo': '!'
},
mode: 'single',
tags: {},
},
trigger: [
],
@@ -10,10 +10,10 @@ test('group automations', () => {
alias: '',
description: '',
mode: 'single',
tags: {
"Room": 'Living Room',
"Type": 'Lights'
}
},
tags: {
"Room": 'Living Room',
"Type": 'Lights'
},
sequence: [],
trigger: [],
@@ -24,10 +24,10 @@ test('group automations', () => {
alias: '',
description: '',
mode: 'single',
tags: {
"Room": 'Living Room',
"Type": 'Climate'
}
},
tags: {
"Room": 'Living Room',
"Type": 'Climate'
},
sequence: [],
trigger: [],
@@ -38,10 +38,10 @@ test('group automations', () => {
alias: '',
description: '',
mode: 'single',
tags: {
"Room": 'Kitchen',
"Type": 'Climate'
}
},
tags: {
"Room": 'Kitchen',
"Type": 'Climate'
},
sequence: [],
trigger: [],
@@ -54,7 +54,7 @@ export const AutomationListBox: FC<Props> = ({
export const getTagList = (autos: AutomationData[]): string[] => Object.keys(autos
.map(a => Object.keys(a.metadata.tags))
.map(a => Object.keys(a.tags))
.reduce((all: any, keys) => {
for (const k of keys) {
all[k] = 1
@@ -75,7 +75,7 @@ const filterAutomations = (autos: AutomationData[], searchText: string, selected
}
if (selected.length > 0) {
for (const i of selected) {
if (!a.metadata.tags[tags[i]]) {
if (!a.tags[tags[i]]) {
return false
}
}
@@ -103,10 +103,10 @@ export const groupAutomations = (
if (lastKey !== null) {
where = where[lastKey]
}
if (!where[a.metadata.tags[tag]]) {
where[a.metadata.tags[tag]] = {}
if (!where[a.tags[tag]]) {
where[a.tags[tag]] = {}
}
lastKey = a.metadata.tags[tag]
lastKey = a.tags[tag]
}
if (lastKey !== null) {
if (!where[lastKey] || !Array.isArray(where[lastKey])) {
@@ -141,8 +141,8 @@ const convertGroupsToItems = (
<div
className="automation-list-box--body--item--tags"
>
{Object.keys(auto.metadata.tags).map(tagName => <span key={tagName}>
<b>{tagName}:</b> {auto.metadata.tags[tagName]}
{Object.keys(auto.tags).map(tagName => <span key={tagName}>
<b>{tagName}:</b> {auto.tags[tagName]}
</span>)}
</div>
</div>