Action list performance upgrade but makes modal logic more comprehensive, but more stable
This commit is contained in:
@@ -10,7 +10,7 @@ export default ModalBase.extend
|
|||||||
new_note_content: ''
|
new_note_content: ''
|
||||||
new_note_content_is_blank: Ember.computed.not 'new_note_content.length'
|
new_note_content_is_blank: Ember.computed.not 'new_note_content.length'
|
||||||
has_uncompleted_constraints: false
|
has_uncompleted_constraints: false
|
||||||
attached_instance_action_connections: []
|
#attached_instance_action_connections: []
|
||||||
attached_conditions_not_met_warning: ''
|
attached_conditions_not_met_warning: ''
|
||||||
|
|
||||||
can_edit_action: Ember.computed 'model.workflow_action_definition.organization.users.[]', ->
|
can_edit_action: Ember.computed 'model.workflow_action_definition.organization.users.[]', ->
|
||||||
@@ -44,23 +44,27 @@ export default ModalBase.extend
|
|||||||
@set 'number_value', @get('model.number_value')
|
@set 'number_value', @get('model.number_value')
|
||||||
@set 'text_value', @get('model.text_value')
|
@set 'text_value', @get('model.text_value')
|
||||||
@set 'timestamp_value', @get('model.timestamp_value')
|
@set 'timestamp_value', @get('model.timestamp_value')
|
||||||
@set 'attached_instance_action_connections', []
|
#@set 'attached_instance_action_connections', []
|
||||||
@set 'attached_conditions_not_met_warning', '' # important te reset since attached actions can be completed on re-open of parent
|
# set this action here to be able to propagate the save callback. This makes double nested attached actions work smoothly
|
||||||
@get('model.pointing_project_instance_action_connections').forEach (pointing_connection) =>
|
@set 'actions.open_current_modal', -> @modal 'project/edit-instance-action', model: @get('model'), save: @get('modal_options.save')
|
||||||
if pointing_connection.get('connection_type') is 'constraint' and not @get('has_uncompleted_constraints')
|
|
||||||
@set 'has_uncompleted_constraints', true unless pointing_connection.get('project_instance_action.completed')
|
|
||||||
if pointing_connection.get('connection_type') is 'attached'
|
|
||||||
if conditional_value = pointing_connection.get('conditional_base_value')
|
|
||||||
switch @get('model.workflow_action_definition.value_type')
|
|
||||||
when 'boolean'
|
|
||||||
3
|
|
||||||
when 'select'
|
|
||||||
@get('attached_instance_action_connections').pushObject pointing_connection if conditional_value is @get('string_value')
|
|
||||||
|
|
||||||
else
|
# constraints setup
|
||||||
# always display non conditional attached actions
|
#@set 'attached_conditions_not_met_warning', 'validating attached actions...' # important te reset since attached actions can be completed on re-open of parent
|
||||||
@get('attached_instance_action_connections').pushObject pointing_connection
|
@set 'attached_conditions_not_met_warning', ''
|
||||||
#@get('pointing_project_instance_action_connections').forEach (pointing_connection) ->
|
@set 'has_uncompleted_constraints', false
|
||||||
|
base = @
|
||||||
|
@get('model.pointing_project_instance_action_connections').then (pointing_connections) =>
|
||||||
|
pointing_connections.forEach (pointing_connection) ->
|
||||||
|
return if base.get('has_uncompleted_constraints') # already found, no need to search further
|
||||||
|
pointing_connection.get('project_instance_action').then (pointing_project_instance_action) ->
|
||||||
|
return if pointing_project_instance_action.get('completed')
|
||||||
|
if pointing_connection.get('connection_type') is 'constraint'
|
||||||
|
return base.set 'has_uncompleted_constraints', true
|
||||||
|
if pointing_connection.get('connection_type') is 'attached'
|
||||||
|
if conditional_value = pointing_connection.get('conditional_base_value')
|
||||||
|
if base.get('model.workflow_action_definition.value_type') isnt 'select' or conditional_value is base.get('model.string_comparison_value')
|
||||||
|
pointing_project_instance_action.get('workflow_action_definition').then (pointing_workflow_action_definition) ->
|
||||||
|
base.set 'attached_conditions_not_met_warning', "#{pointing_workflow_action_definition.get('title')} not completed"
|
||||||
|
|
||||||
select_class_names: Ember.computed 'model.string_value', ->
|
select_class_names: Ember.computed 'model.string_value', ->
|
||||||
return ['green']
|
return ['green']
|
||||||
@@ -80,7 +84,7 @@ export default ModalBase.extend
|
|||||||
#@set attribute, value # internal setting for validation
|
#@set attribute, value # internal setting for validation
|
||||||
@set 'action_value', value
|
@set 'action_value', value
|
||||||
@set "model.#{attribute}", value
|
@set "model.#{attribute}", value
|
||||||
@send 'saveRecord'
|
@send 'validate_and_progress'
|
||||||
|
|
||||||
set_string_value: ->
|
set_string_value: ->
|
||||||
@send 'set_value', 'string_value', @get('string_value')
|
@send 'set_value', 'string_value', @get('string_value')
|
||||||
@@ -98,8 +102,6 @@ export default ModalBase.extend
|
|||||||
Ember.$('body').off('keyup.modal-dialog')
|
Ember.$('body').off('keyup.modal-dialog')
|
||||||
@_super arguments...
|
@_super arguments...
|
||||||
|
|
||||||
open_current_modal: -> @modal 'project/edit-instance-action', model: @get('model')
|
|
||||||
|
|
||||||
continue_from_inquiry: ->
|
continue_from_inquiry: ->
|
||||||
record = @get('model')
|
record = @get('model')
|
||||||
if target_date = @get('model.target_date')
|
if target_date = @get('model.target_date')
|
||||||
@@ -109,6 +111,7 @@ export default ModalBase.extend
|
|||||||
record.set 'state', state
|
record.set 'state', state
|
||||||
record.save().then ->
|
record.save().then ->
|
||||||
record.get('events').reload()
|
record.get('events').reload()
|
||||||
|
|
||||||
add_new_note: ->
|
add_new_note: ->
|
||||||
return unless content = @get('new_note_content')
|
return unless content = @get('new_note_content')
|
||||||
now = moment()
|
now = moment()
|
||||||
@@ -122,6 +125,7 @@ export default ModalBase.extend
|
|||||||
@get('model.events').pushObject new_note_event
|
@get('model.events').pushObject new_note_event
|
||||||
@set 'new_note_content', ''
|
@set 'new_note_content', ''
|
||||||
#@send 'close'
|
#@send 'close'
|
||||||
|
|
||||||
start_inquiry: ->
|
start_inquiry: ->
|
||||||
record = @get('model')
|
record = @get('model')
|
||||||
record.set 'state', 'inquiry'
|
record.set 'state', 'inquiry'
|
||||||
@@ -129,7 +133,8 @@ export default ModalBase.extend
|
|||||||
#record.save().then ->
|
#record.save().then ->
|
||||||
# record.get('events').reload()
|
# record.get('events').reload()
|
||||||
|
|
||||||
saveRecord: ->
|
validate_and_progress: ->
|
||||||
|
# these validations are only needed for select value_type actions, since all the others have no dynamic values that will limit the progress
|
||||||
all_attached_actions_are_valid = true
|
all_attached_actions_are_valid = true
|
||||||
@set 'attached_conditions_not_met_warning', ''
|
@set 'attached_conditions_not_met_warning', ''
|
||||||
@get('model.pointing_project_instance_action_connections').forEach (pointing_connection) =>
|
@get('model.pointing_project_instance_action_connections').forEach (pointing_connection) =>
|
||||||
@@ -139,4 +144,4 @@ export default ModalBase.extend
|
|||||||
@set 'attached_conditions_not_met_warning', "#{pointing_connection.get('project_instance_action.workflow_action_definition.title')} not completed"
|
@set 'attached_conditions_not_met_warning', "#{pointing_connection.get('project_instance_action.workflow_action_definition.title')} not completed"
|
||||||
all_attached_actions_are_valid = false
|
all_attached_actions_are_valid = false
|
||||||
#alert 'Attached not completed'
|
#alert 'Attached not completed'
|
||||||
@_super arguments... if all_attached_actions_are_valid
|
@send('saveRecord') if all_attached_actions_are_valid
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ table.ui.top.attached.compact.definition.table
|
|||||||
if (eq value_type 'text')
|
if (eq value_type 'text')
|
||||||
.ui.bottom.attached.segment
|
.ui.bottom.attached.segment
|
||||||
= textarea value=text_value
|
= textarea value=text_value
|
||||||
each attached_instance_action_connections as |attached_instance_action_connection|
|
|
||||||
|
/each attached_instance_action_connections as |attached_instance_action_connection|
|
||||||
.ui.horizontal.divider
|
.ui.horizontal.divider
|
||||||
span Attached action
|
span Attached action
|
||||||
= attached_instance_action_connection.project_instance_action.workflow_action_definition.title
|
= attached_instance_action_connection.project_instance_action.workflow_action_definition.title
|
||||||
@@ -86,7 +87,7 @@ table.ui.top.attached.compact.definition.table
|
|||||||
.modal-actions.sticky
|
.modal-actions.sticky
|
||||||
/button.ui.primary.button.modal-save.pull-right{action "saveRecord"}= t 'general.save'
|
/button.ui.primary.button.modal-save.pull-right{action "saveRecord"}= t 'general.save'
|
||||||
/button.ui.negative.button.modal-destroy.pull-right{action "destroyRecord"}= t 'general.destroy.button'
|
/button.ui.negative.button.modal-destroy.pull-right{action "destroyRecord"}= t 'general.destroy.button'
|
||||||
if can_edit_action
|
if (and can_edit_action model.pointing_project_instance_action_connections.isFulfilled)
|
||||||
if (eq model.state 'inquiry')
|
if (eq model.state 'inquiry')
|
||||||
button.ui.pink.button.pull-right{action 'continue_from_inquiry'}= t 'action_list.continue_from_inquiry'
|
button.ui.pink.button.pull-right{action 'continue_from_inquiry'}= t 'action_list.continue_from_inquiry'
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user