Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/2.8' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Nov 20, 2024
2 parents f735b0a + b6e2d27 commit c7838a7
Show file tree
Hide file tree
Showing 25 changed files with 389 additions and 54 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ jobs:
- run: npm ci
- run: npm run test
- run: npm run lint

extension:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- name: install
working-directory: client/planning-extension
run: npm ci
- name: compile
working-directory: client/planning-extension
run: npm run compile
2 changes: 2 additions & 0 deletions client/components/ContentProfiles/FieldTab/FieldEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class FieldEditor extends React.Component<IProps, IState> {
'schema.required': {enabled: !(this.props.disableRequired || this.props.systemRequired)},
'schema.read_only': {enabled: this.props.item.name === 'related_plannings'},
'schema.planning_auto_publish': {enabled: this.props.item.name === 'related_plannings'},
'schema.cancel_plan_with_event': {enabled: this.props.item.name === 'related_plannings'},
'schema.field_type': {enabled: fieldType != null},
'schema.minlength': {enabled: !disableMinMax},
'schema.maxlength': {enabled: !disableMinMax},
Expand Down Expand Up @@ -190,6 +191,7 @@ export class FieldEditor extends React.Component<IProps, IState> {
'schema.languages': {enabled: true, index: 12},
'schema.default_language': {enabled: true, index: 13},
'schema.planning_auto_publish': {enabled: true, index: 14},
'schema.cancel_plan_with_event': {enabled: true, index: 14},
'schema.default_value': {enabled: true, index: 11},
},
{
Expand Down
11 changes: 11 additions & 0 deletions client/components/fields/resources/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ registerEditorField(
true
);

registerEditorField(
'schema.cancel_plan_with_event',
EditorFieldCheckbox,
() => ({
label: superdeskApi.localization.gettext('Cancel planning items with Event'),
field: 'schema.cancel_plan_with_event',
}),
null,
true
);

registerEditorField(
'schema.planning_auto_publish',
EditorFieldCheckbox,
Expand Down
3 changes: 3 additions & 0 deletions client/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ export interface IProfileSchemaTypeList extends IBaseProfileSchemaType<'list'> {
mandatory_in_list?: {[key: string]: any};
vocabularies?: Array<IVocabulary['_id']>;
planning_auto_publish?: boolean;
cancel_plan_with_event?: boolean;
}

export interface IProfileSchemaTypeInteger extends IBaseProfileSchemaType<'integer'> {}
Expand Down Expand Up @@ -1149,6 +1150,7 @@ export interface IEventFormProfile {
reference: IProfileEditorField;
slugline: IProfileEditorField;
subject: IProfileEditorField;
related_plannings: IProfileEditorField;
};
name: 'event';
schema: {
Expand All @@ -1172,6 +1174,7 @@ export interface IEventFormProfile {
reference: IProfileSchemaTypeString;
slugline: IProfileSchemaTypeString;
subject: IProfileSchemaTypeList;
related_plannings: IProfileSchemaTypeList;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class AssignmentsCountTracker extends React.PureComponent<{}, {loading: t
{menuId: 'MENU_ITEM_PLANNING_ASSIGNMENTS', badgeValue: itemsCount.toString()},
);

return null;
return <></>;
}
}
</LiveAssignmentsHOC>
Expand Down
75 changes: 57 additions & 18 deletions client/utils/planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ import {planningConfig} from '../config';

const isCoverageAssigned = (coverage) => !!get(coverage, 'assigned_to.desk');

function isCancelPlanWithEventDisabled(): boolean {
return (planningApi.events.getEditorProfile().schema.related_plannings?.cancel_plan_with_event ?? true) === false;
}

function canPostPlanning(
planning: IPlanningItem,
event: IEventItem,
Expand All @@ -81,14 +85,19 @@ function canPostPlanning(
!!privileges[PRIVILEGES.PLANNING_MANAGEMENT] &&
!lockUtils.isLockRestricted(planning, session, locks) &&
getPostedState(planning) !== POST_STATE.USABLE &&
(isNil(event) || getItemWorkflowState(event) !== WORKFLOW_STATE.KILLED) &&
!isItemSpiked(planning) &&
!isItemSpiked(event) &&
(!isItemCancelled(planning) || getItemWorkflowState(planning) === WORKFLOW_STATE.KILLED) &&
!isItemCancelled(event) &&
!isItemRescheduled(planning) &&
!isItemRescheduled(event) &&
!isNotForPublication(planning)
!isNotForPublication(planning) &&
(!isItemCancelled(planning) || getItemWorkflowState(planning) === WORKFLOW_STATE.KILLED) &&
(
isNil(event)
|| isCancelPlanWithEventDisabled()
|| (
getItemWorkflowState(event) !== WORKFLOW_STATE.KILLED
&& !isItemSpiked(event)
&& !isItemRescheduled(event)
)
)
);
}

Expand Down Expand Up @@ -119,11 +128,17 @@ function canEditPlanning(
!!privileges[PRIVILEGES.PLANNING_MANAGEMENT] &&
!lockUtils.isLockRestricted(planning, session, locks) &&
!isItemSpiked(planning) &&
!isItemSpiked(event) &&
!(getPostedState(planning) === POST_STATE.USABLE && !privileges[PRIVILEGES.POST_PLANNING]) &&
!isItemRescheduled(planning) &&
(!isItemExpired(planning) || privileges[PRIVILEGES.EDIT_EXPIRED]) &&
(isNil(event) || getItemWorkflowState(event) !== WORKFLOW_STATE.KILLED)
(
isNil(event)
|| isCancelPlanWithEventDisabled()
|| (
getItemWorkflowState(event) !== WORKFLOW_STATE.KILLED &&
!isItemSpiked(event)
)
)
);
}

Expand All @@ -137,9 +152,13 @@ function canModifyPlanning(
!!privileges[PRIVILEGES.PLANNING_MANAGEMENT] &&
!lockUtils.isItemLocked(planning, locks) &&
!isItemSpiked(planning) &&
!isItemSpiked(event) &&
!isItemCancelled(planning) &&
!isItemRescheduled(planning)
!isItemRescheduled(planning) &&
(
isNil(event)
|| isCancelPlanWithEventDisabled()
|| !isItemSpiked(event)
)
);
}

Expand Down Expand Up @@ -215,10 +234,14 @@ function canUnspikePlanning(
isItemSpiked(plan) &&
!!privileges[PRIVILEGES.UNSPIKE_PLANNING] &&
!!privileges[PRIVILEGES.PLANNING_MANAGEMENT] &&
!isItemSpiked(event) &&
(
!isItemExpired(plan) ||
!!privileges[PRIVILEGES.EDIT_EXPIRED]
) &&
(
isNil(event)
|| isCancelPlanWithEventDisabled()
|| !isItemSpiked(event)
)
);
}
Expand All @@ -234,7 +257,11 @@ function canDuplicatePlanning(
!isItemSpiked(plan) &&
!!privileges[PRIVILEGES.PLANNING_MANAGEMENT] &&
!lockUtils.isLockRestricted(plan, session, locks) &&
!isItemSpiked(event)
(
isNil(event)
|| isCancelPlanWithEventDisabled()
|| !isItemSpiked(event)
)
);
}

Expand All @@ -249,12 +276,16 @@ function canCancelPlanning(
!!privileges[PRIVILEGES.PLANNING_MANAGEMENT] &&
!lockUtils.isLockRestricted(planning, session, locks) &&
getItemWorkflowState(planning) === WORKFLOW_STATE.SCHEDULED &&
getItemWorkflowState(event) !== WORKFLOW_STATE.SPIKED &&
!(
getPostedState(planning) === POST_STATE.USABLE &&
!privileges[PRIVILEGES.POST_PLANNING]
) &&
!isItemExpired(planning)
!isItemExpired(planning) &&
(
isNil(event)
|| isCancelPlanWithEventDisabled()
|| !isItemSpiked(event)
)
);
}

Expand All @@ -269,13 +300,17 @@ function canCancelAllCoverage(
!!privileges[PRIVILEGES.PLANNING_MANAGEMENT] &&
!isItemSpiked(planning) &&
!lockUtils.isLockRestricted(planning, session, locks) &&
getItemWorkflowState(event) !== WORKFLOW_STATE.SPIKED &&
canCancelAllCoverageForPlanning(planning) &&
!(
getPostedState(planning) === POST_STATE.USABLE &&
!privileges[PRIVILEGES.POST_PLANNING]
) &&
!isItemExpired(planning)
!isItemExpired(planning) &&
(
isNil(event)
|| isCancelPlanWithEventDisabled()
|| !isItemSpiked(event)
)
);
}

Expand Down Expand Up @@ -358,9 +393,13 @@ function canAddCoverages(
!!privileges[PRIVILEGES.PLANNING_MANAGEMENT] &&
lockUtils.isItemLocked(planning, locks) &&
lockUtils.isItemLockedInThisSession(planning, session, locks) &&
(isNil(event) || !isItemCancelled(event)) &&
(!isItemCancelled(planning) || isItemKilled(planning)) && !isItemRescheduled(planning) &&
!isItemExpired(planning)
!isItemExpired(planning) &&
(
isNil(event)
|| isCancelPlanWithEventDisabled()
|| !isItemCancelled(event)
)
);
}

Expand Down
15 changes: 4 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superdesk-planning",
"version": "2.8.0-dev",
"version": "2.8.2",
"license": "AGPL-3.0",
"description": "",
"repository": {
Expand All @@ -19,6 +19,7 @@
},
"author": "Edouard Richard",
"dependencies": {
"@superdesk/common": "0.0.17",
"dompurify": "^1.0.11",
"moment": "^2.30.1",
"moment-timezone": "^0.5.45",
Expand Down
Loading

0 comments on commit c7838a7

Please sign in to comment.