d509588cd2
Ember update - update ember-cli, ember-data, and ember to 3.4 series
25 lines
684 B
JavaScript
25 lines
684 B
JavaScript
import { inject as service } from '@ember/service';
|
|
import Component from '@ember/component';
|
|
import { task } from 'ember-concurrency';
|
|
|
|
export default Component.extend({
|
|
flashMessages: service(),
|
|
tagName: '',
|
|
linkParams: null,
|
|
componentName: null,
|
|
hasMenu: false,
|
|
|
|
callMethod: task(function*(method, model, successMessage, failureMessage, successCallback = () => {}) {
|
|
let flash = this.get('flashMessages');
|
|
try {
|
|
yield model[method]();
|
|
flash.success(successMessage);
|
|
successCallback();
|
|
} catch (e) {
|
|
let errString = e.errors.join(' ');
|
|
flash.danger(failureMessage + errString);
|
|
model.rollbackAttributes();
|
|
}
|
|
}),
|
|
});
|