diff --git a/src/js/apps/programs/program/flow/flow_app.js b/src/js/apps/programs/program/flow/flow_app.js index 87e3f0973..fff2d28d9 100644 --- a/src/js/apps/programs/program/flow/flow_app.js +++ b/src/js/apps/programs/program/flow/flow_app.js @@ -4,7 +4,7 @@ import SubRouterApp from 'js/base/subrouterapp'; import ActionApp from 'js/apps/programs/program/action/action_app'; -import { LayoutView, ContextTrailView, HeaderView, ListView } from 'js/views/programs/program/flow/flow_views'; +import { LayoutView, ContextTrailView, HeaderView, AddActionView, ListView } from 'js/views/programs/program/flow/flow_views'; import { SidebarView } from 'js/views/programs/program/sidebar/sidebar-views'; export default SubRouterApp.extend({ @@ -43,6 +43,7 @@ export default SubRouterApp.extend({ })); this.showHeader(); + this.showAddAction(); this.showActionList(); this.showProgramSidebar(); }, @@ -63,12 +64,21 @@ export default SubRouterApp.extend({ this.listenTo(headerView, { 'edit': this.onEditFlow, + }); + + this.showChildView('header', headerView); + }, + + showAddAction() { + const addActionView = new AddActionView(); + + this.listenTo(addActionView, { 'click:addAction': () => { Radio.trigger('event-router', 'programFlow:action:new', this.flow.id); }, }); - this.showChildView('header', headerView); + this.showChildView('addAction', addActionView); }, showActionList() { diff --git a/src/js/i18n/en-US.yml b/src/js/i18n/en-US.yml index 2a9687a84..4e0c0f88d 100644 --- a/src/js/i18n/en-US.yml +++ b/src/js/i18n/en-US.yml @@ -678,10 +678,9 @@ careOptsFrontend: actionItemTemplate: newProgramFlowAction: New Flow Action flowViews: + addActionBtn: Action contextBackBtn: Back to List emptyView: No Actions - headerTemplate: - action: Action programViews: contextBackBtn: Back to List sidebar: diff --git a/src/js/views/programs/program/flow/flow_views.js b/src/js/views/programs/program/flow/flow_views.js index e7b84d3bf..1669785d5 100644 --- a/src/js/views/programs/program/flow/flow_views.js +++ b/src/js/views/programs/program/flow/flow_views.js @@ -51,12 +51,13 @@ const ContextTrailView = View.extend({ }); const HeaderView = View.extend({ + className: 'program-flow__header', modelEvents: { 'editing': 'onEditing', 'change': 'render', }, onEditing(isEditing) { - this.ui.flow.toggleClass('is-selected', isEditing); + this.$el.toggleClass('is-selected', isEditing); }, template: HeaderTemplate, regions: { @@ -64,11 +65,7 @@ const HeaderView = View.extend({ owner: '[data-owner-region]', }, triggers: { - 'click @ui.flow': 'edit', - 'click .js-add-action': 'click:addAction', - }, - ui: { - flow: '.js-flow', + 'click': 'edit', }, onRender() { this.showBehavior(); @@ -97,6 +94,17 @@ const HeaderView = View.extend({ }, }); +const AddActionView = View.extend({ + template: hbs` +
+ +
+ `, + triggers: { + 'click .js-add-action': 'click:addAction', + }, +}); + const EmptyView = View.extend({ tagName: 'tr', template: hbs` @@ -223,6 +231,7 @@ const LayoutView = View.extend({
+
@@ -233,6 +242,7 @@ const LayoutView = View.extend({ replaceElement: true, }, header: '[data-header-region]', + addAction: '[data-add-action-region]', sidebar: '[data-sidebar-region]', actionList: { el: '[data-action-list-region]', @@ -246,5 +256,6 @@ export { LayoutView, ContextTrailView, HeaderView, + AddActionView, ListView, }; diff --git a/src/js/views/programs/program/flow/header.hbs b/src/js/views/programs/program/flow/header.hbs index c868b8b50..c8e60c411 100644 --- a/src/js/views/programs/program/flow/header.hbs +++ b/src/js/views/programs/program/flow/header.hbs @@ -1,17 +1,12 @@ -
-

{{fas "folder-open"}} {{ name }}

-
-

- {{#if details}} - {{ details }} - {{ else }} - - {{/if}} -

{{~ remove_whitespace ~}} - - -
-
-
- +

{{fas "folder-open"}} {{ name }}

+
+

+ {{#if details}} + {{ details }} + {{ else }} + + {{/if}} +

{{~ remove_whitespace ~}} + +
diff --git a/test/integration/programs/sidebar/flow-sidebar.js b/test/integration/programs/sidebar/flow-sidebar.js index 70c96d001..e24c0bfb3 100644 --- a/test/integration/programs/sidebar/flow-sidebar.js +++ b/test/integration/programs/sidebar/flow-sidebar.js @@ -205,7 +205,7 @@ context('flow sidebar', function() { .as('routePatchFlow'); cy - .get('.js-flow') + .get('.program-flow__header') .as('flowHeader') .click('right') .should('have.class', 'is-selected'); @@ -222,6 +222,7 @@ context('flow sidebar', function() { cy .get('@flowHeader') + .should('not.have.class', 'is-selected') .click('right'); cy @@ -278,6 +279,7 @@ context('flow sidebar', function() { cy .get('@flowHeader') + .should('have.class', 'is-selected') .should('contain', 'Here are some details'); cy @@ -494,7 +496,7 @@ context('flow sidebar', function() { .wait('@routeProgramFlow'); cy - .get('.js-flow') + .get('.program-flow__header') .as('flowHeader') .click('right');