Skip to content

Commit

Permalink
Improve publish tab so you have the ability to save values to the art…
Browse files Browse the repository at this point in the history
…icle (#4265)
  • Loading branch information
thecalcc authored Jun 27, 2023
1 parent 1226022 commit b773972
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
7 changes: 6 additions & 1 deletion scripts/apps/authoring/authoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ angular.module('superdesk.apps.authoring', [
.component('sdAuthoringIntegrationWrapper', reactToAngular1(AuthoringAngularIntegration, ['itemId'], []))
.component(
'sdInteractiveArticleActionsPanelCombined',
reactToAngular1(InteractiveArticleActionsPanelCombined, ['onError', 'handleUnsavedChanges', 'location'], []),
reactToAngular1(InteractiveArticleActionsPanelCombined, [
'onError',
'handleUnsavedChanges',
'onDataChange',
'location',
], []),
)
.component('sdCharacterCountConfigButton', reactToAngular1(
CharacterCountConfigButton, ['field'], [], 'display: inline',
Expand Down
3 changes: 2 additions & 1 deletion scripts/apps/authoring/views/authoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ <h2 id="authoring-heading" class="a11y-only" translate>Authoring</h2>
handle-unsaved-changes="handleUnsavedChangesReact"
location="'authoring'"
on-error="onError"
></sd-interactive-article-actions-panel-combined>
on-data-change="autosave"
/>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface IProps {
handleUnsavedChanges(): Promise<IArticle>;
markupV2: boolean;
onError: (error: IPanelError) => void;
onDataChange: (item: IArticle) => void;
}

interface IState {
Expand All @@ -53,9 +54,9 @@ export class PublishTab extends React.PureComponent<IProps, IState> {
selectedDestination: getInitialDestination([this.props.item], false),
publishingDateOptions: getInitialPublishingDateOptions([props.item]),
publishingTarget: {
target_subscribers: [],
target_regions: [],
target_types: [],
target_subscribers: this.props.item.target_subscribers ?? [],
target_regions: this.props.item.target_regions ?? [],
target_types: this.props.item.target_regions ?? [],
},
subscribers: null,
};
Expand Down Expand Up @@ -166,6 +167,19 @@ export class PublishTab extends React.PureComponent<IProps, IState> {
onChange={(value) => {
this.setState({
selectedDestination: value,
}, () => {
const dest = this.state.selectedDestination;

if (dest.type === 'desk') {
this.props.onDataChange({
...this.props.item,
task: {
...(this.props.item.task ?? {}),
desk: dest.desk,
stage: dest.stage,
},
});
}
});
}}
includePersonalSpace={false}
Expand All @@ -186,17 +200,30 @@ export class PublishTab extends React.PureComponent<IProps, IState> {
items={[this.props.item]}
value={this.state.publishingDateOptions}
onChange={(val) => {
this.setState({publishingDateOptions: val});
this.setState(
{publishingDateOptions: val},
() => this.props.onDataChange({
...this.props.item,
...getPublishingDatePatch(
this.props.item,
this.state.publishingDateOptions,
),
}),
);
}}
allowSettingEmbargo={appConfig.ui.publishEmbargo !== false}
/>

<PublishingTargetSelect
value={this.state.publishingTarget}
onChange={(val) => {
this.setState({
publishingTarget: val,
});
this.setState(
{publishingTarget: val},
() => this.props.onDataChange({
...this.props.item,
...getPublishingTargetPatch(this.props.item, this.state.publishingTarget),
}),
);
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface IProps {
handleUnsavedChanges?(items: Array<IArticle>): Promise<Array<IArticle>>;
markupV2?: boolean;
onError: (error: IPanelError) => void;
onDataChange: (item: IArticle) => void;
}

export class InteractiveArticleActionsPanelCombined extends React.PureComponent<IProps> {
Expand All @@ -26,6 +27,7 @@ export class InteractiveArticleActionsPanelCombined extends React.PureComponent<

return (
<InteractiveArticleActionsPanel
onDataChange={this.props.onDataChange}
onError={this.props.onError}
items={state.items}
tabs={state.tabs}
Expand Down
4 changes: 3 additions & 1 deletion scripts/core/interactive-article-actions-panel/index-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface IPropsInteractiveArticleActionsPanelStateless extends IPanelAct
handleUnsavedChanges?(items: Array<IArticle>): Promise<Array<IArticle>>;
markupV2?: boolean;
onClose(): void;
onDataChange?(item: IArticle): void;
}

interface IState {
Expand All @@ -66,7 +67,7 @@ export class InteractiveArticleActionsPanel
}

render() {
const {items, tabs, onClose, onError} = this.props;
const {items, tabs, onClose, onError, onDataChange} = this.props;
const {activeTab} = this.state;
const markupV2 = authoringReactViewEnabled && this.props.markupV2 === true;
const handleUnsavedChanges = this.props.handleUnsavedChanges ?? handleUnsavedChangesDefault;
Expand Down Expand Up @@ -113,6 +114,7 @@ export class InteractiveArticleActionsPanel

return (
<PublishTab
onDataChange={onDataChange}
onError={onError}
item={item}
closePublishView={onClose}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export class DestinationSelect extends React.PureComponent<IProps> {
})()}
items={destinations}
onChange={(val) => {
if (val.id === PERSONAL_SPACE) {
if (val != null && val.id === PERSONAL_SPACE) {
this.props.onChange({
type: 'personal-space',
});
} else {
} else if (val != null) {
const deskId: IDesk['_id'] = val.id;
const nextStages = sdApi.desks.getDeskStages(deskId);

Expand Down

0 comments on commit b773972

Please sign in to comment.