From 59b038ee1ab6bea739c12603e8d6843a6a218744 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Thu, 26 Sep 2024 13:51:09 +0300 Subject: [PATCH] Get latest article, fix conditions, fix initialization of action --- client/planning-extension/src/extension.ts | 20 ++++--- index.ts | 62 +--------------------- 2 files changed, 14 insertions(+), 68 deletions(-) diff --git a/client/planning-extension/src/extension.ts b/client/planning-extension/src/extension.ts index 487edb15a..8f1002045 100644 --- a/client/planning-extension/src/extension.ts +++ b/client/planning-extension/src/extension.ts @@ -140,9 +140,12 @@ const extension: IExtension = { superdeskArticle.itemAction(item).deschedule ) ) { - const event = new CustomEvent('planning:unlinkfromcoverage', {detail: {item}}); - window.dispatchEvent(event); + superdeskArticle.get(item._id).then((_item) => { + const event = new CustomEvent('planning:unlinkfromcoverage', {detail: {item: _item}}); + + window.dispatchEvent(event); + }) } }, }, @@ -157,15 +160,18 @@ const extension: IExtension = { // keep in sync with index.ts:79 if ( !item.assignment_id && - isContentLinkToCoverageAllowed(item) && !superdesk.entities.article.isPersonal(item) && - superdesk.privileges.hasPrivilege('archive') && + isContentLinkToCoverageAllowed(item) && !superdesk.entities.article.isLockedInOtherSession(item) && - !itemStates.includes(item.state) + !itemStates.includes(item.state) && + superdesk.privileges.hasPrivilege('archive') ) { - const event = new CustomEvent('planning:fulfilassignment', {detail: item}); + superdesk.entities.article.get(item._id).then((_item) => { + _item.slugline + const event = new CustomEvent('planning:fulfilassignment', {detail: {item: _item}}); - window.dispatchEvent(event); + window.dispatchEvent(event); + }) } }, } diff --git a/index.ts b/index.ts index 191beb47c..d57d65f53 100644 --- a/index.ts +++ b/index.ts @@ -75,66 +75,6 @@ function configurePlanning(superdesk) { authoring.itemActions(item).deschedule ); }], - }) - .activity('planning.fulfil', { - label: gettext('Fulfil Assignment'), - icon: 'calendar-list', - modal: true, - priority: 2000, - controller: ctrl.FulFilAssignmentController, - filters: [ - { - action: 'list', - type: 'archive', - }, - { - action: 'external-app', - type: 'fulfill-assignment', - }, - ], - group: gettext('Planning'), - privileges: {archive: 1}, - additionalCondition: ['archiveService', 'item', - function(archiveService, item: IArticle) { - return !item.assignment_id && - !archiveService.isPersonal(item) && - !superdeskApi.entities.article.isLockedInOtherSession(item) && - isContentLinkToCoverageAllowed(item) && - !['killed', 'recalled', 'unpublished', 'spiked', 'correction'].includes(item.state); - }], - }) - - // TAG: AUTHORING-ANGULAR - .activity('planning.unlink', { - label: gettext('Unlink as Coverage'), - icon: 'cut', - priority: 1000, - controller: ctrl.UnlinkAssignmentController, - filters: [ - { - action: 'list', - type: 'archive', - }, - { - action: 'external-app', - type: 'unlink-assignment', - }, - ], - group: gettext('Planning'), - privileges: {archive: 1}, - - // keep in sync with client/planning-extension/src/extension.ts:126 - additionalCondition: ['archiveService', 'item', 'authoring', - function(archiveService, item, authoring) { - return item.assignment_id && - !archiveService.isPersonal(item) && - !superdeskApi.entities.article.isLockedInOtherSession(item) && - ( - authoring.itemActions(item).edit || - authoring.itemActions(item).correct || - authoring.itemActions(item).deschedule - ); - }], }); } @@ -148,7 +88,7 @@ window.addEventListener('planning:fulfilassignment', (event: CustomEvent) => { localScope.resolve = handleDestroy; localScope.reject = handleDestroy; - localScope.locals = {data: {item: event.detail}}; + localScope.locals = {data: {item: event.detail.item}}; new ctrl.FulFilAssignmentController( element,