diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-02 17:13:33 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-02 17:13:33 -0700 |
commit | f52be84522da7f8e1c2b19d3484250e275252799 (patch) | |
tree | f13316af299e5f1665cbb0e9d73a5f9ffc04d961 /modern/src/settings | |
parent | 3a8a11c5d101c30cabf727f6a27a892e9bc4c99a (diff) | |
download | trackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.tar.gz trackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.tar.bz2 trackermap-web-f52be84522da7f8e1c2b19d3484250e275252799.zip |
Implement model validation
Diffstat (limited to 'modern/src/settings')
-rw-r--r-- | modern/src/settings/CalendarPage.js | 9 | ||||
-rw-r--r-- | modern/src/settings/CommandPage.js | 4 | ||||
-rw-r--r-- | modern/src/settings/ComputedAttributePage.js | 9 | ||||
-rw-r--r-- | modern/src/settings/DriverPage.js | 9 | ||||
-rw-r--r-- | modern/src/settings/GroupPage.js | 9 | ||||
-rw-r--r-- | modern/src/settings/MaintenancePage.js | 9 | ||||
-rw-r--r-- | modern/src/settings/NotificationPage.js | 14 |
7 files changed, 35 insertions, 28 deletions
diff --git a/modern/src/settings/CalendarPage.js b/modern/src/settings/CalendarPage.js index 60d4ef76..0d35d2f3 100644 --- a/modern/src/settings/CalendarPage.js +++ b/modern/src/settings/CalendarPage.js @@ -34,10 +34,11 @@ const CalendarPage = () => { } }; + const validate = () => item && item.name && item.data; + return ( - <EditItemView endpoint="calendars" item={item} setItem={setItem}> - {item - && ( + <EditItemView endpoint="calendars" item={item} setItem={setItem} validate={validate}> + {item && ( <> <Accordion defaultExpanded> <AccordionSummary expandIcon={<ExpandMoreIcon />}> @@ -74,7 +75,7 @@ const CalendarPage = () => { </AccordionDetails> </Accordion> </> - )} + )} </EditItemView> ); }; diff --git a/modern/src/settings/CommandPage.js b/modern/src/settings/CommandPage.js index 8a7f5b94..0b0f54b6 100644 --- a/modern/src/settings/CommandPage.js +++ b/modern/src/settings/CommandPage.js @@ -30,8 +30,10 @@ const CommandPage = () => { } }, [availableAttributes, item]); + const validate = () => item && item.type; + return ( - <EditItemView endpoint="commands" item={item} setItem={setItem}> + <EditItemView endpoint="commands" item={item} setItem={setItem} validate={validate}> {item && ( <Accordion defaultExpanded> <AccordionSummary expandIcon={<ExpandMoreIcon />}> diff --git a/modern/src/settings/ComputedAttributePage.js b/modern/src/settings/ComputedAttributePage.js index 99bbfadb..2aa40ef0 100644 --- a/modern/src/settings/ComputedAttributePage.js +++ b/modern/src/settings/ComputedAttributePage.js @@ -39,10 +39,11 @@ const ComputedAttributePage = () => { } }; + const validate = () => item && item.description && item.expression; + return ( - <EditItemView endpoint="attributes/computed" item={item} setItem={setItem}> - {item - && ( + <EditItemView endpoint="attributes/computed" item={item} setItem={setItem} validate={validate}> + {item && ( <Accordion defaultExpanded> <AccordionSummary expandIcon={<ExpandMoreIcon />}> <Typography variant="subtitle1"> @@ -95,7 +96,7 @@ const ComputedAttributePage = () => { </FormControl> </AccordionDetails> </Accordion> - )} + )} </EditItemView> ); }; diff --git a/modern/src/settings/DriverPage.js b/modern/src/settings/DriverPage.js index a185405e..ff703916 100644 --- a/modern/src/settings/DriverPage.js +++ b/modern/src/settings/DriverPage.js @@ -20,10 +20,11 @@ const DriverPage = () => { const [item, setItem] = useState(); + const validate = () => item && item.name && item.uniqueId; + return ( - <EditItemView endpoint="drivers" item={item} setItem={setItem}> - {item - && ( + <EditItemView endpoint="drivers" item={item} setItem={setItem} validate={validate}> + {item && ( <> <Accordion defaultExpanded> <AccordionSummary expandIcon={<ExpandMoreIcon />}> @@ -63,7 +64,7 @@ const DriverPage = () => { </AccordionDetails> </Accordion> </> - )} + )} </EditItemView> ); }; diff --git a/modern/src/settings/GroupPage.js b/modern/src/settings/GroupPage.js index be14e96e..3750fc0e 100644 --- a/modern/src/settings/GroupPage.js +++ b/modern/src/settings/GroupPage.js @@ -25,10 +25,11 @@ const GroupPage = () => { const [item, setItem] = useState(); + const validate = () => item && item.name; + return ( - <EditItemView endpoint="groups" item={item} setItem={setItem}> - {item - && ( + <EditItemView endpoint="groups" item={item} setItem={setItem} validate={validate}> + {item && ( <> <Accordion defaultExpanded> <AccordionSummary expandIcon={<ExpandMoreIcon />}> @@ -78,7 +79,7 @@ const GroupPage = () => { </AccordionDetails> </Accordion> </> - )} + )} </EditItemView> ); }; diff --git a/modern/src/settings/MaintenancePage.js b/modern/src/settings/MaintenancePage.js index c157ff48..a612abb7 100644 --- a/modern/src/settings/MaintenancePage.js +++ b/modern/src/settings/MaintenancePage.js @@ -94,10 +94,11 @@ const MaintenancePage = () => { return value; }; + const validate = () => item && item.name && item.type && item.start && item.period; + return ( - <EditItemView endpoint="maintenance" item={item} setItem={setItem}> - {item - && ( + <EditItemView endpoint="maintenance" item={item} setItem={setItem} validate={validate}> + {item && ( <> <Accordion defaultExpanded> <AccordionSummary expandIcon={<ExpandMoreIcon />}> @@ -163,7 +164,7 @@ const MaintenancePage = () => { </AccordionDetails> </Accordion> </> - )} + )} </EditItemView> ); }; diff --git a/modern/src/settings/NotificationPage.js b/modern/src/settings/NotificationPage.js index 67c4ee05..0352683a 100644 --- a/modern/src/settings/NotificationPage.js +++ b/modern/src/settings/NotificationPage.js @@ -26,10 +26,11 @@ const NotificationPage = () => { name: t(it), })); + const validate = () => item && item.type && item.notificators; + return ( - <EditItemView endpoint="notifications" item={item} setItem={setItem}> - {item - && ( + <EditItemView endpoint="notifications" item={item} setItem={setItem} validate={validate}> + {item && ( <> <Accordion defaultExpanded> <AccordionSummary expandIcon={<ExpandMoreIcon />}> @@ -60,8 +61,7 @@ const NotificationPage = () => { label={t('notificationNotificators')} variant="filled" /> - {(!item.type || item.type === 'alarm') - && ( + {(!item.type || item.type === 'alarm') && ( <SelectField multiple margin="normal" @@ -72,7 +72,7 @@ const NotificationPage = () => { label={t('sharedAlarms')} variant="filled" /> - )} + )} <FormControlLabel control={( <Checkbox @@ -85,7 +85,7 @@ const NotificationPage = () => { </AccordionDetails> </Accordion> </> - )} + )} </EditItemView> ); }; |