Skip to content

Commit

Permalink
Merge pull request #1277 from MarkLark86/1.6
Browse files Browse the repository at this point in the history
Release 1.6.2-rc1
  • Loading branch information
MarkLark86 authored Aug 5, 2019
2 parents 35a0328 + 6b5c46d commit debd6b6
Show file tree
Hide file tree
Showing 70 changed files with 1,357 additions and 426 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
- TRAVIS_NODE_VERSION="6"
matrix:
- TEST_TYPE="unit"
- TEST_TYPE="e2e"
# - TEST_TYPE="e2e"

services:
- mongodb
Expand Down Expand Up @@ -41,4 +41,4 @@ script:
after_script:
- test $TEST_TYPE = "e2e" && killall -9 python
after_success:
- test $TEST_TYPE = "unit" && coveralls-lcov -v -n coverage/lcov.info > coverage.json && coveralls --merge=coverage.json
- test $TEST_TYPE = "unit" && coveralls-lcov -v -n coverage/lcov.info > coverage.json && coveralls --merge=coverage.json
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Superdesk Planning Changelog

## [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'

### 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

### 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

## [1.6.1] 2019-07-17
### Fixes
- [SDESK-4471] Reschedule and Postpone bugs when editor is open (#1259)
Expand Down
127 changes: 99 additions & 28 deletions client/actions/events/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,13 @@ const updateRepetitions = (original, updates) => (
)
);

const saveWithConfirmation = (original, updates, unlockOnClose) => (
const saveWithConfirmation = (original, updates, unlockOnClose, ignoreRecurring = false) => (
(dispatch, getState) => {
const maxRecurringEvents = selectors.config.getMaxRecurrentEvents(getState());

// If this is not from a recurring series, then simply post this event
if (!get(original, 'recurrence_id')) {
// Do the same if we need to ignore recurring event selection on purpose
if (!get(original, 'recurrence_id') || ignoreRecurring) {
return dispatch(eventsApi.save(original, updates));
}

Expand Down Expand Up @@ -741,42 +742,35 @@ const onEventEditUnlock = (event) => (
)
);

/**
* Action dispatcher that attempts to assign a calendar to an event
* @param {object} event - The Event to asssign the agenda
* @param {object} calendar - Calendar to be assigned
* @return Promise
*/
const assignToCalendar = (event, calendar) => (
const lockAndSaveUpdates = (
event,
updates,
lockAction,
successNotification,
failureNotification,
recurringModalAction,
openRecurringModal = true) => (
(dispatch, getState, {notify}) => {
const updates = {
_id: event._id,
type: event.type,
calendars: [...get(event, 'calendars', []), calendar],
_calendar: calendar,
};

// If this is a recurring event, then open the modal
// so the user can select which Events to assign this calendar to
if (get(event, 'recurrence_id')) {
return dispatch(self.openAssignCalendarModal(event, updates));
// so the user can select which Events to action on
// Note: Some actions don't need this if it is a recurring event
// Eg. "Mark event as complete"
if (get(event, 'recurrence_id') && openRecurringModal && recurringModalAction) {
return dispatch(recurringModalAction(event, updates));
}

// Otherwise lock, save and unlock this Event
// with the new list of calendars
return dispatch(locks.lock(event, 'assign_calendar'))
return dispatch(locks.lock(event, lockAction))
.then((original) => (
dispatch(main.saveAndUnlockItem(original, updates))
.then(() => {
notify.success(
gettext('Calendar assigned to the event')
);
return Promise.resolve();
dispatch(main.saveAndUnlockItem(original, updates, true))
.then((item) => {
notify.success(successNotification);
return Promise.resolve(item);
}, (error) => {
notify.error(
getErrorMessage(
error,
gettext('Failed to add Calendar to the Event')
failureNotification
)
);

Expand All @@ -794,6 +788,32 @@ const assignToCalendar = (event, calendar) => (
}
);

/**
* Action dispatcher that attempts to assign a calendar to an event
* @param {object} event - The Event to asssign the agenda
* @param {object} calendar - Calendar to be assigned
* @return Promise
*/
const assignToCalendar = (event, calendar) => (
(dispatch, getState, {notify}) => {
const updates = {
_id: event._id,
type: event.type,
calendars: [...get(event, 'calendars', []), calendar],
_calendar: calendar,
};

return dispatch(lockAndSaveUpdates(
event,
updates,
EVENTS.ITEM_ACTIONS.ASSIGN_TO_CALENDAR.lock_action,
gettext('Calendar assigned to the event'),
gettext('Failed to add Calendar to the Event'),
self.openAssignCalendarModal)
);
}
);

const save = (original, updates, confirmation, unlockOnClose) => (
(dispatch) => {
if (confirmation &&
Expand Down Expand Up @@ -834,6 +854,56 @@ const creatAndOpenPlanning = (item, planningDate = null, openPlanningItem = fals
)
);

const onMarkEventCompleted = (event, editor = true) => (
(dispatch) => {
let updates = {
_id: event._id,
type: event.type,
actioned_date: moment(),
completed: true,
};

if (event.recurrence_id) {
// 'all': to make sure if we select a future event and action on it, logic should still apply to events
// falling on the current day and ahead (not future and ahead) - determine which events in backend.
updates.update_method = {value: 'all'};
}

if (editor) {
return dispatch(main.openActionModalFromEditor(
event,
gettext('Save changes before marking event as complete ?'),
(unlockedItem, previousLock, openInEditor, openInModal) => (
dispatch(lockAndSaveUpdates(
unlockedItem,
updates,
EVENTS.ITEM_ACTIONS.MARK_AS_COMPLETED.lock_action,
gettext('Marked event as complete'),
gettext('Failed to mark event as complete'),
null,
false))
.then((result) => {
if (get(previousLock, 'action') && (openInEditor || openInModal)) {
dispatch(main.openForEdit(result, true, openInModal));
dispatch(locks.lock(result, previousLock.action));
}
})
)
));
}

// If actioned on list / preview
return dispatch(lockAndSaveUpdates(
event,
updates,
EVENTS.ITEM_ACTIONS.MARK_AS_COMPLETED.lock_action,
gettext('Marked event as complete'),
gettext('Failed to mark event as complete'),
null,
false));
}
);

// eslint-disable-next-line consistent-this
const self = {
fetchEvents,
Expand Down Expand Up @@ -873,6 +943,7 @@ const self = {
save,
openAssignCalendarModal,
creatAndOpenPlanning,
onMarkEventCompleted,
};

export default self;
4 changes: 2 additions & 2 deletions client/actions/locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ const getLocation = (searchText, unique = false, page = 1) => (
});
} else {
const terms = (!isEmpty(searchText)) ? searchText.split(' ') : '*';
const queryString = (terms.length > 1 ? terms.join('* AND ') : terms[0]) + '*';
const queryString = (terms.length > 1 ? terms.join('* ') : terms[0]) + '*';

return api('locations')
.query({
Expand All @@ -255,6 +255,7 @@ const getLocation = (searchText, unique = false, page = 1) => (
fields: ['name', 'address.line', 'address.area',
'address.postal_code', 'address.country', 'address.locality'],
query: queryString,
default_operator: 'AND',
},
}],
must_not: {
Expand All @@ -264,7 +265,6 @@ const getLocation = (searchText, unique = false, page = 1) => (
},
},
max_results: 200,
sort: '[(\'unique_name\', 1)]',
page: page,
});
}
Expand Down
29 changes: 23 additions & 6 deletions client/actions/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1407,21 +1407,38 @@ const spikeAfterUnlock = (unlockedItem, previousLock, openInEditor, openInModal)
* @param {object} updates - The item to save and unlock
* @return Promise
*/
const saveAndUnlockItem = (original, updates) => (
const saveAndUnlockItem = (original, updates, ignoreRecurring = false) => (
(dispatch, getState, {notify}) => {
const promise = getItemType(original) === ITEM_TYPE.PLANNING ?
dispatch(planningUi.save(original, updates)) :
dispatch(eventsUi.saveWithConfirmation(original, updates));
dispatch(eventsUi.saveWithConfirmation(original, updates, false, ignoreRecurring));

return promise
.then((savedItem) => (
dispatch(locks.unlock(get(savedItem, '[0]', savedItem)))
.then((savedItems) => {
let savedItem = Array.isArray(savedItems) ? savedItems[0] : savedItems;

savedItem = modifyForClient(savedItem);

switch (getItemType(original)) {
case ITEM_TYPE.EVENT:
dispatch(
eventsApi.receiveEvents([savedItem])
);
break;
case ITEM_TYPE.PLANNING:
dispatch(
planningApi.receivePlannings([savedItem])
);
break;
}

return dispatch(locks.unlock(get(savedItem, '[0]', savedItem)))
.then((unlockedItem) => Promise.resolve(unlockedItem))
.catch(() => {
notify.error(gettext('Could not unlock the item.'));
return Promise.reject(savedItem);
})
), (error) => {
});
}, (error) => {
notify.error(gettext('Could not save the item.'));
return Promise.reject(error);
});
Expand Down
Loading

0 comments on commit debd6b6

Please sign in to comment.