Cobalt form improvements - on insert/update action & taller multiselect

This commit is contained in:
garrettmills 2020-05-22 09:05:17 -05:00
parent c74e3b0685
commit 8701df1acc
No known key found for this signature in database
GPG Key ID: 6ACD58D6ADACFC6E
4 changed files with 23 additions and 5 deletions

View File

@ -1,10 +1,6 @@
- MFA recovery codes handling - MFA recovery codes handling
- Forgot password handling - Forgot password handling
- Admin password reset mechanism -> flag users as needing PW resets - Admin password reset mechanism -> flag users as needing PW resets
- Cobalt form - when multiselect make selection box taller
- Cobalt form - after action handlers
- e.g. after insert perform action
- e.g. after update perform action, &c.
- OAuth2 -> support refresh tokens - OAuth2 -> support refresh tokens
- Traps -> support session traps; convert MFA challenge to use session trap - Traps -> support session traps; convert MFA challenge to use session trap
- Allow setting user trap from web UI - Allow setting user trap from web UI

View File

@ -32,7 +32,7 @@ const template = `
<label :for="uuid+field.field">{{ field.name }}</label> <label :for="uuid+field.field">{{ field.name }}</label>
<select <select
:id="uuid+field.field" :id="uuid+field.field"
class="form-control" :class="['form-control', (field.type.endsWith('.multiple') ? 'multi' : 'normal')]"
v-model="data[field.field]" v-model="data[field.field]"
:required="Array.isArray(field.required) ? field.required.includes(mode) : field.required" :required="Array.isArray(field.required) ? field.required.includes(mode) : field.required"
:readonly="mode === 'view' || (Array.isArray(field.readonly) ? field.readonly.includes(mode) : field.readonly)" :readonly="mode === 'view' || (Array.isArray(field.readonly) ? field.readonly.includes(mode) : field.readonly)"
@ -238,10 +238,19 @@ export default class FormComponent extends Component {
async on_create() { async on_create() {
this.id = this.data.id this.id = this.data.id
this.mode = 'update' this.mode = 'update'
if ( this.definition.handlers && this.definition.handlers.insert ) {
await action_service.perform(this.definition.handlers.insert)
}
await this.vue_on_create(true) await this.vue_on_create(true)
location_service.set_query(`mode=update&id=${this.id}`) location_service.set_query(`mode=update&id=${this.id}`)
} }
async on_update() {
if ( this.definition.handlers && this.definition.handlers.update ) {
await action_service.perform(this.definition.handlers.update)
}
}
data_to_save() { data_to_save() {
const data = Object.assign({}, this.data) const data = Object.assign({}, this.data)
for ( const field of this.definition.fields ) { for ( const field of this.definition.fields ) {
@ -270,6 +279,7 @@ export default class FormComponent extends Component {
await this.on_create() await this.on_create()
} else if (this.mode === 'update') { } else if (this.mode === 'update') {
await this.resource_class.update(this.id, this.data_to_save()) await this.resource_class.update(this.id, this.data_to_save())
await this.on_update()
} }
this.error_message = '' this.error_message = ''

View File

@ -146,6 +146,14 @@ class PolicyResource extends CRUDBase {
if: (form_data) => form_data.target_type === 'api_scope' if: (form_data) => form_data.target_type === 'api_scope'
}, },
], ],
/*handlers: {
insert: {
action: 'back',
},
update: {
action: 'back',
},
},*/
} }
} }

View File

@ -82,3 +82,7 @@ body {
opacity: 1; opacity: 1;
} }
} }
select.multi {
min-height: 200px;
}