diff options
author | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2021-01-06 15:53:48 +0530 |
---|---|---|
committer | Ashutosh Bishnoi <mail2bishnoi@gmail.com> | 2021-01-06 15:53:48 +0530 |
commit | a87f06b4cb10014b431e0a3ea8d6ba1da5a02fc1 (patch) | |
tree | ec5312d6ba0265323ea8f424a8df167df1e52046 /modern/src/settings | |
parent | 3fb3b5334e11c1239b5126767c4160da79d1cfe9 (diff) | |
download | trackermap-web-a87f06b4cb10014b431e0a3ea8d6ba1da5a02fc1.tar.gz trackermap-web-a87f06b4cb10014b431e0a3ea8d6ba1da5a02fc1.tar.bz2 trackermap-web-a87f06b4cb10014b431e0a3ea8d6ba1da5a02fc1.zip |
computed attribute code improvements
Diffstat (limited to 'modern/src/settings')
-rw-r--r-- | modern/src/settings/ComputedAttributePage.js | 22 | ||||
-rw-r--r-- | modern/src/settings/ComputedAttributesPage.js | 2 |
2 files changed, 13 insertions, 11 deletions
diff --git a/modern/src/settings/ComputedAttributePage.js b/modern/src/settings/ComputedAttributePage.js index f985152f..7ff9511f 100644 --- a/modern/src/settings/ComputedAttributePage.js +++ b/modern/src/settings/ComputedAttributePage.js @@ -25,6 +25,17 @@ const ComputedAttributePage =() => { type: value.type, })); + const handleChange = event => { + const newValue = event.target.value; + setKey(newValue); + const positionAttribute = positionAttributes[newValue]; + if(positionAttribute && positionAttribute.type) { + setItem({...item, attribute: newValue, type: positionAttribute.type}); + } else { + setItem({...item, attribute: newValue}); + } + } + return ( <EditItemView endpoint="/attributes/computed" item={item} setItem={setItem}> {item && @@ -45,16 +56,7 @@ const ComputedAttributePage =() => { <InputLabel>{t('sharedAttribute')}</InputLabel> <Select value={item.attribute || ''} - onChange={(e) => { - const newValue = e.target.value; - const positionAttribute = positionAttributes[newValue]; - setKey(newValue); - if(positionAttribute && positionAttribute.type) { - setItem({...item, attribute: newValue, type: positionAttribute.type}); - }else { - setItem({...item, attribute: newValue}); - } - }}> + onChange={handleChange}> {options.map((option) => ( <MenuItem key={option.key} value={option.key}>{option.name}</MenuItem> ))} diff --git a/modern/src/settings/ComputedAttributesPage.js b/modern/src/settings/ComputedAttributesPage.js index 9ca5b69d..53d1172c 100644 --- a/modern/src/settings/ComputedAttributesPage.js +++ b/modern/src/settings/ComputedAttributesPage.js @@ -61,7 +61,7 @@ const ComputedAttributesPage = () => { return ( <> <MainToolbar /> - <EditCollectionView content={ComputedAttributeView} editPath="/settings/attribute/computed" endpoint="attributes/computed" /> + <EditCollectionView content={ComputedAttributeView} editPath="/settings/attribute" endpoint="attributes/computed" /> </> ); } |