Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/routes/metadata/components/MetaDataPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,20 @@ class MetaDataPanel extends React.Component {
} else if (metadataType === 'projectTemplate') {
const projectTypeOptions = this.getProductCategoryOptions(templates.projectTypes)
const value = metadata && metadata.category ? metadata.category : projectTypeOptions[0].value
const subCategoryVal = metadata && metadata.subCategory ? metadata.subCategory : ''
const metadataVal = metadata && metadata.metadataVal ? metadata.metadataVal : {}
fields = fields.concat([
{ key: 'id', type: 'number' },
{ key: 'name', type: 'text' },
{ key: 'key', type: 'text' },
{ key: 'category', type: 'dropdown', options: projectTypeOptions, value },
{ key: 'subCategory', type: 'dropdown', options: projectTypeOptions.concat({title: '--', value: ''}), value: subCategoryVal },
{ key: 'icon', type: 'text' },
{ key: 'question', type: 'text' },
{ key: 'info', type: 'text' },
{ key: 'aliases', type: 'array' },
{ key: 'phases', type: 'json', value: phasesDefaultValue },
{ key: 'metadata', type: 'json', value: metadataVal },
{ key: 'disabled', type: 'checkbox' },
{ key: 'hidden', type: 'checkbox' },
])
Expand Down
13 changes: 9 additions & 4 deletions src/routes/metadata/components/TemplateForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ class TemplateForm extends Component {
theme="default max-height"
onSelect={(option) => {
this.props.dropdownChange(label, option)
this.onChangeDropdown(option)
this.onChangeDropdown(label, option)
}}
value={value}
required
required={label!=='subCategory'}
/>
</div>
)
Expand Down Expand Up @@ -284,6 +284,9 @@ class TemplateForm extends Component {
const aliases = _.split(values.aliases, ',')
payload = _.assign({}, payload, { aliases })
}
if(!payload.subCategory) {
payload.subCategory = null
}
saveTemplate(primaryKeyValue, payload)
}

Expand Down Expand Up @@ -312,10 +315,12 @@ class TemplateForm extends Component {
}
}

onChangeDropdown(option) {
onChangeDropdown(label, option) {
const { values } = this.state
const updatedValue = {}
updatedValue[`${label}`] = option.value
this.setState({
values: _.assign({}, values, {category: option.value})
values: _.assign({}, values, updatedValue)
})
}

Expand Down