unclean SPARC
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
class BypassTrackSetupDialog extends EICDialogContent {
|
||||
|
||||
actions = [
|
||||
{
|
||||
label: 'Cancel',
|
||||
onclick: this.cancel.bind(this),
|
||||
severity: 'secondary',
|
||||
role: 'cancel'
|
||||
},
|
||||
{
|
||||
label: 'Save',
|
||||
onclick: this.save.bind(this),
|
||||
severity: 'primary',
|
||||
role: 'save'
|
||||
}
|
||||
]
|
||||
|
||||
constructor(options) { super(options); }
|
||||
|
||||
DOMContentLoaded(options) {
|
||||
this.model = options.model;
|
||||
this.track = options.track;
|
||||
this.domains = options.domains;
|
||||
|
||||
|
||||
|
||||
this.grid = new DataGrid(this.find('.domains [eicdatagrid]'), {
|
||||
headers: [ { label: 'Domain'}, { label: 'Tokens', type: 'markup' }, { label: 'Min.' } ],
|
||||
height: '320px'
|
||||
});
|
||||
|
||||
this.grid.clear();
|
||||
this.grid.loading = true;
|
||||
this.model.getSettings(this.track)
|
||||
.then(this.fill.bind(this));
|
||||
}
|
||||
|
||||
fill(payload) {
|
||||
this.grid.clear();
|
||||
this.grid.loading = false;
|
||||
let index = 0;
|
||||
for(let item of payload.domains) {
|
||||
this.grid.addRow(item.domain, [
|
||||
app.meta.toString('accelerator-tracks', item.domain),
|
||||
`<input type="hidden" data-path="domains[${index}].domain" value="${item.domain}" />
|
||||
<input eicinput type="number" min="${item.tokens - item.remaining}" data-path="domains[${index}].tokens" value="${item.tokens}" />`,
|
||||
item.tokens - item.remaining
|
||||
]);
|
||||
index++;
|
||||
}
|
||||
this.grid.sort(1, 'asc');
|
||||
this.form = new Form(this.find('.domains'));
|
||||
|
||||
let components = ui.eicfy(this.el);
|
||||
}
|
||||
|
||||
save() {
|
||||
if(this.form.validate()) {
|
||||
this.actions.find(o => o.role == 'save').button.loading = true;
|
||||
this.actions.find(o => o.role == 'cancel').button.disabled = true;
|
||||
this.model.setSettings(this.form.value)
|
||||
.then(this.onSuccess.bind(this))
|
||||
.catch(this.onFailed.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
onSuccess() {
|
||||
this.actions.find(o => o.role == 'save').button.loading = false;
|
||||
this.actions.find(o => o.role == 'cancel').button.disabled = false;
|
||||
this.commit(true);
|
||||
}
|
||||
|
||||
onFailed() {
|
||||
this.actions.find(o => o.role == 'save').button.loading = false;
|
||||
this.actions.find(o => o.role == 'cancel').button.disabled = false;
|
||||
//this.abort();
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('BypassTrackSetupDialog',BypassTrackSetupDialog);
|
||||
Reference in New Issue
Block a user