Safeguarding attached actions

This commit is contained in:
2017-12-25 13:36:09 +01:00
parent 9936a38843
commit 724a3688d9
7 changed files with 115 additions and 37 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ export default_filter = Ember.Object.create
project_id: ''
project_instance_project_scenario_id: ''
workflow_action_definition_organization_id: ''
offset_type_not_eq: 'attached'
workflow_action_definition_offset_type_not_eq: 'attached'
state_in: []
target_date_gteq: null
target_date_lteq: null
+1 -1
View File
@@ -10,7 +10,7 @@ export var default_filter = Ember.Object.create({
project_id: '',
project_instance_project_scenario_id: '',
workflow_action_definition_organization_id: '',
offset_type_not_eq: 'attached',
workflow_action_definition_offset_type_not_eq: 'attached',
state_in: [],
target_date_gteq: null,
target_date_lteq: null,
@@ -10,6 +10,8 @@ export default ModalBase.extend
new_note_content: ''
new_note_content_is_blank: Ember.computed.not 'new_note_content.length'
has_uncompleted_constraints: false
attached_instance_action_connections: []
attached_conditions_not_met_warning: ''
can_edit_action: Ember.computed 'model.workflow_action_definition.organization.users.[]', ->
return true if @get('globals.current_user.admin')
@@ -42,9 +44,22 @@ export default ModalBase.extend
@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
@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
@get('model.pointing_project_instance_action_connections').forEach (pointing_connection) =>
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
# always display non conditional attached actions
@get('attached_instance_action_connections').pushObject pointing_connection
#@get('pointing_project_instance_action_connections').forEach (pointing_connection) ->
select_class_names: Ember.computed 'model.string_value', ->
@@ -62,6 +77,8 @@ export default ModalBase.extend
actions:
set_value: (attribute, value) ->
#@set attribute, value # internal setting for validation
@set 'action_value', value
@set "model.#{attribute}", value
@send 'saveRecord'
@@ -73,6 +90,7 @@ export default ModalBase.extend
set_number_value: ->
@send 'set_value', 'number_value', @get('number_value')
set_timestamp_value: ->
@send 'set_value', 'timestamp_value', @get('timestamp_value')
@@ -110,3 +128,14 @@ export default ModalBase.extend
#record.save().then ->
# record.get('events').reload()
saveRecord: ->
all_attached_actions_are_valid = true
@set 'attached_conditions_not_met_warning', ''
@get('model.pointing_project_instance_action_connections').forEach (pointing_connection) =>
if pointing_connection.get('connection_type') is 'attached'
if conditional_value = pointing_connection.get('conditional_base_value')
if conditional_value is @get('model.string_comparison_value') and not pointing_connection.get('project_instance_action.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
#alert 'Attached not completed'
@_super arguments... if all_attached_actions_are_valid
@@ -38,6 +38,22 @@ export default DS.Model.extend
cls = if @get('boolean_value') then 'checkmark box' else 'square outline'
"<i class='#{cls} icon'></i>".htmlSafe()
string_comparison_value: Ember.computed 'workflow_action_definition.value_type', '{string_value,number_value,text_value,date_value,timestamp_value,boolean_value}', ->
return '' unless value_type = @get('workflow_action_definition.value_type')
switch value_type
when 'string', 'select'
@get('string_value')
when 'number'
if number = @get('number_value') then String(number) else ''
when 'text'
@get('text_value')
when 'date'
if date = @get('date_value') then date.format('YYYY-MM-DD') else ''
when 'timestamp'
if timestamp = @get('timestamp_value') then timestamp.format('YYYY-MM-DDThh:mm:ss') else ''
when 'boolean'
String(@get('boolean_value'))
project: DS.belongsTo('panda/project', inverse: 'project_instance_actions')
workflow_action_definition: DS.belongsTo('panda/workflow-action-definition', inverse: 'project_instance_actions')
project_instance_group: DS.belongsTo('panda/project-instance-group', inverse: 'project_instance_actions')
+1 -1
View File
@@ -88,7 +88,7 @@ table.ui.attached.stiped.table
= ui-markdown-popup tagName='i' class='info circle icon' markdown=project_instance_action.workflow_action_definition.extra_info
td= format-date project_instance_action.target_date
td= project/instance-action-value-display project_instance_action=project_instance_action
each project_instance_action.pointing_project_instance_action_connections as |project_instance_action_connection|
/each project_instance_action.pointing_project_instance_action_connections as |project_instance_action_connection|
if (eq project_instance_action_connection.connection_type 'attached')
tr.pointing-record
unless scope_project
@@ -52,6 +52,10 @@ table.ui.top.attached.compact.definition.table
if (eq value_type 'text')
.ui.bottom.attached.segment
= textarea value=text_value
each attached_instance_action_connections as |attached_instance_action_connection|
.ui.horizontal.divider
span Attached action
= attached_instance_action_connection.project_instance_action.workflow_action_definition.title
/minimal space for calendar at bottom right
if misc_events.length
.ui.horizontal.divider events
@@ -90,36 +94,51 @@ table.ui.top.attached.compact.definition.table
button.ui.pink.button.pull-right{action 'continue_from_inquiry'} Continue&hellip;
else
if (eq value_type 'boolean')
if model.boolean_value
button.ui.yellow.button.pull-right{action 'set_value' 'boolean_value' false}= t 'project_instance_action.revoke'
if attached_conditions_not_met_warning
.ui.visible.warning.message.pull-right= attached_conditions_not_met_warning
else
button.ui.primary.button.pull-right{action 'set_value' 'boolean_value' true}= t 'project_instance_action.done'
if model.boolean_value
button.ui.yellow.button.pull-right{action 'set_value' 'boolean_value' false}= t 'project_instance_action.revoke'
else
button.ui.primary.button.pull-right{action 'set_value' 'boolean_value' true}= t 'project_instance_action.done'
else if (eq value_type 'date')
.pull-right: .ui.revoke.action.input
= ui-calendar-moment type='date' momentValue=model.date_value onChange=(action 'set_value' 'date_value') placeholder="Select date" popupOptions=(hash position='top right' maxSearchDepth=0)
if model.date_value
button.ui.yellow.button.pull-right{action 'set_value' 'date_value' null}= t 'project_instance_action.revoke'
if attached_conditions_not_met_warning
.ui.visible.warning.message.pull-right= attached_conditions_not_met_warning
else
.pull-right: .ui.revoke.action.input
= ui-calendar-moment type='date' momentValue=model.date_value onChange=(action 'set_value' 'date_value') placeholder="Select date" popupOptions=(hash position='top right' maxSearchDepth=0)
if model.date_value
button.ui.yellow.button.pull-right{action 'set_value' 'date_value' null}= t 'project_instance_action.revoke'
else if (eq value_type 'timestamp')
if has_changed_timestamp_value
button.ui.primary.icon.button.pull-right{action 'set_timestamp_value'}: i.save.icon
if model.timestamp_value
button.ui.yellow.button.pull-right{action 'set_value' 'timestamp_value' null}= t 'project_instance_action.revoke'
.pull-right: .ui.revoke.action.input
= ui-calendar-moment type='datetime' ampm=false momentValue=timestamp_value onChange=(action (mut timestamp_value)) placeholder="Select timestamp" popupOptions=(hash position='top right' maxSearchDepth=0)
if attached_conditions_not_met_warning
.ui.visible.warning.message.pull-right= attached_conditions_not_met_warning
else
if has_changed_timestamp_value
button.ui.primary.icon.button.pull-right{action 'set_timestamp_value'}: i.save.icon
if model.timestamp_value
button.ui.yellow.button.pull-right{action 'set_value' 'timestamp_value' null}= t 'project_instance_action.revoke'
.pull-right: .ui.revoke.action.input
= ui-calendar-moment type='datetime' ampm=false momentValue=timestamp_value onChange=(action (mut timestamp_value)) placeholder="Select timestamp" popupOptions=(hash position='top right' maxSearchDepth=0)
else if (eq value_type 'string')
.pull-right: .ui.revoke.action.input
= input value=string_value enter='set_string_value'
if (not-eq string_value model.string_value)
button.ui.primary.icon.button{action 'set_string_value'}: i.save.icon
if model.string_value
button.ui.yellow.button{action 'set_value' 'string_value' ''}= t 'project_instance_action.revoke'
if attached_conditions_not_met_warning
.ui.visible.warning.message.pull-right= attached_conditions_not_met_warning
else
.pull-right: .ui.revoke.action.input
= input value=string_value enter='set_string_value'
if (not-eq string_value model.string_value)
button.ui.primary.icon.button{action 'set_string_value'}: i.save.icon
if model.string_value
button.ui.yellow.button{action 'set_value' 'string_value' ''}= t 'project_instance_action.revoke'
else if (eq value_type 'number')
.pull-right: .ui.revoke.action.input
= number-input numericValue=number_value step=1 enter='set_number_value'
if (not-eq number_value model.number_value)
button.ui.primary.icon.button{action 'set_number_value'}: i.save.icon
if model.number_value
button.ui.yellow.button.pull-right{action 'set_value' 'number_value' ''}= t 'project_instance_action.revoke'
if attached_conditions_not_met_warning
.ui.visible.warning.message.pull-right= attached_conditions_not_met_warning
else
.pull-right: .ui.revoke.action.input
= number-input numericValue=number_value step=1 enter='set_number_value'
if (not-eq number_value model.number_value)
button.ui.primary.icon.button{action 'set_number_value'}: i.save.icon
if model.number_value
button.ui.yellow.button.pull-right{action 'set_value' 'number_value' ''}= t 'project_instance_action.revoke'
else if (eq value_type 'select')
if model.workflow_action_definition.value_type_select_options.length
.ui.buttons.pull-right
@@ -130,18 +149,31 @@ table.ui.top.attached.compact.definition.table
each model.workflow_action_definition.value_type_select_options as |option|
.item= option
if model.string_value
if attached_conditions_not_met_warning
button.ui.negative.icon.button
= ui-popup tagName='i' class='close icon' content=attached_conditions_not_met_warning
else
button.ui.primary.icon.button{action 'set_string_value'}: i.save.icon
button.ui.yellow.button{action 'set_value' 'string_value' ''}= t 'project_instance_action.revoke'
else
.pull-right: .ui.revoke.action.input
= input value=string_value enter='set_string_value'
if model.string_value
if attached_conditions_not_met_warning
button.ui.negative.icon.button
= ui-popup tagName='i' class='close icon' content=attached_conditions_not_met_warning
else
button.ui.primary.icon.button{action 'set_string_value'}: i.save.icon
button.ui.yellow.button{action 'set_value' 'string_value' ''}= t 'project_instance_action.revoke'
else if (eq value_type 'text')
.ui.buttons.pull-right
if (not-eq text_value model.text_value)
button.ui.primary.button{action 'set_text_value'}= t 'project_instance_action.done'
if model.text_value
button.ui.yellow.button{action 'set_value' 'text_value' ''}= t 'project_instance_action.revoke'
if attached_conditions_not_met_warning
.ui.visible.warning.message.pull-right= attached_conditions_not_met_warning
else
.ui.buttons.pull-right
if (not-eq text_value model.text_value)
button.ui.primary.button{action 'set_text_value'}= t 'project_instance_action.done'
if model.text_value
button.ui.yellow.button{action 'set_value' 'text_value' ''}= t 'project_instance_action.revoke'
button.ui.basic.button.modal-rollback{action "close"}= t 'general.close'
@@ -5,6 +5,7 @@ translations = attributes:
uncategorized: 'uncategorized'
unplanned: 'unplanned'
planned: 'planned'
active: 'active'
overdue: 'overdue'
rejected: 'rejected'
completed: 'completed'
@@ -70,5 +71,5 @@ translations = attributes:
workflow_action_offset:
base_workflow_action_definition: 'Base ${models.workflow_action_definition}'
workflow_action_connection:
conditional_base_value: 'Visible if ${models.workflow_action_definition} is'
conditional_base_value: 'Required if ${models.workflow_action_definition} is'
export default translations