diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-21 13:56:27 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-21 13:56:27 -0700 |
commit | fcaa089ea298c9067a2b09a168cb4d90c88e8b54 (patch) | |
tree | 15c9a179bd8a157c084226eb8dee5a72fe94a70c /modern/src/settings | |
parent | c59d1418df08f9fbb4edb131b54d9f5947893388 (diff) | |
download | trackermap-web-fcaa089ea298c9067a2b09a168cb4d90c88e8b54.tar.gz trackermap-web-fcaa089ea298c9067a2b09a168cb4d90c88e8b54.tar.bz2 trackermap-web-fcaa089ea298c9067a2b09a168cb4d90c88e8b54.zip |
Remaining command attributes
Diffstat (limited to 'modern/src/settings')
-rw-r--r-- | modern/src/settings/CommandSendPage.js | 2 | ||||
-rw-r--r-- | modern/src/settings/components/BaseCommandView.js | 46 |
2 files changed, 34 insertions, 14 deletions
diff --git a/modern/src/settings/CommandSendPage.js b/modern/src/settings/CommandSendPage.js index a817e11d..cc0dae63 100644 --- a/modern/src/settings/CommandSendPage.js +++ b/modern/src/settings/CommandSendPage.js @@ -88,7 +88,7 @@ const CommandSendPage = () => { variant="filled" /> {!savedId && ( - <BaseCommandView item={item} setItem={setItem} /> + <BaseCommandView item={item} setItem={setItem} /> )} </AccordionDetails> </Accordion> diff --git a/modern/src/settings/components/BaseCommandView.js b/modern/src/settings/components/BaseCommandView.js index b422e153..836e8789 100644 --- a/modern/src/settings/components/BaseCommandView.js +++ b/modern/src/settings/components/BaseCommandView.js @@ -34,19 +34,39 @@ const BaseCommandView = ({ item, setItem }) => { label={t('sharedType')} variant="filled" /> - {attributes.map((attribute) => ( - <TextField - margin="normal" - value={item.attributes[attribute.key]} - onChange={(e) => { - const updateItem = { ...item, attributes: { ...item.attributes } }; - updateItem.attributes[attribute.key] = e.target.value; - setItem(updateItem); - }} - label={attribute.name} - variant="filled" - /> - ))} + {attributes.map(({ key, name, type }) => { + if (type === 'boolean') { + return ( + <FormControlLabel + control={( + <Checkbox + checked={item.attributes[key]} + onChange={(e) => { + const updateItem = { ...item, attributes: { ...item.attributes } }; + updateItem.attributes[key] = e.target.checked; + setItem(updateItem); + }} + /> + )} + label={name} + /> + ); + } + return ( + <TextField + margin="normal" + type={type === 'number' ? 'number' : 'text'} + value={item.attributes[key]} + onChange={(e) => { + const updateItem = { ...item, attributes: { ...item.attributes } }; + updateItem.attributes[key] = type === 'number' ? Number(e.target.value) : e.target.value; + setItem(updateItem); + }} + label={name} + variant="filled" + /> + ); + })} <FormControlLabel control={<Checkbox checked={item.textChannel} onChange={(event) => setItem({ ...item, textChannel: event.target.checked })} />} label={t('commandSendSms')} |