open-vault/ui/app/components/list-item.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

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();
}
}),
});