class BypassProgramAddDialog extends EICDialogContent { actions = [ { label: 'Cancel', onclick: this.cancel.bind(this), severity: 'secondary', role: 'cancel' }, { label: 'Create programme', onclick: this.add.bind(this), severity: 'primary', role: 'add', disabled: false } ] constructor(options) { super(options); } DOMContentLoaded(options) { this.model = options.model; this.profile = options.profile; let components = ui.eicfy(this.el); this.form = new Form(this.find('.program')); this.find('input[name="track"]').value = this.profile.track; this.find('input[name="domain"]').value = this.profile.domain; } add() { if(this.form.validate()) { this.actions.find(o => o.role == 'add').button.loading = true; this.actions.find(o => o.role == 'cancel').button.disabled = true; this.model.addProgram(this.form.value) .then( this.onSuccess.bind(this), this.onFailed.bind(this) ) } } onSuccess() { this.actions.find(o => o.role == 'add').button.loading = false; this.actions.find(o => o.role == 'cancel').button.disabled = false; this.commit(true); } onFailed() { this.actions.find(o => o.role == 'add').button.loading = false; this.actions.find(o => o.role == 'cancel').button.disabled = false; this.abort(); } } app.registerClass('BypassProgramAddDialog',BypassProgramAddDialog);