Skip to content

Commit

Permalink
Unlink as coverage (#1847)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc authored Sep 13, 2024
1 parent d206462 commit a480add
Show file tree
Hide file tree
Showing 3 changed files with 299 additions and 211 deletions.
29 changes: 28 additions & 1 deletion client/planning-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,41 @@ function onSendBefore(superdesk: ISuperdesk, items: Array<IArticle>, desk: IDesk
const extension: IExtension = {
activate: (superdesk: ISuperdesk) => {
const extensionConfig: IPlanningExtensionConfigurationOptions = superdesk.getExtensionConfig();

const displayTopbarWidget = superdesk.privileges.hasPrivilege('planning_assignments_view')
&& extensionConfig?.assignmentsTopBarWidget === true;
const {gettext} = superdesk.localization;

const result: IExtensionActivationResult = {
contributions: {
entities: {
article: {
getActions: (item) => [
{
label: gettext('Unlink as Coverage'),
groupId: 'planning-actions',
icon: 'cut',
onTrigger: () => {
const superdeskArticle = superdesk.entities.article;

// keep in sync with client/planning-extension/src/extension.ts:123
if (
superdesk.privileges.hasPrivilege('archive') &&
item.assignment_id != null &&
!superdeskArticle.isPersonal(item) &&
!superdeskArticle.isLockedInOtherSession(item) &&
(
superdeskArticle.itemAction(item).edit ||
superdeskArticle.itemAction(item).correct ||
superdeskArticle.itemAction(item).deschedule
)
) {
const event = new CustomEvent('planning:unlinkfromcoverage', {detail: {item}});

window.dispatchEvent(event);
}
},
}
],
onSpike: (item: IArticle) => onSpike(superdesk, item),
onSpikeMultiple: (items: Array<IArticle>) => onSpikeMultiple(superdesk, items),
onPublish: (item: IArticle) => onPublishArticle(superdesk, item),
Expand Down
16 changes: 15 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import planningModule from './client';
import * as ctrl from './client/controllers';
import {gettext} from './client/utils/gettext';
import {isContentLinkToCoverageAllowed} from './client/utils/archive';

import ng from 'superdesk-core/scripts/core/services/ng';

configurePlanning.$inject = ['superdeskProvider'];
function configurePlanning(superdesk) {
Expand Down Expand Up @@ -103,6 +103,8 @@ function configurePlanning(superdesk) {
!['killed', 'recalled', 'unpublished', 'spiked', 'correction'].includes(item.state);
}],
})

// TAG: AUTHORING-ANGULAR
.activity('planning.unlink', {
label: gettext('Unlink as Coverage'),
icon: 'cut',
Expand All @@ -120,6 +122,8 @@ function configurePlanning(superdesk) {
],
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 &&
Expand All @@ -134,5 +138,15 @@ function configurePlanning(superdesk) {
});
}

window.addEventListener('planning:unlinkfromcoverage', (event: CustomEvent) => {
ctrl.UnlinkAssignmentController(
event.detail,
ng.get('notify'),
ng.get('gettext'),
ng.get('api'),
ng.get('lock'),
);
});

export default planningModule
.config(configurePlanning);
Loading

0 comments on commit a480add

Please sign in to comment.