53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
class SubmissionFormComplaintDialog extends EICDialogContent {
|
|
actions = [
|
|
{
|
|
label: 'cancel',
|
|
onclick: this.cancel.bind(this),
|
|
severity: 'secondary',
|
|
role: 'cancel'
|
|
},
|
|
{
|
|
label: 'File complaint',
|
|
onclick: this.complain.bind(this),
|
|
severity: 'primary',
|
|
role: 'save'
|
|
}
|
|
]
|
|
|
|
DOMContentLoaded(options) {
|
|
ui.eicfy(this.el);
|
|
this.form = new Form(this.el);
|
|
this.pic = options.pic;
|
|
this.number = options.number;
|
|
this.proposal = options.proposal
|
|
}
|
|
|
|
async complain(event) {
|
|
event.stopPropagation();
|
|
event.preventDefault();
|
|
|
|
if(this.form.validate()) {
|
|
console.log('form valid', this.form.value)
|
|
this.actions.find(o => o.role == 'save').button.loading = true;
|
|
this.actions.find(o => o.role == 'cancel').button.disabled = true;
|
|
|
|
this.proposal.complain(this.pic, this.number, this.form.value)
|
|
.then(
|
|
async payload => {
|
|
ui.growl.append('Your complaint has been filed', 'success');
|
|
this.actions.find(o => o.role == 'save').button.loading = false;
|
|
this.actions.find(o => o.role == 'cancel').button.disabled = false;
|
|
this.commit(true);
|
|
},
|
|
async () => {
|
|
ui.growl.append('Your complaint could not be filed', 'danger');
|
|
this.actions.find(o => o.role == 'save').button.loading = false;
|
|
this.actions.find(o => o.role == 'cancel').button.disabled = false;
|
|
this.commit(false);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
app.registerClass('SubmissionFormComplaintDialog', SubmissionFormComplaintDialog); |