All files / addon/components/bootstrap/tables/body/row -actions.js

0% Statements 0/13
0% Branches 0/8
0% Functions 0/9
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                                                 
import Component from '@ember/component';
import { notEmpty } from '@ember/object/computed';
import { task, didCancel } from 'ember-concurrency';
import layout from '../../../../../templates/components/bootstrap/tables/body/row/-actions';
 
export default Component.extend({
  layout,
  tagName: 'td',
  archiveEnabled: notEmpty('onArchive'),
  editEnabled: notEmpty('onEdit'),
  showEnabled: notEmpty('onShow'),
  deleteEnabled: notEmpty('onDelete'),
 
  asyncTask: task(function * (asyncTask, rowData) {
    return yield asyncTask(rowData);
  }).drop(),
 
  actions: {
    onShow(rowData) {
      return this.get('asyncTask').perform(this.get('onShow'), rowData).catch(error => {
        if (!didCancel(error)) { throw error; }
      });
    },
    onEdit(rowData) {
      return this.get('asyncTask').perform(this.get('onEdit'), rowData).catch(error => {
        if (!didCancel(error)) { throw error; }
      });
    },
    onArchive(rowData) {
      return this.get('asyncTask').perform(this.get('onArchive'), rowData).catch(error => {
        if (!didCancel(error)) { throw error; }
      });
    },
    onDelete(rowData) {
      return this.get('asyncTask').perform(this.get('onDelete'), rowData).catch(error => {
        if (!didCancel(error)) { throw error; }
      });
    }
  }
});