Skip to content
Snippets Groups Projects
Commit 8c76f0c6 authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

SSDM-7583 : ObjectTypeForm - display a warning in the property parameters...

SSDM-7583 : ObjectTypeForm - display a warning in the property parameters panel when a property is already in use and it is not fully editable
parent 3e72b047
No related branches found
No related tags found
No related merge requests found
...@@ -14,18 +14,22 @@ class ObjectTypeDialogRemoveProperty extends React.Component { ...@@ -14,18 +14,22 @@ class ObjectTypeDialogRemoveProperty extends React.Component {
open={open} open={open}
onConfirm={onConfirm} onConfirm={onConfirm}
onCancel={onCancel} onCancel={onCancel}
title={'Remove "' + this.getPropertyName() + '" property'} title={this.getTitle()}
content='The property is used by some entities. Are you sure you want to remove it?' content='This property is already used by some entities. Are you sure you want to remove it?'
/> />
) )
} }
getPropertyName() { getTitle() {
const { open, selection, properties } = this.props const { open, selection, properties } = this.props
if (open) { if (open) {
const property = _.find(properties, ['id', selection.params.id]) const property = _.find(properties, ['id', selection.params.id])
return property.code if (property.code) {
return `Remove "${property.code}" property`
} else {
return 'Remove property'
}
} else { } else {
return null return null
} }
......
...@@ -14,18 +14,22 @@ class ObjectTypeDialogRemoveSection extends React.Component { ...@@ -14,18 +14,22 @@ class ObjectTypeDialogRemoveSection extends React.Component {
open={open} open={open}
onConfirm={onConfirm} onConfirm={onConfirm}
onCancel={onCancel} onCancel={onCancel}
title={'Remove "' + this.getSectionName() + '" section'} title={this.getTitle()}
content='The section contains properties used in entities. Are you sure you want to remove it?' content='This section contains properties which are already used by some entities. Are you sure you want to remove it?'
/> />
) )
} }
getSectionName() { getTitle() {
const { open, selection, sections } = this.props const { open, selection, sections } = this.props
if (open) { if (open) {
const section = _.find(sections, ['id', selection.params.id]) const section = _.find(sections, ['id', selection.params.id])
return section.name if (section.name) {
return `Remove "${section.name}" section`
} else {
return 'Remove section'
}
} else { } else {
return null return null
} }
......
...@@ -4,6 +4,7 @@ import Typography from '@material-ui/core/Typography' ...@@ -4,6 +4,7 @@ import Typography from '@material-ui/core/Typography'
import CheckboxField from '../../common/form/CheckboxField.jsx' import CheckboxField from '../../common/form/CheckboxField.jsx'
import TextField from '../../common/form/TextField.jsx' import TextField from '../../common/form/TextField.jsx'
import SelectField from '../../common/form/SelectField.jsx' import SelectField from '../../common/form/SelectField.jsx'
import WarningIcon from '@material-ui/icons/Warning'
import { facade, dto } from '../../../services/openbis.js' import { facade, dto } from '../../../services/openbis.js'
import logger from '../../../common/logger.js' import logger from '../../../common/logger.js'
...@@ -16,6 +17,14 @@ const styles = theme => ({ ...@@ -16,6 +17,14 @@ const styles = theme => ({
}, },
field: { field: {
paddingBottom: theme.spacing(2) paddingBottom: theme.spacing(2)
},
warning: {
display: 'flex',
alignItems: 'center',
'& svg': {
marginRight: theme.spacing(1),
color: theme.palette.warning.main
}
} }
}) })
...@@ -173,6 +182,7 @@ class ObjectTypeParametersProperty extends React.PureComponent { ...@@ -173,6 +182,7 @@ class ObjectTypeParametersProperty extends React.PureComponent {
<Typography variant='h6' className={classes.header}> <Typography variant='h6' className={classes.header}>
Property Property
</Typography> </Typography>
{this.renderWarning(property)}
{this.renderCode(property)} {this.renderCode(property)}
{this.renderDataType(property)} {this.renderDataType(property)}
{this.renderVocabulary(property)} {this.renderVocabulary(property)}
...@@ -185,6 +195,22 @@ class ObjectTypeParametersProperty extends React.PureComponent { ...@@ -185,6 +195,22 @@ class ObjectTypeParametersProperty extends React.PureComponent {
) )
} }
renderWarning(property) {
if (property.used) {
const { classes } = this.props
return (
<div className={classes.field}>
<Typography variant='body2' className={classes.warning}>
<WarningIcon />
This property is already used by some entities.
</Typography>
</div>
)
} else {
return null
}
}
renderLabel(property) { renderLabel(property) {
const { classes } = this.props const { classes } = this.props
return ( return (
......
...@@ -21,6 +21,9 @@ const theme = createMuiTheme({ ...@@ -21,6 +21,9 @@ const theme = createMuiTheme({
secondary: { secondary: {
main: lightBlue[600] main: lightBlue[600]
}, },
warning: {
main: '#ff9609'
},
background: { background: {
primary: '#ebebeb', primary: '#ebebeb',
secondary: '#dbdbdb' secondary: '#dbdbdb'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment