// Generated by CoffeeScript 1.12.5
var Model;

import Ember from 'ember';

import DS from 'ember-data';

import {
  modelAction
} from 'ember-custom-actions';

import add_business_day_computations from 'ember-panda/utils/business-day-computations';

export var value_type_options = ['boolean', 'date', 'number', 'select', 'string', 'text', 'timestamp'];

Model = {
  identifier: DS.attr('string'),
  title: DS.attr('string'),
  name: Ember.computed.alias('title'),
  description: DS.attr('string'),
  isEditing: DS.attr('boolean', {
    defaultValue: false
  }),
  done: DS.attr('boolean', {
    defaultValue: false
  }),
  position: DS.attr('number', {
    defaultValue: 0
  }),
  value_type: DS.attr('string', {
    defaultValue: 'boolean'
  }),
  value_type_select_options: DS.attr({
    defaultValue: function() {
      return [];
    }
  }),
  extra_info: DS.attr('string'),
  offset_type: DS.attr('string', {
    defaultValue: 'none'
  }),
  overdue_coulance: DS.attr('number', {
    defaultValue: 0
  }),
  completes_group: DS.attr('boolean', {
    defaultValue: false
  }),
  workflow_group: DS.belongsTo('panda/workflow-group'),
  project: DS.belongsTo('panda/project', {
    inverse: 'workflow_action_definitions'
  }),
  organization: DS.belongsTo('panda/organization', {
    inverse: 'workflow_action_definitions'
  }),
  workflow_action_constraints: DS.hasMany('panda/workflow-action-constraint', {
    inverse: 'workflow_action_definition'
  }),
  workflow_action_offsets: DS.hasMany('panda/workflow-action-offset', {
    inverse: 'workflow_action_definition'
  }),
  dependent_workflow_action_offsets: DS.hasMany('panda/workflow-action-offset', {
    inverse: 'base_workflow_action_definition'
  }),
  project_scenarios: DS.hasMany('panda/project-scenario'),
  project_instance_actions: DS.hasMany('panda/project-instance-action', {
    inverse: 'workflow_action_definition'
  }),
  confirms_workflow_action_definition: DS.belongsTo('panda/workflow-action-definition', {
    inverse: 'confirmed_by_workflow_action_definition'
  }),
  confirmed_by_workflow_action_definition: DS.belongsTo('panda/workflow-action-definition', {
    inverse: 'confirms_workflow_action_definition'
  }),
  workflow_action_connections: DS.hasMany('panda/workflow-action-connection', {
    inverse: 'workflow_action_definition'
  }),
  pointing_workflow_action_connections: DS.hasMany('panda/workflow-action-connection', {
    inverse: 'base_workflow_action_definition'
  }),
  absolute_position: Ember.computed('workflow_group.position', 'position', function() {
    return (this.get('workflow_group.position') || 99) * 100 + (this.get('position') || 99);
  }),
  set_value_on_non_final_till_date: modelAction('set_value_on_non_final_till_date', {
    pushToStore: false
  })
};

add_business_day_computations(Model, 'offset', {
  add_attributes: true
});

add_business_day_computations(Model, 'batch_element_threshold', {
  add_attributes: true
});

export default DS.Model.extend(Model);
