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

Add to workflow UX improvements #1978

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions client/actions/multiSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {MULTISELECT, ITEM_TYPE, MODALS} from '../constants';
import eventsUi from './events/ui';
import planningUi from './planning/ui';
import {getItemType, gettext, getItemInArrayById, getErrorMessage, lockUtils} from '../utils';
import {planningApi} from '../superdeskApi';

/**
* Action Dispatcher to select an/all Event(s)
Expand Down Expand Up @@ -180,6 +181,12 @@ const downloadEvents = (url, data) => {
req.send(JSON.stringify(data));
};

const bulkAddPlanningCoveragesToWorkflow = (items) => (
(dispatch) => planningApi.planning.coverages.bulkAddCoverageToWorkflow(items)
.then(() => dispatch({
type: MULTISELECT.ACTIONS.DESELECT_ALL_PLANNINGS,
}))
);

const exportAsArticle = (items = [], download) => (
(dispatch, getState, {api, notify, gettext, superdesk, $location, $interpolate, desks}) => {
Expand Down Expand Up @@ -312,6 +319,7 @@ const self = {
itemBulkSpikeModal,
itemBulkUnSpikeModal,
exportAsArticle,
bulkAddPlanningCoveragesToWorkflow,
};

export default self;
16 changes: 14 additions & 2 deletions client/components/Coverages/CoverageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IContactItem, IG2ContentType, IPlanningCoverageItem, IPlanningItem} from

import * as selectors from '../../selectors';
import * as actions from '../../actions';
import {WORKFLOW_STATE} from '../../constants';
import {COVERAGES, WORKFLOW_STATE} from '../../constants';
import {
getCreator,
getItemInArrayById,
Expand All @@ -20,6 +20,7 @@ import {getUserInterfaceLanguageFromCV} from '../../utils/users';
import {Item, Column, Row, Border, ActionMenu} from '../UI/List';
import {StateLabel, InternalNoteLabel} from '../../components';
import {CoverageIcons} from './CoverageIcons';
import {Label} from 'superdesk-ui-framework';

interface IProps {
coverage: IPlanningCoverageItem;
Expand All @@ -39,6 +40,7 @@ interface IProps {
}

interface IState {
addedToWorkflow: boolean;
userAssigned?: IUser;
deskAssigned?: IDesk;
coverageProvider?: string;
Expand Down Expand Up @@ -70,6 +72,7 @@ export class CoverageItemComponent extends React.Component<IProps, IState> {
coverageDateText: '',
internalNoteFieldPrefix: '',
coverageInWorkflow: false,
addedToWorkflow: false,
};

this.updateViewAttributes = this.updateViewAttributes.bind(this);
Expand Down Expand Up @@ -120,6 +123,7 @@ export class CoverageItemComponent extends React.Component<IProps, IState> {
userAssigned: null,
displayContentType: '',
coverageDateText: '',
addedToWorkflow: coverage.workflow_status === COVERAGES.WORKFLOW_STATE.ACTIVE,
};

if (!isPreview) {
Expand Down Expand Up @@ -220,7 +224,7 @@ export class CoverageItemComponent extends React.Component<IProps, IState> {
</span>
)}

<span className="grid">
<span className="grid sd-gap--x-small">
<InternalNoteLabel
item={item}
prefix={`${this.state.internalNoteFieldPrefix}.planning.`}
Expand All @@ -230,6 +234,14 @@ export class CoverageItemComponent extends React.Component<IProps, IState> {
`${this.state.internalNoteFieldPrefix}.workflow_status` : 'state'}
showHeaderText={false}
/>
{this.state.addedToWorkflow && (
<div>
<Label
text={gettext('Added to workflow')}
type="success"
/>
</div>
)}
<StateLabel
item={this.state.coverageInWorkflow ? get(coverage, 'assigned_to', {}) : coverage}
fieldName={this.state.coverageInWorkflow ? 'state' : 'workflow_status'}
Expand Down
5 changes: 3 additions & 2 deletions client/components/MultiSelectActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {eventUtils, planningUtils, gettext} from '../utils';
import {MAIN} from '../constants';
import {SlidingToolBar} from './UI/SubNav';
import {Button} from './UI';
import {planningApi} from '../superdeskApi';

export class MultiSelectActionsComponent extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -95,7 +94,7 @@ export class MultiSelectActionsComponent extends React.PureComponent {
key={0}
hollow={true}
onClick={() => {
planningApi.planning.coverages.bulkAddCoverageToWorkflow(this.getItemList());
this.props.addToWorkflow(this.getItemList());
}}
text={gettext('Add to workflow')}
/>
Expand Down Expand Up @@ -274,6 +273,7 @@ MultiSelectActionsComponent.propTypes = {
selectedEvents: PropTypes.array,
selectAllEvents: PropTypes.func,
deSelectAllEvents: PropTypes.func,
addToWorkflow: PropTypes.func,
selectedPlannings: PropTypes.array,
selectAllPlannings: PropTypes.func,
deSelectAllPlannings: PropTypes.func,
Expand Down Expand Up @@ -312,6 +312,7 @@ const mapDispatchToProps = (dispatch) => ({
spikeItems: (items) => dispatch(actions.multiSelect.itemBulkSpikeModal(items)),
unspikeItems: (items) => dispatch(actions.multiSelect.itemBulkUnSpikeModal(items)),
exportAsArticle: (items, download) => dispatch(actions.multiSelect.exportAsArticle(items, download)),
addToWorkflow: (items) => dispatch(actions.multiSelect.bulkAddPlanningCoveragesToWorkflow(items)),
});


Expand Down
4 changes: 3 additions & 1 deletion client/utils/planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,9 @@ function getCoverageIcon(
}

function getCoverageIconColor(coverage: IPlanningCoverageItem): string {
if (get(coverage, 'assigned_to.state') === ASSIGNMENTS.WORKFLOW_STATE.COMPLETED) {
if (coverage.workflow_status === COVERAGES.WORKFLOW_STATE.ACTIVE) {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't you have a different color here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, fritz wants to have this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, fritz wants this one

return 'var(--sd-colour-success)';
} else if (get(coverage, 'assigned_to.state') === ASSIGNMENTS.WORKFLOW_STATE.COMPLETED) {
return 'var(--sd-colour-success)';
} else if (isCoverageDraft(coverage) || get(coverage, 'workflow_status') === COVERAGES.WORKFLOW_STATE.ACTIVE) {
return 'var(--sd-colour-highlight)';
Expand Down
Loading