diff --git a/src/js/base/model.js b/src/js/base/model.js index d8c19e8f2..05f4355fb 100644 --- a/src/js/base/model.js +++ b/src/js/base/model.js @@ -1,5 +1,6 @@ import { extend, isEmpty, isFunction, pick, reduce, result } from 'underscore'; import Backbone from 'backbone'; +import dayjs from 'dayjs'; import JsonApiMixin from './jsonapi-mixin'; export default Backbone.Model.extend(extend({ @@ -84,6 +85,8 @@ export default Backbone.Model.extend(extend({ return isFunction(messages[category]) ? messages[category] : this[messages[category]]; }, handleMessage({ category, payload }) { + payload.attributes = extend(payload.attributes || {}, { updated_at: dayjs.utc().format() }); + const handler = this._getMessageHandler(category); if (handler) handler.call(this, payload); diff --git a/src/js/views/patients/sidebar/action/action-sidebar-activity-views.js b/src/js/views/patients/sidebar/action/action-sidebar-activity-views.js index 52d681317..76a293f96 100644 --- a/src/js/views/patients/sidebar/action/action-sidebar-activity-views.js +++ b/src/js/views/patients/sidebar/action/action-sidebar-activity-views.js @@ -264,6 +264,9 @@ const TimestampsView = View.extend({ createdAt: this.getOption('createdEvent').get('date'), }; }, + modelEvents: { + 'change:updated_at': 'render', + }, }); export { diff --git a/src/js/views/patients/sidebar/flow/flow-sidebar_views.js b/src/js/views/patients/sidebar/flow/flow-sidebar_views.js index dd1737eb9..c0247f013 100644 --- a/src/js/views/patients/sidebar/flow/flow-sidebar_views.js +++ b/src/js/views/patients/sidebar/flow/flow-sidebar_views.js @@ -76,6 +76,7 @@ const LayoutView = View.extend({ modelEvents: { 'change:_state': 'showOwner', 'change:_owner': 'showFlow', + 'change:updated_at': 'showTimestamps', }, onAttach() { animSidebar(this.el); diff --git a/test/integration/patients/patient/patient-flow.js b/test/integration/patients/patient/patient-flow.js index 0644cc614..71b5687f1 100644 --- a/test/integration/patients/patient/patient-flow.js +++ b/test/integration/patients/patient/patient-flow.js @@ -1,4 +1,5 @@ import _ from 'underscore'; +import dayjs from 'dayjs'; import { testTs, testTsSubtract } from 'helpers/test-timestamp'; import { testDate, testDateAdd, testDateSubtract } from 'helpers/test-date'; @@ -121,6 +122,7 @@ context('patient flow page', function() { duration: 10, outreach: 'disabled', sharing: 'disabled', + updated_at: testTsSubtract(1), }, relationships: { flow: getRelationship(testFlow), @@ -190,6 +192,13 @@ context('patient flow page', function() { .find('[data-action-region] .action-sidebar__name') .should('contain', 'New Websocket Name'); + cy + .get('.sidebar') + .find('.sidebar__footer') + .contains('Updated') + .next() + .should('contain', formatDate(dayjs.utc().format(), 'AT_TIME')); + cy .get('.sidebar') .find('[data-details-region] .js-input') @@ -2344,6 +2353,7 @@ context('patient flow page', function() { const testSocketFlow = getFlow({ attributes: { name: 'Flow Test', + updated_at: testTsSubtract(1), }, relationships: { state: getRelationship(stateInProgress), @@ -2358,6 +2368,7 @@ context('patient flow page', function() { due_time: '06:00:00', outreach: 'disabled', sharing: 'disabled', + updated_at: testTsSubtract(1), }, relationships: { flow: getRelationship(testSocketFlow), @@ -2383,6 +2394,7 @@ context('patient flow page', function() { return fx; }) .routeActionActivity() + .routeFlowActivity() .visit(`/flow/${ testSocketFlow.id }`) .wait('@routeFlow') .wait('@routePatientByFlow') @@ -2394,6 +2406,10 @@ context('patient flow page', function() { getRelationship(testSocketAction).data, ]); + cy + .get('[data-header-region]') + .click('top'); + cy.sendWs({ category: 'NameChanged', resource: { @@ -2412,6 +2428,18 @@ context('patient flow page', function() { .find('.patient-flow__name') .contains('New Flow Name'); + cy + .get('.app-frame__sidebar') + .find('.sidebar__footer') + .contains('Updated') + .next() + .should('contain', formatDate(dayjs.utc().format(), 'AT_TIME')); + + cy + .get('.app-frame__sidebar') + .find('.js-close') + .click(); + cy.sendWs({ category: 'DetailsChanged', resource: { @@ -2448,6 +2476,11 @@ context('patient flow page', function() { .find('.table-list__item .patient__action-name') .contains('New Action Name'); + cy + .get('.patient-flow__list') + .find('.table-list__item .patient__action-ts') + .should('contain', formatDate(dayjs.utc().format(), 'TIME_OR_DAY')); + cy.sendWs({ category: 'ActionDueChanged', resource: {