From 914f21c2ea1cedb811902702567f4a715b82b750 Mon Sep 17 00:00:00 2001 From: Mark Pittaway Date: Thu, 12 Oct 2023 18:11:09 +1100 Subject: [PATCH 1/3] [TGA-59] fix(author_approval): incorrect watch function signature --- .../authoring/directives/AuthoringContainerDirective.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/apps/authoring/authoring/directives/AuthoringContainerDirective.ts b/scripts/apps/authoring/authoring/directives/AuthoringContainerDirective.ts index 862da84e03..af8763ab6c 100644 --- a/scripts/apps/authoring/authoring/directives/AuthoringContainerDirective.ts +++ b/scripts/apps/authoring/authoring/directives/AuthoringContainerDirective.ts @@ -34,9 +34,9 @@ export function AuthoringContainerDirective(authoringWorkspace: AuthoringWorkspa link: function(scope, elem, attrs, ctrl) { // Needed only for authoring Angular. In authoring react we have a generic // event ('resource:updated') which listens to all item changes. - scope.$on('author_approval:updated', (event) => { - if (event.item_id === scope.item._id) { - scope.item.extra.publish_sign_off = event.sign_off_new_data; + scope.$on('author_approval:updated', (event, extra) => { + if (extra.item_id === ctrl.item?._id) { + ctrl.item.extra.publish_sign_off = extra.new_sign_off; } }); From 44447e84ff36b74110617a561c344860f562c3a7 Mon Sep 17 00:00:00 2001 From: thecalcc Date: Thu, 12 Oct 2023 14:23:33 +0300 Subject: [PATCH 2/3] Fix article update after it's been signed off --- .../authoring/directives/ArticleEditDirective.ts | 10 ++++++++++ .../directives/AuthoringContainerDirective.ts | 8 -------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/apps/authoring/authoring/directives/ArticleEditDirective.ts b/scripts/apps/authoring/authoring/directives/ArticleEditDirective.ts index 0798f30a7c..c870dc433f 100644 --- a/scripts/apps/authoring/authoring/directives/ArticleEditDirective.ts +++ b/scripts/apps/authoring/authoring/directives/ArticleEditDirective.ts @@ -167,6 +167,16 @@ export function ArticleEditDirective( } } + // Needed only for authoring Angular. In authoring react we have a generic + // event ('resource:updated') which listens to all item changes. + scope.$on('author_approval:updated', (_, extra) => { + if (extra.item_id === scope.item?._id) { + scope.item.extra = {publish_sign_off: extra.new_sign_off}; + + scope.$apply(); + } + }); + scope.$watch('item.language', () => { scope.monthNames = getMonthNamesShort(scope.item.language ?? appConfig.default_language) .map((label, i) => ({id: i.toString(), label: label})); diff --git a/scripts/apps/authoring/authoring/directives/AuthoringContainerDirective.ts b/scripts/apps/authoring/authoring/directives/AuthoringContainerDirective.ts index af8763ab6c..f043125efc 100644 --- a/scripts/apps/authoring/authoring/directives/AuthoringContainerDirective.ts +++ b/scripts/apps/authoring/authoring/directives/AuthoringContainerDirective.ts @@ -32,14 +32,6 @@ export function AuthoringContainerDirective(authoringWorkspace: AuthoringWorkspa scope: {}, require: 'sdAuthoringContainer', link: function(scope, elem, attrs, ctrl) { - // Needed only for authoring Angular. In authoring react we have a generic - // event ('resource:updated') which listens to all item changes. - scope.$on('author_approval:updated', (event, extra) => { - if (extra.item_id === ctrl.item?._id) { - ctrl.item.extra.publish_sign_off = extra.new_sign_off; - } - }); - scope.$watch(authoringWorkspace.getState, (state) => { if (state) { if (itemInEditMode != null) { From e06dbf0a35636ba6ea178d317b6b96c1edc0b92f Mon Sep 17 00:00:00 2001 From: Mark Pittaway Date: Fri, 13 Oct 2023 10:34:22 +1100 Subject: [PATCH 3/3] fix lint issue, dont wipe extra on update --- .../authoring/authoring/directives/ArticleEditDirective.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/apps/authoring/authoring/directives/ArticleEditDirective.ts b/scripts/apps/authoring/authoring/directives/ArticleEditDirective.ts index c870dc433f..50c62aaa91 100644 --- a/scripts/apps/authoring/authoring/directives/ArticleEditDirective.ts +++ b/scripts/apps/authoring/authoring/directives/ArticleEditDirective.ts @@ -169,10 +169,13 @@ export function ArticleEditDirective( // Needed only for authoring Angular. In authoring react we have a generic // event ('resource:updated') which listens to all item changes. - scope.$on('author_approval:updated', (_, extra) => { + scope.$on('author_approval:updated', (_event, extra) => { if (extra.item_id === scope.item?._id) { - scope.item.extra = {publish_sign_off: extra.new_sign_off}; + if (scope.item.extra == null) { + scope.item.extra = {}; + } + scope.item.extra.publish_sign_off = extra.new_sign_off; scope.$apply(); } });