From 5efa6f05e6216b6fedcd0ba9a9bd36e1be4df52a Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Tue, 9 Oct 2018 13:44:49 -0300 Subject: [PATCH] instance-action notes display enhancements and trigger refresh on action deletion --- .../compact-notes-display.js | 4 +++ .../compact-notes-display.js | 1 + .../edit-workflow-action-definition.coffee | 11 ++++++++ .../show/project-instance/show/actions.coffee | 4 +++ app/templates/action-list.emblem | 9 +------ .../compact-notes-display.emblem | 8 ++++++ .../show/project-instance-action/index.emblem | 3 +++ .../show/project-instance/show/actions.emblem | 3 +++ .../-edit-workflow-action-definition.emblem | 2 +- .../compact-notes-display-test.coffee | 25 +++++++++++++++++++ 10 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 addon/components/project-instance-action/compact-notes-display.js create mode 100644 app/components/project-instance-action/compact-notes-display.js create mode 100644 app/templates/components/project-instance-action/compact-notes-display.emblem create mode 100644 tests/integration/components/project-instance-action/compact-notes-display-test.coffee diff --git a/addon/components/project-instance-action/compact-notes-display.js b/addon/components/project-instance-action/compact-notes-display.js new file mode 100644 index 0000000..926b613 --- /dev/null +++ b/addon/components/project-instance-action/compact-notes-display.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ +}); diff --git a/app/components/project-instance-action/compact-notes-display.js b/app/components/project-instance-action/compact-notes-display.js new file mode 100644 index 0000000..74267ac --- /dev/null +++ b/app/components/project-instance-action/compact-notes-display.js @@ -0,0 +1 @@ +export { default } from 'ember-panda/components/project-instance-action/compact-notes-display'; diff --git a/app/components/workflow-action-definition/modals/edit-workflow-action-definition.coffee b/app/components/workflow-action-definition/modals/edit-workflow-action-definition.coffee index 5a2a6d5..fc72f2f 100644 --- a/app/components/workflow-action-definition/modals/edit-workflow-action-definition.coffee +++ b/app/components/workflow-action-definition/modals/edit-workflow-action-definition.coffee @@ -169,6 +169,17 @@ Component = # else # workflow_action_constraint.deleteRecord() # @set 'new_workflow_action_constraint_warning', '' + destroy_workflow_action_definition: -> + project = @get('model.project') + @modal 'confirm', + title_path: @get('modal_options.destroy_text_path') || 'general.destroy.are_you_sure' + model: @get('model') + ok: -> + model = @get("model") + model = model.get("_content") if model.__changeset__ + model.destroyRecord().then -> project.incrementProperty('update_revision') + @send 'closeModal' unless @preventClose + destroyWorkflowActionOffset: (workflow_action_offset) -> if workflow_action_offset.get('isNew') diff --git a/app/controllers/project/show/project-instance/show/actions.coffee b/app/controllers/project/show/project-instance/show/actions.coffee index f33eb3b..c3ec1c2 100644 --- a/app/controllers/project/show/project-instance/show/actions.coffee +++ b/app/controllers/project/show/project-instance/show/actions.coffee @@ -36,6 +36,7 @@ export default Ember.Controller.extend filters: Ember.Object.create state_in: [] workflow_group_name_cont: '' + notes_cont: '' workflow_action_definition_title_cont: '' target_date_lteq: null target_date_gteq: null @@ -50,6 +51,9 @@ export default Ember.Controller.extend if title_filter = @get('filters.workflow_action_definition_title_cont') matcher = new RegExp(title_filter, 'i') actions = actions.filter (record) -> matcher.test record.get('workflow_action_definition.title') + if notes_filter = @get('filters.notes_cont') + matcher = new RegExp(notes_filter, 'i') + actions = actions.filter (record) -> matcher.test record.get('notes') actions.sort target_date_sort actions: diff --git a/app/templates/action-list.emblem b/app/templates/action-list.emblem index b1fadc9..745b59f 100644 --- a/app/templates/action-list.emblem +++ b/app/templates/action-list.emblem @@ -88,14 +88,7 @@ table.ui.attached.stiped.sortable.table else = project_instance_action.project_instance.client_identifier td= state-badge project_instance_action.state action=(action 'edit_project_instance_action' project_instance_action) - td - if (gt project_instance_action.notes.length 14) - = ui-markdown-popup tagName='i' class='pointable sticky note outline icon' markdown=project_instance_action.notes on='click' - else if project_instance_action.notes - = project_instance_action.notes - if project_instance_action.workflow_action_definition.extra_info - ' - = ui-markdown-popup tagName='i' class='pointable info circle icon' markdown=project_instance_action.workflow_action_definition.extra_info on='click' + td= project-instance-action/compact-notes-display record=project_instance_action td= format-date project_instance_action.target_date format=globals.date_formatting if show_completed_at td= format-date project_instance_action.completed_at format=globals.time_formatting diff --git a/app/templates/components/project-instance-action/compact-notes-display.emblem b/app/templates/components/project-instance-action/compact-notes-display.emblem new file mode 100644 index 0000000..6c7316f --- /dev/null +++ b/app/templates/components/project-instance-action/compact-notes-display.emblem @@ -0,0 +1,8 @@ +if (gt record.notes.length 14) + = ui-markdown-popup tagName='i' class='pointable sticky note outline icon' markdown=record.notes on='click' +else if record.notes + = record.notes +if record.workflow_action_definition.extra_info + ' + = ui-markdown-popup tagName='i' class='pointable info circle icon' markdown=record.workflow_action_definition.extra_info on='click' += yield diff --git a/app/templates/project/show/project-instance-action/index.emblem b/app/templates/project/show/project-instance-action/index.emblem index 05cc615..a22ba5d 100644 --- a/app/templates/project/show/project-instance-action/index.emblem +++ b/app/templates/project/show/project-instance-action/index.emblem @@ -26,6 +26,7 @@ table.ui.bottom.attached.stiped.table th= t 'models.workflow_action_definition' th= t 'models.project_instance' th= t 'attributes.project_instance_action.state' + th= t 'attributes.project_instance_action.notes' / ui-dropdown class='right basic labeled icon' action='nothing' i.dropdown.icon span.ui.tiny.header class=filter.state_in.length:active-filter @@ -68,6 +69,7 @@ table.ui.bottom.attached.stiped.table = filter.dropdown-select-multiple key='workflow_action_definition_id_in' options=project.sorted_workflow_action_definitions labelPath='title' = filter.input key='project_instance_client_identifier_cont' = filter.dropdown-select-multiple key='state_in' options=globals.project_instance_action.states translationPath='attributes.state' + = filter.input key='notes_cont' = filter.date-range key='target_date' expandingTime=true weekSelector=true /th class=date_filter_active:active-filter ui-dropdown class='right basic labeled top right pointing icon' action='nothing' @@ -95,5 +97,6 @@ table.ui.bottom.attached.stiped.table td= link-to 'project.show.project-instance.show' project_instance_action.project_instance.project.id project_instance_action.project_instance.id span= project_instance_action.project_instance.client_identifier td= state-badge project_instance_action.state + td= project-instance-action/compact-notes-display record=project_instance_action td= format-date project_instance_action.target_date format=globals.date_formatting td= project/instance-action-value-display project_instance_action=project_instance_action diff --git a/app/templates/project/show/project-instance/show/actions.emblem b/app/templates/project/show/project-instance/show/actions.emblem index 7c745f0..0f937b5 100644 --- a/app/templates/project/show/project-instance/show/actions.emblem +++ b/app/templates/project/show/project-instance/show/actions.emblem @@ -4,12 +4,14 @@ table.ui.bottom.attached.striped.table th= t 'models.project_instance_group' th= t 'models.workflow_action_definition' th= t 'attributes.project_instance_action.state' + th= t 'attributes.project_instance_action.notes' th= t 'attributes.project_instance_action.target_date' th= t 'attributes.project_instance_action.value' table-filters filters=filters as |filter| = filter.input key='workflow_group_name_cont' = filter.input key='workflow_action_definition_title_cont' = filter.dropdown-select-multiple key='state_in' options=globals.project_instance_action.states translationPath='attributes.state' eager_filter=true + = filter.input key='notes_cont' th th @@ -23,5 +25,6 @@ table.ui.bottom.attached.striped.table span= project_instance_action.project_instance_group.workflow_group.name td= project_instance_action.workflow_action_definition.title td= state-badge project_instance_action.state action=(action 'edit_project_instance_action' project_instance_action) + td= project-instance-action/compact-notes-display record=project_instance_action td= format-date project_instance_action.target_date format=globals.date_formatting td= project/instance-action-value-display project_instance_action=project_instance_action diff --git a/app/templates/workflow-action-definition/-edit-workflow-action-definition.emblem b/app/templates/workflow-action-definition/-edit-workflow-action-definition.emblem index 8ceda6b..60aec15 100644 --- a/app/templates/workflow-action-definition/-edit-workflow-action-definition.emblem +++ b/app/templates/workflow-action-definition/-edit-workflow-action-definition.emblem @@ -242,4 +242,4 @@ each non_deleted_working_pointing_workflow_action_connections as |pointing_conne button.ui.basic.button.modal-rollback{ action 'rollback_and_close'}= t 'general.rollback' push-action type='position' action='positionInProject' 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 'destroy_workflow_action_definition'}= t 'general.destroy.button' diff --git a/tests/integration/components/project-instance-action/compact-notes-display-test.coffee b/tests/integration/components/project-instance-action/compact-notes-display-test.coffee new file mode 100644 index 0000000..9ef3a80 --- /dev/null +++ b/tests/integration/components/project-instance-action/compact-notes-display-test.coffee @@ -0,0 +1,25 @@ +import { test, moduleForComponent } from 'ember-qunit' +import hbs from 'htmlbars-inline-precompile' + +moduleForComponent 'project-instance-action/compact-notes-display', 'Integration | Component | project instance action/compact notes display', { + integration: true +} + +test 'it renders', (assert) -> + assert.expect 2 + + # Set any properties with @set 'myProperty', 'value' + # Handle any actions with @on 'myAction', (val) -> + + @render hbs """{{project-instance-action/compact-notes-display}}""" + + assert.equal @$().text().trim(), '' + + # Template block usage: + @render hbs """ + {{#project-instance-action/compact-notes-display}} + template block text + {{/project-instance-action/compact-notes-display}} + """ + + assert.equal @$().text().trim(), 'template block text'