aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/NotificationPage.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-12-05 17:23:44 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-12-05 17:23:44 -0800
commita4c2f0477dcda2662a3fd268f77a7549dead6e67 (patch)
tree4782c3456ae181f783d24f9892eec4a2c7f509c2 /modern/src/settings/NotificationPage.js
parent604eabcd97c6e7ddb42316a5a1fb0abc24e8dc7f (diff)
downloadtrackermap-web-a4c2f0477dcda2662a3fd268f77a7549dead6e67.tar.gz
trackermap-web-a4c2f0477dcda2662a3fd268f77a7549dead6e67.tar.bz2
trackermap-web-a4c2f0477dcda2662a3fd268f77a7549dead6e67.zip
Fix default and empty values (fix #802)
Diffstat (limited to 'modern/src/settings/NotificationPage.js')
-rw-r--r--modern/src/settings/NotificationPage.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/modern/src/settings/NotificationPage.js b/modern/src/settings/NotificationPage.js
index 2cf8a62f..33904e7f 100644
--- a/modern/src/settings/NotificationPage.js
+++ b/modern/src/settings/NotificationPage.js
@@ -36,7 +36,8 @@ const NotificationPage = () => {
<AccordionDetails className={classes.details}>
<SelectField
margin="normal"
- defaultValue={item.type}
+ value={item.type || 'alarm'}
+ emptyValue={null}
onChange={e => setItem({...item, type: e.target.value})}
endpoint="/api/notifications/types"
keyGetter={it => it.type}
@@ -46,18 +47,18 @@ const NotificationPage = () => {
<SelectField
multiple
margin="normal"
- defaultValue={item.notificators ? item.notificators.split(/[, ]+/) : []}
+ value={item.notificators ? item.notificators.split(/[, ]+/) : []}
onChange={e => setItem({...item, notificators: e.target.value.join()})}
endpoint="/api/notifications/notificators"
keyGetter={it => it.type}
titleGetter={it => t(prefixString('notificator', it.type))}
label={t('notificationNotificators')}
variant="filled" />
- {item.type === 'alarm' &&
+ {(!item.type || item.type === 'alarm') &&
<SelectField
multiple
margin="normal"
- defaultValue={item.attributes && item.attributes.alarms ? item.attributes.alarms.split(/[, ]+/) : []}
+ value={item.attributes && item.attributes.alarms ? item.attributes.alarms.split(/[, ]+/) : []}
onChange={e => setItem({...item, attributes: {...item.attributes, alarms: e.target.value.join()}})}
data={alarms}
keyGetter={it => it.key}