mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-21 04:53:37 +01:00
autogenview: fill edit form field values (#227)
This fixes to fill an edit form fields' value if possible automatically for all auto-generated forms Fixes #198 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Co-authored-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
8ec5eb0130
commit
c6e70d3169
@ -60,19 +60,6 @@ export default {
|
|||||||
popup: true,
|
popup: true,
|
||||||
component: () => import('@/views/network/CreateNetwork.vue')
|
component: () => import('@/views/network/CreateNetwork.vue')
|
||||||
},
|
},
|
||||||
{
|
|
||||||
api: 'associateIpAddress',
|
|
||||||
icon: 'plus',
|
|
||||||
label: 'Acquire New IP',
|
|
||||||
dataView: true,
|
|
||||||
show: (record) => { return record && record.service && record.service.filter(x => x.name && ['StaticNat', 'SourceNat', 'Firewall', 'PortForwarding', 'Lb'].includes(x.name)).length > 0 },
|
|
||||||
args: ['networkid'],
|
|
||||||
mapping: {
|
|
||||||
networkid: {
|
|
||||||
value: (record) => { return record.id }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
api: 'updateNetwork',
|
api: 'updateNetwork',
|
||||||
icon: 'edit',
|
icon: 'edit',
|
||||||
|
|||||||
@ -559,6 +559,9 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.currentAction.loading = false
|
this.currentAction.loading = false
|
||||||
|
if (action.dataView && action.icon === 'edit') {
|
||||||
|
this.fillEditFormFieldValues()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
listUuidOpts (param) {
|
listUuidOpts (param) {
|
||||||
if (this.currentAction.mapping && param.name in this.currentAction.mapping && !this.currentAction.mapping[param.name].api) {
|
if (this.currentAction.mapping && param.name in this.currentAction.mapping && !this.currentAction.mapping[param.name].api) {
|
||||||
@ -641,6 +644,22 @@ export default {
|
|||||||
action
|
action
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
fillEditFormFieldValues () {
|
||||||
|
const form = this.form
|
||||||
|
this.currentAction.paramFields.map(field => {
|
||||||
|
let fieldValue = null
|
||||||
|
let fieldName = null
|
||||||
|
if (field.type === 'uuid' || field.type === 'list' || field.name === 'account' || (this.currentAction.mapping && field.name in this.currentAction.mapping)) {
|
||||||
|
fieldName = field.name.replace('ids', 'name').replace('id', 'name')
|
||||||
|
} else {
|
||||||
|
fieldName = field.name
|
||||||
|
}
|
||||||
|
fieldValue = this.resource[fieldName] ? this.resource[fieldName] : null
|
||||||
|
if (fieldValue) {
|
||||||
|
form.getFieldDecorator(field.name, { initialValue: fieldValue })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
handleSubmit (e) {
|
handleSubmit (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.form.validateFields((err, values) => {
|
this.form.validateFields((err, values) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user