Fixed switch update according to switch rule
This commit is contained in:
@@ -14,14 +14,6 @@ import {
|
||||
} from "grommet";
|
||||
import { Close, Trash } from "grommet-icons";
|
||||
|
||||
const CONNECT_DEVICE = gql`
|
||||
mutation connectDevice($id: String!) {
|
||||
connectDevice(id: $id) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const MSGS_FRAGMENT = gql`
|
||||
fragment DeviceMsgs on Device {
|
||||
messages
|
||||
@@ -30,9 +22,6 @@ const MSGS_FRAGMENT = gql`
|
||||
|
||||
const Device = ({ device, messages, onMessagesClosed }) => {
|
||||
const client = useApolloClient();
|
||||
const [connect] = useMutation(CONNECT_DEVICE, {
|
||||
variables: { id: device.id },
|
||||
});
|
||||
const [groups, setGroups] = useState([]);
|
||||
const [selectedTabs, setSelectedTabs] = useState({});
|
||||
const [currentTab, setCurrentTab] = useState(0);
|
||||
@@ -49,14 +38,6 @@ const Device = ({ device, messages, onMessagesClosed }) => {
|
||||
|
||||
return (
|
||||
<Box>
|
||||
{!device.connected && (
|
||||
<Button
|
||||
label="Connect"
|
||||
onClick={() => {
|
||||
connect();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Tabs
|
||||
justify="start"
|
||||
activeIndex={currentTab}
|
||||
|
||||
@@ -20,13 +20,20 @@ const SwitchVector = ({ vector }) => {
|
||||
key={v.name}
|
||||
label={v.label}
|
||||
onClick={() => {
|
||||
if (vector.rule === 0 && v.switch === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newValues = vector.values.map((val) => {
|
||||
if (v.name === val.name) {
|
||||
return { name: val.name, value: true };
|
||||
if (vector.rule === 0) {
|
||||
|
||||
}
|
||||
return { name: val.name, value: vector.rule === 0 ? true : !val.switch};
|
||||
} else {
|
||||
return {
|
||||
name: val.name,
|
||||
value: vector.rule === 0 ? false : val.switch,
|
||||
value: vector.rule === 0 || vector.rule === 1 ? false : val.switch,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user