2018-07-18 02:55:09 -04:00
|
|
|
const Mn = require('backbone.marionette');
|
|
|
|
const template = require('./delete.ejs');
|
|
|
|
const App = require('../main');
|
2018-07-04 18:27:25 -04:00
|
|
|
|
|
|
|
require('jquery-serializejson');
|
|
|
|
|
|
|
|
module.exports = Mn.View.extend({
|
|
|
|
template: template,
|
|
|
|
className: 'modal-dialog',
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
form: 'form',
|
|
|
|
buttons: '.modal-footer button',
|
|
|
|
cancel: 'button.cancel',
|
|
|
|
save: 'button.save'
|
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
|
|
|
|
'click @ui.save': function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2018-07-18 02:55:09 -04:00
|
|
|
App.Api.Users.delete(this.model.get('id'))
|
2018-07-04 18:27:25 -04:00
|
|
|
.then(() => {
|
2018-07-18 02:55:09 -04:00
|
|
|
App.Controller.showUsers();
|
2018-07-04 18:27:25 -04:00
|
|
|
App.UI.closeModal();
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
alert(err.message);
|
|
|
|
this.ui.buttons.prop('disabled', false).removeClass('btn-disabled');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|