cec146d2a3
Fix session invalidation in table confirmation dialog, plus console error message when deleting deep KV's
36 lines
949 B
JavaScript
36 lines
949 B
JavaScript
import Service from '@ember/service';
|
|
import { inject as service } from '@ember/service';
|
|
import { get } from '@ember/object';
|
|
|
|
export default Service.extend({
|
|
// TODO: Why can't I name this `notify`?
|
|
flashMessages: service('flashMessages'),
|
|
execute: function(handle, success, error) {
|
|
const controller = this.controller;
|
|
controller.set('isLoading', true);
|
|
return handle()
|
|
.then(() => {
|
|
get(this, 'flashMessages').add({
|
|
type: 'success',
|
|
message: success,
|
|
});
|
|
})
|
|
.catch(e => {
|
|
if (e.name === 'TransitionAborted') {
|
|
get(this, 'flashMessages').add({
|
|
type: 'success',
|
|
message: success,
|
|
});
|
|
} else {
|
|
get(this, 'flashMessages').add({
|
|
type: 'error',
|
|
message: error,
|
|
});
|
|
}
|
|
})
|
|
.finally(function() {
|
|
controller.set('isLoading', false);
|
|
});
|
|
},
|
|
});
|