Skip to content

Commit

Permalink
Get latest article, fix conditions, fix initialization of action
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Sep 26, 2024
1 parent 7e4b490 commit 59b038e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 68 deletions.
20 changes: 13 additions & 7 deletions client/planning-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ const extension: IExtension = {
superdeskArticle.itemAction(item).deschedule
)
) {

Check failure on line 142 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

Block must not be padded by blank lines

Check failure on line 142 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

Block must not be padded by blank lines
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}});

Check failure on line 145 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

This line has a length of 130. Maximum allowed is 120

Check failure on line 145 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

This line has a length of 130. Maximum allowed is 120

window.dispatchEvent(event);
})

Check failure on line 148 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

Missing semicolon

Check failure on line 148 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

Missing semicolon
}
},
},
Expand All @@ -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

Check failure on line 170 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

Missing semicolon

Check failure on line 170 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

Missing semicolon
const event = new CustomEvent('planning:fulfilassignment', {detail: {item: _item}});

Check failure on line 171 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

This line has a length of 128. Maximum allowed is 120

Check failure on line 171 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

This line has a length of 128. Maximum allowed is 120

window.dispatchEvent(event);
window.dispatchEvent(event);
})

Check failure on line 174 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

Missing semicolon

Check failure on line 174 in client/planning-extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / client (14.x)

Missing semicolon
}
},
}
Expand Down
62 changes: 1 addition & 61 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}],
});
}

Expand All @@ -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,
Expand Down

0 comments on commit 59b038e

Please sign in to comment.