seocahill/ember-engine-xbrl-tagger

View on GitHub
addon/pods/discoverable-taxonomy-set/role-type/presentation-node/element/controller.js

Summary

Maintainability
A
2 hrs
Test Coverage
import Ember from 'ember';

export default Ember.Controller.extend({
  currentCell: Ember.inject.service(),
  store: Ember.inject.service(),

  actions: {
    updateTag() {
      const cell = this.get('currentCell.cell');
      const model = this.get('model');
      cell.setProperties({
        settings: model,
        tag: model.get('id')
      });
      if (Ember.isEmpty(cell.get('period'))) {
        cell.set('period', this.get('currentCell.periods.firstObject'));
      }
      cell.save();
    },

    async autoTagCell() {
      const cell = await this.get('currentCell.cell').autoTag();
      this.get('store').pushPayload(cell);
    },

    viewNode(id) {
      this.transitionToRoute('discoverable-taxonomy-set.role-type.presentation-node', id);
    },

    remove() {
      const cell = this.get('currentCell.cell');
      cell.setProperties({
        settings: null,
        period: null,
        tag: null,
        dimensions: [],
      });
      cell.save();
    }
  }
});