diff --git a/openbis_ng_ui/src/js/components/types/form/TypeForm.jsx b/openbis_ng_ui/src/js/components/types/form/TypeForm.jsx index 27dd562c81d9cf37a2f196cd1189015920a10126..94b78d55be2b7a51258ae1a5c03ea3582281cb4c 100644 --- a/openbis_ng_ui/src/js/components/types/form/TypeForm.jsx +++ b/openbis_ng_ui/src/js/components/types/form/TypeForm.jsx @@ -97,6 +97,7 @@ class TypeForm extends React.PureComponent { selection, removePropertyDialogOpen, removeSectionDialogOpen, + changed, mode } = this.state @@ -157,6 +158,7 @@ class TypeForm extends React.PureComponent { onSave={controller.handleSave} onCancel={controller.handleCancel} selection={selection} + changed={changed} mode={mode} /> <TypeFormDialogRemoveSection diff --git a/openbis_ng_ui/src/js/components/types/form/TypeFormButtons.jsx b/openbis_ng_ui/src/js/components/types/form/TypeFormButtons.jsx index 494160cad8b27a52656995dfd0dd207ef2a81a5c..1eda5fae7a077fa8194eded4d5b5d3771a15b112 100644 --- a/openbis_ng_ui/src/js/components/types/form/TypeFormButtons.jsx +++ b/openbis_ng_ui/src/js/components/types/form/TypeFormButtons.jsx @@ -4,6 +4,8 @@ import Container from '@src/js/components/common/form/Container.jsx' import Button from '@src/js/components/common/form/Button.jsx' import logger from '@src/js/common/logger.js' +import TypeFormMessage from './TypeFormMessage.jsx' + const styles = theme => ({ container: { display: 'flex' @@ -76,7 +78,8 @@ class TypeFormButtons extends React.PureComponent { onAddProperty, onRemove, onSave, - onCancel + onCancel, + changed } = this.props return ( @@ -104,6 +107,11 @@ class TypeFormButtons extends React.PureComponent { /> </div> <div className={classes.rightContainer}> + {changed && ( + <TypeFormMessage type='warning'> + You have unsaved changes. + </TypeFormMessage> + )} <Button name='save' label='Save' diff --git a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerAddProperty.js b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerAddProperty.js index f6092c673d8d0b964f3f19d10de4833e037085cb..9446254461b0966dd897cd73e3d20f5845c75e56 100644 --- a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerAddProperty.js +++ b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerAddProperty.js @@ -100,7 +100,8 @@ export default class TypeFormControllerAddProperty { sections: newSections, properties: newProperties, propertiesCounter, - selection: newSelection + selection: newSelection, + changed: true })) } diff --git a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerAddSection.js b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerAddSection.js index 8fc87eb53cf593ca60cf52caa21de371d61ff9ec..94158583b21e10836053b31c38170180076a48f8 100644 --- a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerAddSection.js +++ b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerAddSection.js @@ -41,7 +41,8 @@ export default class TypeFormControllerAddSection { ...state, sections: newSections, sectionsCounter, - selection: newSelection + selection: newSelection, + changed: true })) } diff --git a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerChange.js b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerChange.js index 82bbf40270b097e21e741b01c85ec6830c49bcb8..ab83b4f4ef1f46ae483d51f13bc0f3d91dccea2f 100644 --- a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerChange.js +++ b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerChange.js @@ -31,7 +31,8 @@ export default class TypeFormControllerChange { ...state.type[field], value } - } + }, + changed: true })) } @@ -52,7 +53,8 @@ export default class TypeFormControllerChange { this.context.setState(state => ({ ...state, - sections: newSections + sections: newSections, + changed: true })) } @@ -79,7 +81,8 @@ export default class TypeFormControllerChange { this.context.setState(state => ({ ...state, - properties: newProperties + properties: newProperties, + changed: true })) } diff --git a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerLoad.js b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerLoad.js index 9e03e95ca8d2780697b6837f23b0c531596cfcd5..f6f53dfd628d33bad1c625f30b1fc744870d23d1 100644 --- a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerLoad.js +++ b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerLoad.js @@ -13,7 +13,8 @@ export default class TypeFormControllerLoad { await this.context.setState({ mode: 'view', loading: true, - validate: false + validate: false, + changed: false }) const typePromise = new TypeFormControllerLoadType( diff --git a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerOrderChange.js b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerOrderChange.js index f8fdda74d41624d289b73ed64b79d5798eda86c2..533eff583508b01851037b14506d1276cc71a5dd 100644 --- a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerOrderChange.js +++ b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerOrderChange.js @@ -27,7 +27,8 @@ export default class TypeFormControllerOrderChange { newSections.splice(toIndex, 0, section) this.context.setState(state => ({ ...state, - sections: newSections + sections: newSections, + changed: true })) } @@ -49,7 +50,8 @@ export default class TypeFormControllerOrderChange { this.context.setState(state => ({ ...state, - sections: newSections + sections: newSections, + changed: true })) } else { let { sections } = this.context.getState() @@ -89,7 +91,8 @@ export default class TypeFormControllerOrderChange { this.context.setState(state => ({ ...state, sections: newSections, - properties: newProperties + properties: newProperties, + changed: true })) } } diff --git a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerRemove.js b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerRemove.js index c0a75b7d0a074e138377e4087873084365917d2f..337fe56321bd0953563335be4840b385962a9ebf 100644 --- a/openbis_ng_ui/src/js/components/types/form/TypeFormControllerRemove.js +++ b/openbis_ng_ui/src/js/components/types/form/TypeFormControllerRemove.js @@ -57,7 +57,8 @@ export default class TypeFormControllerRemove { ...state, sections: newSections, properties: newProperties, - selection: null + selection: null, + changed: true })) } @@ -100,7 +101,8 @@ export default class TypeFormControllerRemove { ...state, sections: newSections, properties: newProperties, - selection: null + selection: null, + changed: true })) }