mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Use ternary operator in Org Edit form
This commit is contained in:
@@ -43,8 +43,8 @@ class OrganizationEdit extends Component {
|
|||||||
value: ''
|
value: ''
|
||||||
},
|
},
|
||||||
instanceGroups: {
|
instanceGroups: {
|
||||||
value: null,
|
value: [],
|
||||||
initialValue: null
|
initialValue: []
|
||||||
},
|
},
|
||||||
custom_virtualenv: {
|
custom_virtualenv: {
|
||||||
value: '',
|
value: '',
|
||||||
@@ -84,11 +84,10 @@ class OrganizationEdit extends Component {
|
|||||||
updatedFormEl.value = value;
|
updatedFormEl.value = value;
|
||||||
updatedForm[targetName] = updatedFormEl;
|
updatedForm[targetName] = updatedFormEl;
|
||||||
|
|
||||||
let formIsValid = true;
|
updatedFormEl.isValid = (updatedFormEl.validation)
|
||||||
if (updatedFormEl.validation) {
|
? this.checkValidity(updatedFormEl.value, updatedFormEl.validation) : true;
|
||||||
updatedFormEl.isValid = this.checkValidity(updatedFormEl.value, updatedFormEl.validation);
|
|
||||||
formIsValid = updatedFormEl.isValid && formIsValid;
|
const formIsValid = (updatedFormEl.validation) ? updatedFormEl.isValid : true;
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({ form: updatedForm, formIsValid });
|
this.setState({ form: updatedForm, formIsValid });
|
||||||
}
|
}
|
||||||
@@ -148,10 +147,9 @@ class OrganizationEdit extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkValidity = (value, validation) => {
|
checkValidity = (value, validation) => {
|
||||||
let isValid = true;
|
const isValid = (validation.required)
|
||||||
if (validation.required) {
|
? (value.trim() !== '') : true;
|
||||||
isValid = value.trim() !== '' && isValid;
|
|
||||||
}
|
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,19 +253,15 @@ class OrganizationEdit extends Component {
|
|||||||
fieldId="edit-org-form-instance-groups"
|
fieldId="edit-org-form-instance-groups"
|
||||||
label={i18n._(t`Instance Groups`)}
|
label={i18n._(t`Instance Groups`)}
|
||||||
>
|
>
|
||||||
{ instanceGroups.value
|
<Lookup
|
||||||
&& (
|
columns={instanceGroupsLookupColumns}
|
||||||
<Lookup
|
getItems={this.getInstanceGroups}
|
||||||
columns={instanceGroupsLookupColumns}
|
lookupHeader={i18n._(t`Instance Groups`)}
|
||||||
getItems={this.getInstanceGroups}
|
name="instanceGroups"
|
||||||
lookupHeader={i18n._(t`Instance Groups`)}
|
onLookupSave={this.onLookupSave}
|
||||||
name="instanceGroups"
|
sortedColumnKey="name"
|
||||||
onLookupSave={this.onLookupSave}
|
value={instanceGroups.value}
|
||||||
sortedColumnKey="name"
|
/>
|
||||||
value={instanceGroups.value}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<FormActionGroup
|
<FormActionGroup
|
||||||
onCancel={this.onCancel}
|
onCancel={this.onCancel}
|
||||||
|
|||||||
Reference in New Issue
Block a user