initial github commit

This commit is contained in:
2017-12-21 11:51:55 +01:00
commit 9936a38843
413 changed files with 12623 additions and 0 deletions
@@ -0,0 +1,112 @@
import ModalBase from 'ember-cli-dunlop/mixins/modal-base'
ESC_KEY = 27
export default ModalBase.extend
title: Ember.computed 'model.workflow_action_definition.title', ->
t 'project.edit_instance_action.title', title: @get('model.workflow_action_definition.title')
value_type: Ember.computed.alias 'model.workflow_action_definition.value_type'
string_value: ''
number_value: null
text_value: ''
new_note_content: ''
new_note_content_is_blank: Ember.computed.not 'new_note_content.length'
has_uncompleted_constraints: false
can_edit_action: Ember.computed 'model.workflow_action_definition.organization.users.[]', ->
return true if @get('globals.current_user.admin')
return true if @get('model.workflow_action_definition.offset_type') is 'attached'
role_names = @get('globals.current_user.role_names') || []
return true if 'manage-app-panda' in role_names
return true if 'manage-model-panda/project-instance' in role_names
organization_user_ids = @get('model.workflow_action_definition.organization.users')?.mapBy('id') || []
return true if @get('globals.current_user.id') in organization_user_ids
false
_initEscListener: ->
closeOnEscapeKey = (ev) =>
@send 'rollback_and_close' if ev.keyCode is ESC_KEY
Ember.$('body').on('keyup.modal-dialog', closeOnEscapeKey)
false
note_events: Ember.computed 'model.events.@each.event_value', ->
@get('model.events').filterBy('event_key', 'note')
misc_events: Ember.computed 'model.events.length', ->
@get('model.events').rejectBy('event_key', 'note')
willOpenModal: ->
@_initEscListener()
@get('model.events').reload()
@set 'string_value', @get('model.string_value')
@set 'number_value', @get('model.number_value')
@set 'text_value', @get('model.text_value')
@set 'timestamp_value', @get('model.timestamp_value')
@get('model.pointing_project_instance_action_connections').filterBy('connection_type', 'constraint').some (pointing_connection) =>
return @set 'has_uncompleted_constraints', true unless pointing_connection.get('project_instance_action.completed')
false
#@get('pointing_project_instance_action_connections').forEach (pointing_connection) ->
select_class_names: Ember.computed 'model.string_value', ->
return ['green']
if @get('model.string_value') then 'green button' else 'button'
has_changed_timestamp_value: Ember.computed 'timestamp_value', 'model.timestamp_value', ->
current_timestamp = @get('timestamp_value')
model_timestamp = @get('model.timestamp_value')
return false unless current_timestamp or model_timestamp # both false, nothing changed
return true unless current_timestamp and model_timestamp
# now we have two timestamps, lets compare
current_timestamp.toISOString() isnt model_timestamp.toISOString()
actions:
set_value: (attribute, value) ->
@set "model.#{attribute}", value
@send 'saveRecord'
set_string_value: ->
@send 'set_value', 'string_value', @get('string_value')
set_text_value: ->
@send 'set_value', 'text_value', @get('text_value')
set_number_value: ->
@send 'set_value', 'number_value', @get('number_value')
set_timestamp_value: ->
@send 'set_value', 'timestamp_value', @get('timestamp_value')
close: ->
Ember.$('body').off('keyup.modal-dialog')
@_super arguments...
open_current_modal: -> @modal 'project/edit-instance-action', model: @get('model')
continue_from_inquiry: ->
record = @get('model')
if target_date = @get('model.target_date')
state = if target_date.format('YYYY-MM-DD') < moment().format('YYYY-MM-DD') then 'overdue' else 'active'
else
state = 'active'
record.set 'state', state
record.save().then ->
record.get('events').reload()
add_new_note: ->
return unless content = @get('new_note_content')
now = moment()
new_note_event = @store.createRecord 'panda/action-event',
client_identifier: @get('model.project_instance.client_identifier')
identifier: @get('model.workflow_action_definition.identifier')
event_key: 'note'
event_value: content
event_timestamp: now
new_note_event.save().then =>
@set 'new_note_content', ''
@send 'close'
start_inquiry: ->
record = @get('model')
record.set 'state', 'inquiry'
record.save().then => @send 'add_new_note'
#record.save().then ->
# record.get('events').reload()