full tag support on UI
This commit is contained in:
1 parent
7ea923a050
commit
4f78e42699
6 files changed
+36
-80
No files matched your search
@@ -59,15 +59,15 @@ export const FewAutos = Template.bind({})
|
||||
FewAutos.args = {
|
||||
...FewAutos.args,
|
||||
automations: [
|
||||
createMockAuto(),
|
||||
createMockAuto(),
|
||||
createMockAuto(),
|
||||
createMockAuto(),
|
||||
createMockAuto(),
|
||||
createMockAuto(),
|
||||
createMockAuto(),
|
||||
createMockAuto(),
|
||||
createMockAuto(),
|
||||
createMockAuto({ "Room": "Bathroom", "Type": "Lights", "NewDevice": "Yes", "Remote": "No", "Floor": "1" }),
|
||||
createMockAuto({ "Room": "Bathroom", "Type": "Climate" }),
|
||||
createMockAuto({ "Room": "Living Room", "Type": "Climate" }),
|
||||
createMockAuto({ "Type": "Climate" }),
|
||||
createMockAuto({ "Type": "Lights", "Routine": "Myself" }),
|
||||
createMockAuto({ "Routine": "DNS", "Type": "SSL" }),
|
||||
createMockAuto({ "Room": "Bedroom", "Type": "Lights", "Routine": "Baby" }),
|
||||
createMockAuto({ "Room": "Office", "Type": "Lights" }),
|
||||
createMockAuto({ "Room": "Office" }),
|
||||
createMockAuto(),
|
||||
],
|
||||
}
|
||||
@@ -52,10 +52,10 @@
|
||||
padding-left: 1em;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
justify-content: left;
|
||||
align-items: flex-start;
|
||||
gap: 1em;
|
||||
/* position: relative; */
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.automation-list-box--body--item::before {
|
||||
content: "⊚ ";
|
||||
@@ -64,6 +64,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-left: 0.25em;
|
||||
flex: 1;
|
||||
}
|
||||
.automation-list-box--body--item--title > b {
|
||||
font-size: 1em;
|
||||
|
||||
@@ -10,8 +10,8 @@ import { TrashIcon } from "components/Icons";
|
||||
export type Props = {
|
||||
automations: AutomationData[];
|
||||
onSelectAutomation: (i: number) => void;
|
||||
onRemove: (i: number) => void;
|
||||
onAdd: () => void;
|
||||
onRemove: () => void;
|
||||
}
|
||||
|
||||
export const AutomationListBox: FC<Props> = ({
|
||||
@@ -39,6 +39,7 @@ export const AutomationListBox: FC<Props> = ({
|
||||
selected={selected}
|
||||
onChange={setSelected}
|
||||
options={tags}
|
||||
max={3}
|
||||
/>
|
||||
</div>
|
||||
<div className="automation-list-box--body">
|
||||
@@ -129,7 +130,7 @@ const convertGroupsToItems = (
|
||||
return <div
|
||||
key={i}
|
||||
className="automation-list-box--body--item"
|
||||
title={`${auto.metadata.alias}\n ID=${auto.metadata.id}\n${auto.metadata.description}`}
|
||||
title={`Name = ${auto.metadata.alias}\nID = ${auto.metadata.id}\nDescription = ${auto.metadata.description}`}
|
||||
>
|
||||
<div
|
||||
className="automation-list-box--body--item--title"
|
||||
@@ -137,14 +138,13 @@ const convertGroupsToItems = (
|
||||
>
|
||||
<b>{auto.metadata.alias.slice(0, 15)} <span>({auto.metadata.id.slice(0, 5)})</span></b>
|
||||
<span>{auto.metadata.description.slice(0, 25)}</span>
|
||||
</div>
|
||||
<div
|
||||
className="automation-list-box--body--item--tags"
|
||||
onClick={() => onSelectAutomation(autoIndex)}
|
||||
>
|
||||
{Object.keys(auto.metadata.tags).map(tagName => <span key={tagName}>
|
||||
<b>{tagName}:</b> {auto.metadata.tags[tagName]}
|
||||
</span>)}
|
||||
<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]}
|
||||
</span>)}
|
||||
</div>
|
||||
</div>
|
||||
<Button onClick={() => onRemove(autoIndex)}><TrashIcon /></Button>
|
||||
</div>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
.automation-list--list {
|
||||
flex : 1;
|
||||
min-width: 200px;
|
||||
max-width: 200px;
|
||||
min-width: 400px;
|
||||
max-width: 400px;
|
||||
position : relative;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
}
|
||||
|
||||
/* list children: on hide */
|
||||
.automation-list--list.hide>.automation-list--list-box {
|
||||
display: none;
|
||||
.automation-list--list.hide>.automation-list-box {
|
||||
width: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.automation-list--list.hide {
|
||||
@@ -43,45 +44,3 @@
|
||||
bottom : 10px;
|
||||
right : 5px;
|
||||
}
|
||||
|
||||
|
||||
.automation-list--list-box {
|
||||
overflow : auto;
|
||||
height : 100%;
|
||||
display : flex;
|
||||
flex-direction : column;
|
||||
justify-content: flex-start;
|
||||
align-items : center;
|
||||
padding-top : 10px;
|
||||
margin-bottom : 10px;
|
||||
}
|
||||
|
||||
.automation-list--list-box>* {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.automation-list--list-box>:last-child {
|
||||
background-color: #070;
|
||||
color : white;
|
||||
}
|
||||
|
||||
.automation-list--elm {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.automation-list--elm>button {
|
||||
padding-left : 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.automation-list--elm>button>span {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
.automation-list--elm>.automation-list--elm-remove {
|
||||
position: absolute;
|
||||
left : -10px;
|
||||
top : 10%;
|
||||
padding : 0;
|
||||
margin : 0;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { defaultAutomation } from '../../utils/defaults';
|
||||
import { ArrowIcon, TrashIcon } from "components/Icons";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import { ApiService } from "apiService/core";
|
||||
import { AutomationListBox } from "./AutomationListBox";
|
||||
|
||||
|
||||
interface AutomationListParams {
|
||||
@@ -35,21 +36,15 @@ export const AutomationList: FC<AutomationListParams> = ({
|
||||
// render
|
||||
return <div className="automation-list--root">
|
||||
<div className={automationListListCls}>
|
||||
<div className="automation-list--list-box">
|
||||
{automations.map((auto, i) =>
|
||||
<div key={i} className="automation-list--elm">
|
||||
<Button onClick={() => onRemove(i)} className="automation-list--elm-remove"><TrashIcon /></Button>
|
||||
<Button onClick={() => setCurrent(i)}>
|
||||
{auto.metadata.alias.slice(0, 15)} <br />
|
||||
<span>{auto.metadata.description.slice(0, 25)}</span>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<Button onClick={() => {
|
||||
<AutomationListBox
|
||||
automations={automations}
|
||||
onAdd={() => {
|
||||
onAdd(defaultAutomation(`shortu-${automations.length}`));
|
||||
setCurrent(automations.length)
|
||||
}}>Add</Button>
|
||||
</div>
|
||||
}}
|
||||
onSelectAutomation={setCurrent}
|
||||
onRemove={onRemove}
|
||||
/>
|
||||
<ButtonIcon
|
||||
onClick={() => setHideList(!hideList)}
|
||||
className="automation-list--list-hide"
|
||||
|
||||
@@ -43,6 +43,7 @@ export default function InputMultiSelect<T extends string>({
|
||||
const isSelected = selectedCount > -1;
|
||||
return <div
|
||||
key={i}
|
||||
title={(maxedOut && !isSelected) ? `Maximum allowed to select is ${max}.` : isSelected ? `Unselect ${v}` : `Select ${v}`}
|
||||
className={[classes.option, isSelected ? 'selected' : 'unselected'].join(' ')}
|
||||
onClick={() => {
|
||||
if (!isSelected) {
|
||||
|
||||
Reference in new issue
Block a user