Skip to content

Commit

Permalink
[#3799] parent project to allow delete
Browse files Browse the repository at this point in the history
  • Loading branch information
martinchristov committed Sep 24, 2019
1 parent 2c57665 commit 2bf6575
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const ProjectPicker = ({ fieldName, loading, projects, savedData, formPush, proj
onSearch={filterOptions}
notFoundContent={state.loading ? <Spin size="small" /> : (state.searchStr.length === 0 ? <span>{t('Start typing...')}</span> : <span>{t('No results')}</span>)}
filterOption={false}
allowClear
>
{$options.map(option => <Option value={option.value} key={option.value}>{option.label}</Option>)}
</Select>
Expand Down
9 changes: 6 additions & 3 deletions akvo/rsr/spa/app/utils/auto-save.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ const getRootValues = (values, sectionKey) => {
return ret
}

const transformUndefinedToEmptyString = (difference, lastSavedValues) => {
const transformUndefinedToEmptyStringOrNull = (difference, lastSavedValues) => {
Object.keys(difference).forEach(key => {
if (difference[key] === undefined && typeof lastSavedValues[key] === 'string') {
difference[key] = ''
}
else if (difference[key] === undefined && typeof lastSavedValues[key] === 'number') {
difference[key] = null
}
})
}

Expand Down Expand Up @@ -81,7 +84,7 @@ class AutoSave extends React.Component {
!(Object.keys(difference).indexOf('id') !== -1)
&& !(Object.keys(difference).length === 1 && Object.keys(difference)[0] === 'dimensionNames')
){
transformUndefinedToEmptyString(difference, savedValues)
transformUndefinedToEmptyStringOrNull(difference, savedValues)
if(!item.id){
this.props.addSetItem(sectionIndex, setName, item)
} else {
Expand All @@ -97,7 +100,7 @@ class AutoSave extends React.Component {
!isEmpty(difference)
&& !(Object.keys(difference).length === 1 && Object.keys(difference)[0] === 'publishingStatus')
){
transformUndefinedToEmptyString(difference, savedValues)
transformUndefinedToEmptyStringOrNull(difference, savedValues)
const isDiffOnlyCurrentImage = Object.keys(difference).length === 1 && Object.keys(difference)[0] === 'currentImage'
this.props.saveFields(difference, sectionIndex, isDiffOnlyCurrentImage)
}
Expand Down

0 comments on commit 2bf6575

Please sign in to comment.