Skip to content

Commit

Permalink
Merge pull request #1291 from MarkLark86/1.6
Browse files Browse the repository at this point in the history
Release 1.6.2-rc2
  • Loading branch information
MarkLark86 authored Aug 15, 2019
2 parents debd6b6 + cb2b646 commit fbc0684
Show file tree
Hide file tree
Showing 51 changed files with 2,085 additions and 1,129 deletions.
37 changes: 25 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,35 @@

## [1.6.2] Not Released Yet
### Features
- [SDESK-4469] Introduce modal to prompt for a 'reason' to cancel individual coverages
- [SDESK-4427] New Event action 'Mark as Completed'
- [SDESK-4469] Introduce modal to prompt for a 'reason' to cancel individual coverages (#1260)
- [SDESK-4427] New Event action 'Mark as Completed' (#1273)

### Improvements
- [SDESK-3286] Close popup modals with ESC key
- [SDESK-4428] Multiselect in the Event list and Planning list
- [SDESK-4402] Improve location display in planning lists
- [SDESK-4493] Create a history record for Planning items and events when an Event is created from planning item
- [SDESK-4421] Add details to location dropdown
- [SDESK-3286] Close popup modals with ESC key (#1272)
- [SDESK-4428] Multiselect in the Event list and Planning list (#1268)
- [SDESK-4402] Improve location display in planning lists (#1266)
- [SDESK-4493] Create a history record for Planning items and events when an Event is created from planning item (#1264)
- [SDESK-4421] Add details to location dropdown (#1263)
- [SDBELGA-129] Include coverage without users on export templates (#1281)
- [SDESK-4286] Minor changes to event and planning list items in Export Modal (#1279)
- [SDESK-4566] Position 'start working' as the first item in the action menu for assignments (#1282)
- [SDESK-4573] Slack mentions in slack notifications (#1283)
- [SDESK-4529][SDESK-4534] Show current and future only assignments in the Fulfill modal (#1284)

### Fixes
- [SDESK-4286] List Item format for exporting and downloading events/planning
- [SDESK-4478] Correctly display the number of events in Post/Unpost popup
- [SDESK-4549] Coverages are inheriting published time and not scheduled time of a story
- [SDESK-4328] Remove ability to clear the coverage type in the editor
- (fix): Update enzyme-adapter-react-16
- [SDESK-4286] List Item format for exporting and downloading events/planning (#1276)
- [SDESK-4478] Correctly display the number of events in Post/Unpost popup (#1275)
- [SDESK-4549] Coverages are inheriting published time and not scheduled time of a story (#1271)
- [SDESK-4328] Remove ability to clear the coverage type in the editor (1270)
- (fix): Update enzyme-adapter-react-16 (#1269)
- [SDESK-4427] Mark for complete fix to cater for events that start on same day but ahead in time. (#1278)
- [SDESK-4571] Allow content unlinking when content has been archived (1280)
- [SDESK-4552] (fix): Assignment preview not showing from monitoring preview (#1285)
- [SDESK-4477] (fix): Cannot lower repetitions unless on the first event (#1286))
- [SDESK-4511] (fix): Scrollbar required for planning items in CancelEvent modal (#1287)
- [SDESK-4524] Make contact form read only when embedded in read only coverage form (#1289)
- [SDESK-4535] Fulfill assignment available for Reporters (#1288)
- [SDESK-4609] Filter soft deleted locations out from the browse view (#1290)

## [1.6.1] 2019-07-17
### Fixes
Expand Down
176 changes: 135 additions & 41 deletions client/actions/assignments/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import moment from 'moment';
import {get, cloneDeep, has, pick} from 'lodash';

import * as selectors from '../../selectors';
import {ASSIGNMENTS} from '../../constants';
import planningUtils from '../../utils/planning';
import {get, cloneDeep, has, pick} from 'lodash';
import {lockUtils, getErrorMessage, isExistingItem, gettext} from '../../utils';
import planning from '../planning';

Expand All @@ -10,6 +12,118 @@ const setBaseQuery = ({must = []}) => ({
payload: {must},
});

const constructQuery = ({
systemTimezone,
baseQuery,
searchQuery,
deskId = null,
userId = null,
states = [],
type = null,
priority = null,
dateFilter = null,
}) => {
let must = [];

const filters = [{
condition: () => deskId,
do: () => {
must.push(
{term: {'assigned_to.desk': deskId}}
);
},
}, {
condition: () => userId,
do: () => {
must.push(
{term: {'assigned_to.user': userId}}
);
},
}, {
condition: () => get(states, 'length', 0) > 0,
do: () => {
must.push(
{terms: {'assigned_to.state': states}}
);
},
}, {
condition: () => type,
do: () => {
must.push(
{term: {'planning.g2_content_type': type}}
);
},
}, {
condition: () => priority,
do: () => {
must.push(
{term: {priority: priority}}
);
},
}, {
condition: () => searchQuery,
do: () => {
must.push(
{query_string: {query: searchQuery}}
);
},
}, {
condition: () => dateFilter,
do: () => {
const timezoneOffset = moment()
.tz(systemTimezone || moment.tz.guess())
.format('Z');

switch (dateFilter) {
case 'today':
must.push({
range: {
'planning.scheduled': {
gte: 'now/d',
lte: 'now/d',
time_zone: timezoneOffset,
},
},
});
break;
case 'current':
must.push({
range: {
'planning.scheduled': {
lte: 'now/d',
time_zone: timezoneOffset,
},
},
});
break;
case 'future':
must.push({
range: {
'planning.scheduled': {
gt: 'now/d',
time_zone: timezoneOffset,
},
},
});
break;
}
},
}, {
condition: () => get(baseQuery, 'must.length', 0) > 0,
do: () => {
must = must.concat(baseQuery.must);
},
}];

filters.forEach((filter) => {
if (filter.condition()) {
filter.do();
}
});

return {bool: {must}};
};


/**
* Action Dispatcher for query the api for events
Expand All @@ -25,6 +139,8 @@ const query = ({
states = [],
type = null,
priority = null,
dateFilter = null,
size = null,
}) => (
(dispatch, getState, {api}) => {
const filterByValues = {
Expand All @@ -34,53 +150,30 @@ const query = ({
Scheduled: 'planning.scheduled',
};

const baseQuery = selectors.getBaseAssignmentQuery(getState());

let query = {};
let must = [];
let sort = '[("' + (get(filterByValues, orderByField, 'planning.scheduled')) + '", '
+ (orderDirection === 'Asc' ? 1 : -1) + ')]';

if (deskId) {
must.push(
{term: {'assigned_to.desk': deskId}}
);
}

if (userId) {
must.push(
{term: {'assigned_to.user': userId}}
);
}

if (states.length > 0) {
must.push(
{terms: {'assigned_to.state': states}}
);
}

if (type) {
must.push(
{term: {'planning.g2_content_type': type}}
);
}

if (priority) {
must.push(
{term: {priority: priority}}
);
}

if (searchQuery) {
must.push({query_string: {query: searchQuery}});
}

query.bool = {must: must.concat(baseQuery.must)};
const systemTimezone = selectors.config.defaultTimeZone(getState());
const baseQuery = selectors.getBaseAssignmentQuery(getState());
const query = constructQuery({
systemTimezone,
baseQuery,
searchQuery,
deskId,
userId,
states,
type,
priority,
dateFilter,
});

return api('assignments').query({
page: page,
sort: sort,
source: JSON.stringify({query}),
source: JSON.stringify(size !== null ?
{query, size} :
{query}
),
})
.then((data) => {
if (get(data, '_items')) {
Expand Down Expand Up @@ -467,6 +560,7 @@ const self = {
receiveAssignmentHistory,
unlink,
setBaseQuery,
constructQuery,
};

export default self;
28 changes: 18 additions & 10 deletions client/actions/assignments/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,31 @@ const onAssignmentUpdated = (_e, data) => (
);

if (querySearchSettings.deskId === null ||
currentDesk === data.assigned_desk || currentDesk === data.original_assigned_desk) {
currentDesk === data.assigned_desk ||
currentDesk === data.original_assigned_desk
) {
dispatch(assignments.api.fetchAssignmentHistory({_id: data.item}));
dispatch(assignments.ui.reloadAssignments([data.assignment_state]));

dispatch(assignments.api.fetchAssignmentById(data.item))
.then((assignmentInStore) => {
// If assignment moved from one state to another, check if group changed
// And trigger reload
// If assignment moved from one state to another, check if group changed
// And trigger reload
if (assignmentInStore.assigned_to.state !== data.assignment_state) {
const originalGroup = assignmentUtils.getAssignmentGroupByStates(
[assignmentInStore.assigned_to.state]);
const newGroup = assignmentUtils.getAssignmentGroupByStates(
[data.assignment_state]);

if (newGroup.label !== originalGroup.label) {
const visibleGroups = selectors.getAssignmentGroups(getState());
const originalGroups = assignmentUtils.getAssignmentGroupsByStates(
visibleGroups,
[assignmentInStore.assigned_to.state]
);
const newGroups = assignmentUtils.getAssignmentGroupsByStates(
visibleGroups,
[data.assignment_state]
);

if (newGroups[0] !== originalGroups[0]) {
dispatch(assignments.ui.reloadAssignments(
[assignmentInStore.assigned_to.state]));
[assignmentInStore.assigned_to.state])
);
}
}
});
Expand Down
Loading

0 comments on commit fbc0684

Please sign in to comment.