Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlink as coverage #1847

Merged
merged 22 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion client/planning-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,40 @@ 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;

if (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you take these conditions from somewhere else? In order not to duplicate it, we should add canUnlinkAscoverage function and expose it via extensions bridge.

Copy link
Contributor Author

@thecalcc thecalcc Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is, we can't add it 1-to-1, because in the angular world permissions work under the hood, so if we do add it it'll still be chopped up. Personally I don't think it's necessary when this is the case, so we can keep it like this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the comment about keeping it up to date

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
12 changes: 11 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 @@ -134,5 +134,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
Loading