From b32220496b972bc0bd171e7f9e64ecf1c0bf9160 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 26 Nov 2018 19:16:26 +0100 Subject: [PATCH 01/23] Adding action and service to handle edition control on slides. --- .../slidesEditions/controlSlideEditions.js | 15 +++++++++++ services/currentSlidesEditions.js | 26 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 actions/slidesEditions/controlSlideEditions.js create mode 100644 services/currentSlidesEditions.js diff --git a/actions/slidesEditions/controlSlideEditions.js b/actions/slidesEditions/controlSlideEditions.js new file mode 100644 index 000000000..8deffd321 --- /dev/null +++ b/actions/slidesEditions/controlSlideEditions.js @@ -0,0 +1,15 @@ +import log from '../log/clog'; + +export default function controlSlideEditions(context, slideId, done) { + + log.info(context); + let user = context.getUser(); + + let username = user.username ? user.username : null; + + context.service.read('currentSlidesEditions.slide', slideId, {timeout: 20 * 1000}, (err, res) => { + + }); + + done(); +} diff --git a/services/currentSlidesEditions.js b/services/currentSlidesEditions.js new file mode 100644 index 000000000..29f010122 --- /dev/null +++ b/services/currentSlidesEditions.js @@ -0,0 +1,26 @@ +import {Microservices} from '../configs/microservices'; +import rp from 'request-promise'; +const log = require('../configs/log').log; + +export default { + name: 'currentSlidesEditions', + + read: (req, resource, slideId, config, callback) => { + + req.reqId = req.reqId ? req.reqId : -1; + log.info({Id: req.reqId, Service: __filename.split('/').pop(), Resource: resource, Operation: 'read', Method: req.method}); + + switch (resource) { + case 'currentSlidesEditions.slide': + rp.get({uri: Microservices.activities.uri + '/slideEdition/slide/' + slideId}).then((res) => { + let slideEditions = JSON.parse(res); + callback(null, {slideEditions: slideEditions}); + }).catch((err) => { + console.log(err); + callback(null, {followings: []}); + }); + break; + } + + } +} From ed4ad2af59a410f7a2563af790d7805bc72af759 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 26 Nov 2018 19:17:22 +0100 Subject: [PATCH 02/23] executing controlSlidesEdition from loadSlideEdit. --- actions/slide/loadSlideEdit.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/actions/slide/loadSlideEdit.js b/actions/slide/loadSlideEdit.js index 7b2cbe0f3..762e0ee0e 100644 --- a/actions/slide/loadSlideEdit.js +++ b/actions/slide/loadSlideEdit.js @@ -3,6 +3,7 @@ import slideIdTypeError from '../error/slideIdTypeError'; import { AllowedPattern } from '../error/util/allowedPattern'; import expandContentPanel from '../deckpagelayout/expandContentPanel'; import serviceUnavailable from '../error/serviceUnavailable'; +import controlSlidesEdition from '../slidesEditions/controlSlideEditions'; const log = require('../log/clog'); import DeckTreeStore from '../../stores/DeckTreeStore'; @@ -21,6 +22,7 @@ export default function loadSlideEdit(context, payload, done) { //expand edit view collapsing TreeNode. Then dispatch LOAD_SLIDE_EDIT_SUCCESS //revert for SWIK-1347 - Slide Edit view to display decktree (and right-hand panel) //context.executeAction(expandContentPanel,{}, () => { + context.executeAction(controlSlidesEdition, payload.params.sid, done); context.dispatch('LOAD_SLIDE_EDIT_SUCCESS', res); //}); From 17778ea46b1a152cdc3c77f6352ba9b3de7d23cc Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Thu, 6 Dec 2018 02:40:58 +0100 Subject: [PATCH 03/23] Refactor and fixes on slideEditions -> slideCurrentlyEdited --- actions/slide/loadSlideEdit.js | 8 ++- .../controlSlideCurrentlyEdited.js | 34 +++++++++++ .../slidesEditions/controlSlideEditions.js | 15 ----- services/currentSlidesEditions.js | 26 --------- services/slidesCurrentlyEdited.js | 56 +++++++++++++++++++ 5 files changed, 96 insertions(+), 43 deletions(-) create mode 100644 actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js delete mode 100644 actions/slidesEditions/controlSlideEditions.js delete mode 100644 services/currentSlidesEditions.js create mode 100644 services/slidesCurrentlyEdited.js diff --git a/actions/slide/loadSlideEdit.js b/actions/slide/loadSlideEdit.js index 762e0ee0e..a997be4d6 100644 --- a/actions/slide/loadSlideEdit.js +++ b/actions/slide/loadSlideEdit.js @@ -3,7 +3,7 @@ import slideIdTypeError from '../error/slideIdTypeError'; import { AllowedPattern } from '../error/util/allowedPattern'; import expandContentPanel from '../deckpagelayout/expandContentPanel'; import serviceUnavailable from '../error/serviceUnavailable'; -import controlSlidesEdition from '../slidesEditions/controlSlideEditions'; +import controlSlideCurrentlyEdited from '../slideCurrentlyEdited/controlSlideCurrentlyEdited'; const log = require('../log/clog'); import DeckTreeStore from '../../stores/DeckTreeStore'; @@ -22,7 +22,11 @@ export default function loadSlideEdit(context, payload, done) { //expand edit view collapsing TreeNode. Then dispatch LOAD_SLIDE_EDIT_SUCCESS //revert for SWIK-1347 - Slide Edit view to display decktree (and right-hand panel) //context.executeAction(expandContentPanel,{}, () => { - context.executeAction(controlSlidesEdition, payload.params.sid, done); + + let payload2 = { + sid: payload.params.sid + }; + context.executeAction(controlSlideCurrentlyEdited, payload2, done); context.dispatch('LOAD_SLIDE_EDIT_SUCCESS', res); //}); diff --git a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js new file mode 100644 index 000000000..396ba44ba --- /dev/null +++ b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js @@ -0,0 +1,34 @@ +import log from '../log/clog'; +import UserProfileStore from '../../stores/UserProfileStore'; + +export default function controlSlidesCurrentlyEdited(context, payload, done) { + + log.info(context); + let user = context.getUser(); + + let sid = payload.sid; + + context.service.read('slidesCurrentlyEdited.slide', payload, {timeout: 20 * 1000}, (err, res) => { + if(err) { + // console.log(err); + } + + let username = user.username ? user.username : null; + let timestamp = new Date().toString(); + + let payload = { + userId: username, + timestamp: timestamp, + slideCurrentlyEdited: sid + }; + + context.service.create('slidesCurrentlyEdited.slide', payload, {timeout: 20 * 1000}, {}, (err2, res2) => { + if (err2) { + // + } + done(); + }); + }); + + done(); +} diff --git a/actions/slidesEditions/controlSlideEditions.js b/actions/slidesEditions/controlSlideEditions.js deleted file mode 100644 index 8deffd321..000000000 --- a/actions/slidesEditions/controlSlideEditions.js +++ /dev/null @@ -1,15 +0,0 @@ -import log from '../log/clog'; - -export default function controlSlideEditions(context, slideId, done) { - - log.info(context); - let user = context.getUser(); - - let username = user.username ? user.username : null; - - context.service.read('currentSlidesEditions.slide', slideId, {timeout: 20 * 1000}, (err, res) => { - - }); - - done(); -} diff --git a/services/currentSlidesEditions.js b/services/currentSlidesEditions.js deleted file mode 100644 index 29f010122..000000000 --- a/services/currentSlidesEditions.js +++ /dev/null @@ -1,26 +0,0 @@ -import {Microservices} from '../configs/microservices'; -import rp from 'request-promise'; -const log = require('../configs/log').log; - -export default { - name: 'currentSlidesEditions', - - read: (req, resource, slideId, config, callback) => { - - req.reqId = req.reqId ? req.reqId : -1; - log.info({Id: req.reqId, Service: __filename.split('/').pop(), Resource: resource, Operation: 'read', Method: req.method}); - - switch (resource) { - case 'currentSlidesEditions.slide': - rp.get({uri: Microservices.activities.uri + '/slideEdition/slide/' + slideId}).then((res) => { - let slideEditions = JSON.parse(res); - callback(null, {slideEditions: slideEditions}); - }).catch((err) => { - console.log(err); - callback(null, {followings: []}); - }); - break; - } - - } -} diff --git a/services/slidesCurrentlyEdited.js b/services/slidesCurrentlyEdited.js new file mode 100644 index 000000000..0fd1ee0d1 --- /dev/null +++ b/services/slidesCurrentlyEdited.js @@ -0,0 +1,56 @@ +import {Microservices} from '../configs/microservices'; +import rp from 'request-promise'; +const log = require('../configs/log').log; + +export default { + name: 'slidesCurrentlyEdited', + + read: (req, resource, payload, config, callback) => { + + req.reqId = req.reqId ? req.reqId : -1; + log.info({Id: req.reqId, Service: __filename.split('/').pop(), Resource: resource, Operation: 'read', Method: req.method}); + + switch (resource) { + + case 'slidesCurrentlyEdited.slide': + + + rp.get({uri: Microservices.activities.uri + '/slideCurrentlyEdited/slide/' + payload.sid}).then((res) => { + let slidesCurrentlyEdited = JSON.parse(res); + callback(null, {slidesCurrentlyEdited: slidesCurrentlyEdited}); + }).catch((err) => { + callback(err, null); + }); + break; + } + + }, + + create: (req, resource, payload, config, emptyObject, callback) => { + req.reqId = req.reqId ? req.reqId : -1; + log.info({Id: req.reqId, Service: __filename.split('/').pop(), Resource: resource, Operation: 'create', Method: req.method}); + + let jwt = payload.jwt; + + delete payload.jwt; + + if (resource === 'slidesCurrentlyEdited.slide') { + + /*********connect to microservices*************/ + rp.post({ + uri: Microservices.activities.uri + '/slideCurrentlyEdited/new', + headers: {'----jwt----': jwt}, + body:JSON.stringify(payload) + }).then((res) => { + // console.log(JSON.parse(res)); + callback(null, {slideCurrentlyEdited: res}); + }).catch((err) => { + // console.log(err); + callback(err, null); + }); + + } + + + } +}; From d5d94723fc1f802d4f6d12582bdd3bf5dcfff854 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Thu, 6 Dec 2018 03:31:08 +0100 Subject: [PATCH 04/23] Adding new slideCurrentlyEdited store --- app.js | 2 ++ stores/SlideCurrentlyEditedStore.js | 45 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 stores/SlideCurrentlyEditedStore.js diff --git a/app.js b/app.js index 99cb387cf..ea47b6d33 100644 --- a/app.js +++ b/app.js @@ -56,6 +56,7 @@ import UserStatsStore from './stores/UserStatsStore'; import UserGroupsStore from './stores/UserGroupsStore'; import GroupStatsStore from './stores/GroupStatsStore'; import DeckStatsStore from './stores/DeckStatsStore'; +import SlideCurrentlyEditedStore from './stores/SlideCurrentlyEditedStore'; // create new fluxible instance & register all stores @@ -116,6 +117,7 @@ const app = new Fluxible({ UserGroupsStore, GroupStatsStore, DeckStatsStore, + SlideCurrentlyEditedStore ] }); diff --git a/stores/SlideCurrentlyEditedStore.js b/stores/SlideCurrentlyEditedStore.js new file mode 100644 index 000000000..acfe824c6 --- /dev/null +++ b/stores/SlideCurrentlyEditedStore.js @@ -0,0 +1,45 @@ +import {BaseStore} from 'fluxible/addons'; + +class SlideCurrentlyEditedStore extends BaseStore { + constructor(dispatcher) { + super(dispatcher); + this.eventId = ''; + this.slideCurrentlyEditedId = ''; + this.usersCurrentlyEditing = []; + } + destructor() { + this.eventId = ''; + this.slideCurrentlyEditedId = ''; + this.usersCurrentlyEditing = []; + } + getState() { + return { + eventId: this.eventId, + slideCurrentlyEditedId: this.slideCurrentlyEditedId, + usersCurrentlyEditing: [] + }; + } + dehydrate() { + return this.getState(); + } + rehydrate(state) { + this.eventId = state.eventId; + this.slideCurrentlyEditedId = state.slideCurrentlyEditedId; + this.usersCurrentlyEditing = state.usersCurrentlyEditing; + } + + getUsersEditingSlide(params) { + this.slideCurrentlyEditedId = params.slideCurrentlyEditedId; + this.usersCurrentlyEditing = params.usersCurrentlyEditing; + this.emitChange(); + } + +} + +SlideCurrentlyEditedStore.storeName = 'SlideCurrentlyEditedStore'; + +SlideCurrentlyEditedStore.handlers = { + 'GET_USERS_EDITING_SLIDE': 'getUsersEditingSlide' +}; + +export default SlideCurrentlyEditedStore; From 8a97a11de37ab31aa9a6b9e6e7d5c2d3aae0cd18 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Thu, 6 Dec 2018 03:31:41 +0100 Subject: [PATCH 05/23] updating store (users editing) when accessing to edit a slide --- .../controlSlideCurrentlyEdited.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js index 396ba44ba..bc37e2cf1 100644 --- a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js +++ b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js @@ -22,6 +22,22 @@ export default function controlSlidesCurrentlyEdited(context, payload, done) { slideCurrentlyEdited: sid }; + let params = { + slideCurrentlyEditedId: sid, + usersCurrentlyEditing: [] + }; + + // take only different users currently editing the slide. + res.slidesCurrentlyEdited = res.slidesCurrentlyEdited.filter((elem) => elem.userId !== username); + res.slidesCurrentlyEdited.forEach((elem) => { + params.usersCurrentlyEditing.push({ + user: elem.userId, + timestamp: elem.timestamp + }); + }); + + context.dispatch('GET_USERS_EDITING_SLIDE', params); + context.service.create('slidesCurrentlyEdited.slide', payload, {timeout: 20 * 1000}, {}, (err2, res2) => { if (err2) { // From 530659cee30d924cbff28c9f428d8f39fe112dad Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Thu, 6 Dec 2018 03:44:11 +0100 Subject: [PATCH 06/23] Getting the event id for future deletion/track --- .../slideCurrentlyEdited/controlSlideCurrentlyEdited.js | 9 +++++++-- stores/SlideCurrentlyEditedStore.js | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js index bc37e2cf1..8656e22ec 100644 --- a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js +++ b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js @@ -26,7 +26,7 @@ export default function controlSlidesCurrentlyEdited(context, payload, done) { slideCurrentlyEditedId: sid, usersCurrentlyEditing: [] }; - + // take only different users currently editing the slide. res.slidesCurrentlyEdited = res.slidesCurrentlyEdited.filter((elem) => elem.userId !== username); res.slidesCurrentlyEdited.forEach((elem) => { @@ -40,8 +40,13 @@ export default function controlSlidesCurrentlyEdited(context, payload, done) { context.service.create('slidesCurrentlyEdited.slide', payload, {timeout: 20 * 1000}, {}, (err2, res2) => { if (err2) { - // + // console.log(err); } + let slideCurrentlyEdited = JSON.parse(res2.slideCurrentlyEdited); + let params = { + eventId: slideCurrentlyEdited.id + }; + context.dispatch('UPDATE_EVENT_ID', params); done(); }); }); diff --git a/stores/SlideCurrentlyEditedStore.js b/stores/SlideCurrentlyEditedStore.js index acfe824c6..5dd1de429 100644 --- a/stores/SlideCurrentlyEditedStore.js +++ b/stores/SlideCurrentlyEditedStore.js @@ -28,6 +28,10 @@ class SlideCurrentlyEditedStore extends BaseStore { this.usersCurrentlyEditing = state.usersCurrentlyEditing; } + updateEventId(params) { + this.eventId = params.eventId; + } + getUsersEditingSlide(params) { this.slideCurrentlyEditedId = params.slideCurrentlyEditedId; this.usersCurrentlyEditing = params.usersCurrentlyEditing; @@ -39,7 +43,9 @@ class SlideCurrentlyEditedStore extends BaseStore { SlideCurrentlyEditedStore.storeName = 'SlideCurrentlyEditedStore'; SlideCurrentlyEditedStore.handlers = { + 'UPDATE_EVENT_ID': 'updateEventId', 'GET_USERS_EDITING_SLIDE': 'getUsersEditingSlide' + }; export default SlideCurrentlyEditedStore; From b4d93ec44a85482613b08b1665464268db502e39 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Thu, 6 Dec 2018 03:44:42 +0100 Subject: [PATCH 07/23] fetching slideCurrentlyEdited service. --- server.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.js b/server.js index 4b5d953cf..e71f965f6 100644 --- a/server.js +++ b/server.js @@ -110,6 +110,8 @@ fetchrPlugin.registerService(require('./services/recommendations')); fetchrPlugin.registerService(require('./services/following')); fetchrPlugin.registerService(require('./services/tags')); fetchrPlugin.registerService(require('./services/stats')); +fetchrPlugin.registerService(require('./services/slidesCurrentlyEdited')); + // ************************** UI Internationalisation routines *************************************** From efdadb091babae2e57d1e3aafebe58b0b238ea43 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 10 Dec 2018 21:06:24 +0100 Subject: [PATCH 08/23] Adding deletion in slidesCurrentlyEdited service. --- services/slidesCurrentlyEdited.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/services/slidesCurrentlyEdited.js b/services/slidesCurrentlyEdited.js index 0fd1ee0d1..66b4e2da4 100644 --- a/services/slidesCurrentlyEdited.js +++ b/services/slidesCurrentlyEdited.js @@ -50,6 +50,31 @@ export default { }); } + } + + delete: (req, resource, payload, config, emptyObject, callback) => { + req.reqId = req.reqId ? req.reqId : -1; + log.info({Id: req.reqId, Service: __filename.split('/').pop(), Resource: resource, Operation: 'create', Method: req.method}); + + let jwt = payload.jwt; + delete payload.jwt; + + if (resource === 'slidesCurrentlyEdited.deleteEvent') { + + /*********connect to microservices*************/ + /*rp.delete({ + uri: Microservices.activities.uri + '/slideCurrentlyEdited/new', + headers: {'----jwt----': jwt}, + body:JSON.stringify(payload) + }).then((res) => { + // console.log(JSON.parse(res)); + callback(null, {slideCurrentlyEdited: res}); + }).catch((err) => { + // console.log(err); + callback(err, null); + }); + */ + } } From 76b51262144ea0709037320203c395b6553a413d Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 17 Dec 2018 18:36:03 +0100 Subject: [PATCH 09/23] Removing slideedition event after cancelling edition without changes --- .../removeCurrentlyEditedSlideEvent.js | 19 +++++++++++++++++++ .../SlideEditPanel/SlideContentEditor.js | 15 ++++++++++----- services/slidesCurrentlyEdited.js | 12 ++++++------ 3 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js diff --git a/actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js b/actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js new file mode 100644 index 000000000..0bfd0ca9c --- /dev/null +++ b/actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js @@ -0,0 +1,19 @@ +import log from '../log/clog'; + +export default function removeCurrentlyEditedSlideEvent(context, payload, done) { + + log.info(context); + + context.service.delete('slidesCurrentlyEdited.deleteEvent', payload, {timeout: 20 * 1000}, (err, res) => { + if (err) { + // console.log(err); + } + + let params = { + eventId: '' + }; + context.dispatch('UPDATE_EVENT_ID', params); + done(); + }); + +} diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js index 645ffe667..31ab52827 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js @@ -7,12 +7,14 @@ import DataSourceStore from '../../../../../stores/DataSourceStore'; import SlideViewStore from '../../../../../stores/SlideViewStore'; import MediaStore from '../../../../../stores/MediaStore'; import PaintModalStore from '../../../../../stores/PaintModalStore'; +import SlideCurrentlyEditedStore from '../../../../../stores/SlideCurrentlyEditedStore'; import saveSlide from '../../../../../actions/slide/saveSlide'; import saveSlideWithDeckTransition from '../../../../../actions/slide/saveSlideWithDeckTransition'; import editImageWithSrc from '../../../../../actions/paint/editImageWithSrc'; import editSVGwithSVG from '../../../../../actions/paint/editSVGwithSVG'; import handleDroppedFile from '../../../../../actions/media/handleDroppedFile'; import contentEditorClick from '../../../../../actions/slide/contentEditorClick'; +import removeCurrentlyEditedSlideEvent from '../../../../../actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent'; //import ResizeAware from 'react-resize-aware'; import {findDOMNode} from 'react-dom'; import UserProfileStore from '../../../../../stores/UserProfileStore'; @@ -895,14 +897,14 @@ class SlideContentEditor extends React.Component { //this.removeEditMode(); $('.pptx2html [style*="absolute"]').find('.cke_widget_drag_handler_container').remove(); $('.pptx2html [style*="absolute"]').find('.widget').remove(); - + let annotations = []; if (CKEDITOR.instances.inlineContent != null) { // get the annotations before CKEditor is destroyed CKEDITOR.instances.inlineContent.plugins.semanticannotations.getAnnotationsToStore(CKEDITOR.instances.inlineContent); annotations = CKEDITOR.instances.inlineContent.plugins.semanticannotations.annotationsToStore; annotations = this.convertAnnotationsToDatabaseStructure(annotations); - + CKEDITOR.instances.inlineContent.destroy(); } if (CKEDITOR.instances.inlineSpeakerNotes != null) { @@ -1960,6 +1962,8 @@ class SlideContentEditor extends React.Component { } else{ + this.context.executeAction(removeCurrentlyEditedSlideEvent, {id: this.props.SlideCurrentlyEditedStore.eventId ? + this.props.SlideCurrentlyEditedStore.eventId : null }); const nodeURL = Util.makeNodeURL(nextProps.SlideEditStore.selector, nextProps.SlideEditStore.selector.page, 'view'); this.context.executeAction(navigateAction, { url: nodeURL @@ -2159,7 +2163,7 @@ class SlideContentEditor extends React.Component { if (nextProps.SlideEditStore.annotateClick === 'true' && nextProps.SlideEditStore.annotateClick !== this.props.SlideEditStore.annotateClick) { CKEDITOR.instances.inlineContent.execCommand('automaticAnnotation'); - + } if (nextProps.SlideEditStore.mathsClick === 'true' && nextProps.SlideEditStore.mathsClick !== this.props.SlideEditStore.mathsClick) { @@ -2860,7 +2864,7 @@ SlideContentEditor.contextTypes = { intl: PropTypes.object.isRequired }; -SlideContentEditor = connectToStores(SlideContentEditor, [SlideEditStore, UserProfileStore, DataSourceStore, SlideViewStore, DeckTreeStore, MediaStore, PaintModalStore], (context, props) => { +SlideContentEditor = connectToStores(SlideContentEditor, [SlideEditStore, UserProfileStore, DataSourceStore, SlideViewStore, DeckTreeStore, MediaStore, PaintModalStore, SlideCurrentlyEditedStore], (context, props) => { return { SlideEditStore: context.getStore(SlideEditStore).getState(), @@ -2869,7 +2873,8 @@ SlideContentEditor = connectToStores(SlideContentEditor, [SlideEditStore, UserPr DataSourceStore: context.getStore(DataSourceStore).getState(), DeckTreeStore: context.getStore(DeckTreeStore).getState(), MediaStore: context.getStore(MediaStore).getState(), - PaintModalStore: context.getStore(PaintModalStore).getState() + PaintModalStore: context.getStore(PaintModalStore).getState(), + SlideCurrentlyEditedStore: context.getStore(SlideCurrentlyEditedStore) }; }); export default SlideContentEditor; diff --git a/services/slidesCurrentlyEdited.js b/services/slidesCurrentlyEdited.js index 66b4e2da4..6a6527e20 100644 --- a/services/slidesCurrentlyEdited.js +++ b/services/slidesCurrentlyEdited.js @@ -50,11 +50,11 @@ export default { }); } - } + }, - delete: (req, resource, payload, config, emptyObject, callback) => { + delete: (req, resource, payload, config, callback) => { req.reqId = req.reqId ? req.reqId : -1; - log.info({Id: req.reqId, Service: __filename.split('/').pop(), Resource: resource, Operation: 'create', Method: req.method}); + log.info({Id: req.reqId, Service: __filename.split('/').pop(), Resource: resource, Operation: 'delete', Method: req.method}); let jwt = payload.jwt; delete payload.jwt; @@ -62,8 +62,8 @@ export default { if (resource === 'slidesCurrentlyEdited.deleteEvent') { /*********connect to microservices*************/ - /*rp.delete({ - uri: Microservices.activities.uri + '/slideCurrentlyEdited/new', + rp.delete({ + uri: Microservices.activities.uri + '/slideCurrentlyEdited/delete', headers: {'----jwt----': jwt}, body:JSON.stringify(payload) }).then((res) => { @@ -73,7 +73,7 @@ export default { // console.log(err); callback(err, null); }); - */ + } From 4de1340657e28d5c2821a5be48b463bf46bff074 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 17 Dec 2018 19:00:13 +0100 Subject: [PATCH 10/23] Deleting edition event when cancelling after changes made and when saving after edition. --- .../removeCurrentlyEditedSlideEvent.js | 2 ++ .../SlideModes/SlideEditPanel/SlideContentEditor.js | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js b/actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js index 0bfd0ca9c..fc126de70 100644 --- a/actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js +++ b/actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js @@ -4,6 +4,8 @@ export default function removeCurrentlyEditedSlideEvent(context, payload, done) log.info(context); + if (payload.id === null) done(); + context.service.delete('slidesCurrentlyEdited.deleteEvent', payload, {timeout: 20 * 1000}, (err, res) => { if (err) { // console.log(err); diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js index 31ab52827..dcb3f7d50 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js @@ -957,8 +957,13 @@ class SlideContentEditor extends React.Component { console.log('SlideContentEditor.ltiResponseHTML='+ltiResponseHTML); */ + // Removing edition event on currently Edited slide. + this.context.executeAction(removeCurrentlyEditedSlideEvent, {id: this.props.SlideCurrentlyEditedStore.eventId ? + this.props.SlideCurrentlyEditedStore.eventId : null }); + //setTimeout(function() { //if (transitionType === 'slide') { + this.context.executeAction(saveSlide, { id: currentSelector.sid, deckID: deckID, @@ -1949,6 +1954,8 @@ class SlideContentEditor extends React.Component { buttonsStyling: false, allowEnterKey: true }).then((accepted) => { + this.context.executeAction(removeCurrentlyEditedSlideEvent, {id: this.props.SlideCurrentlyEditedStore.eventId ? + this.props.SlideCurrentlyEditedStore.eventId : null }); const nodeURL = Util.makeNodeURL(nextProps.SlideEditStore.selector, nextProps.SlideEditStore.selector.page, 'view'); this.context.executeAction(navigateAction, { url: nodeURL From f175036c3ad94fb821a1aeb40a26822ad5a1b433 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Sun, 10 Feb 2019 02:59:37 +0100 Subject: [PATCH 11/23] Creating modal layout --- .../SlideCurrentlyEditedWarningModal.js | 133 ++++++++++++++++++ components/Paint/PaintModal.js | 2 +- 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js new file mode 100644 index 000000000..3dd3136b5 --- /dev/null +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -0,0 +1,133 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import {connectToStores} from 'fluxible-addons-react'; +import FocusTrap from 'focus-trap-react'; +import { Button, Divider, Dropdown, Icon, Input, Modal, Popup, Segment } from 'semantic-ui-react'; +import {defineMessages} from 'react-intl'; + +class SlideCurrentlyEditedWarningModal extends React.Component { + constructor(props) { + super(props); + this.state = { + modalOpen: false, + activeTrap: false, + }; + + // + this.handleOpen = this.handleOpen.bind(this); + this.handleClose = this.handleClose.bind(this); + this.unmountTrap = this.unmountTrap.bind(this); + + + // Messages + this.messages = defineMessages({ + modalTitle: { + id: 'SCEWModal.title', + defaultMessage: 'Warning! Simultaneous Edition' + }, + modalWarning: { + id: 'SCEWModal.warning', + defaultMessage: 'This version of this slide is also currently being edited by other users. The changes ' + + 'you are performing could be overwritten by them. Contact them to avoid troubles with this slide. ' + + 'The users editing this slide are: ' + } + }); + } + + + componentDidMount() { + this.handleOpen(); + } + + handleOpen(){ + $('#app').attr('aria-hidden', 'true'); + this.setState({ + modalOpen:true, + activeTrap:true + }); + } + + handleClose(){ + $('#app').attr('aria-hidden', 'false'); + this.setState({ + modalOpen: false, + activeTrap: false, + }); + } + + unmountTrap() { + if(this.state.activeTrap){ + this.setState({ activeTrap: false }); + $('#app').attr('aria-hidden','false'); + } + } + + handleKeyPress = (event, param) => { + if(event.key === 'Enter'){ + if(param === 'handleOpen') { + this.handleOpen(); + } + } + }; + + render () { + + const headerStyle = { + 'textAlign': 'center' + }; + + let triggerStyle = { + /*display: none; + visibility: hidden;*/ + }; + + return ( + this.handleKeyPress(evt, 'handleOpen')}/> + } + open={this.state.modalOpen} + onOpen={this.handleOpen} + onClose={this.handleClose} + id="slideCurrentlyEditedWarningModal" + aria-labelledby="slideCurrentlyEditedWarningModalHeader" + aria-describedby="slideCurrentlyEditedWarningModalDescription" + tabIndex="0" + > + + +

{this.context.intl.formatMessage(this.messages.modalTitle)}

+
+ +
{this.context.intl.formatMessage(this.messages.modalWarning)}
+
+ + + + +
+
+ ); + } + +} + +SlideCurrentlyEditedWarningModal.contextTypes = { + executeAction: PropTypes.func.isRequired, + intl: PropTypes.object.isRequired, + getUser: PropTypes.func +}; + +export default SlideCurrentlyEditedWarningModal; diff --git a/components/Paint/PaintModal.js b/components/Paint/PaintModal.js index cc2365ee0..46e894448 100644 --- a/components/Paint/PaintModal.js +++ b/components/Paint/PaintModal.js @@ -814,7 +814,7 @@ class PaintModal extends React.Component { this.handleOpen(); } } - } + }; render() { this.context.getUser().username; From af5bc4fe286726b0ba60321424bf8ec759dde488 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 11 Feb 2019 17:48:13 +0100 Subject: [PATCH 12/23] Displaying modal with useful information. --- .../controlSlideCurrentlyEdited.js | 23 +++--- .../SlideEditPanel/SlideContentEditor.js | 2 + .../SlideCurrentlyEditedWarningModal.js | 78 +++++++++++++++++-- stores/SlideCurrentlyEditedStore.js | 3 +- 4 files changed, 87 insertions(+), 19 deletions(-) diff --git a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js index 8656e22ec..3b8b22610 100644 --- a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js +++ b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js @@ -22,6 +22,18 @@ export default function controlSlidesCurrentlyEdited(context, payload, done) { slideCurrentlyEdited: sid }; + context.service.create('slidesCurrentlyEdited.slide', payload, {timeout: 20 * 1000}, {}, (err2, res2) => { + if (err2) { + // console.log(err); + } + let slideCurrentlyEdited = JSON.parse(res2.slideCurrentlyEdited); + let params = { + eventId: slideCurrentlyEdited.id + }; + context.dispatch('UPDATE_EVENT_ID', params); + done(); + }); + let params = { slideCurrentlyEditedId: sid, usersCurrentlyEditing: [] @@ -38,17 +50,6 @@ export default function controlSlidesCurrentlyEdited(context, payload, done) { context.dispatch('GET_USERS_EDITING_SLIDE', params); - context.service.create('slidesCurrentlyEdited.slide', payload, {timeout: 20 * 1000}, {}, (err2, res2) => { - if (err2) { - // console.log(err); - } - let slideCurrentlyEdited = JSON.parse(res2.slideCurrentlyEdited); - let params = { - eventId: slideCurrentlyEdited.id - }; - context.dispatch('UPDATE_EVENT_ID', params); - done(); - }); }); done(); diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js index dcb3f7d50..d0d129137 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js @@ -27,6 +27,7 @@ import Util from '../../../../common/Util'; import {defineMessages} from 'react-intl'; import changeSlideSizeText from '../../../../../actions/slide/changeSlideSizeText'; import registerChange from '../../../../../actions/slide/registerChange'; +import SlideCurrentlyEditedWarningModal from './SlideCurrentlyEditedWarningModal'; let ReactDOM = require('react-dom'); @@ -2801,6 +2802,7 @@ class SlideContentEditor extends React.Component {
{(this.loading === 'loading') ?
Loading
: ''} + {/* - + ); } @@ -130,4 +188,10 @@ SlideCurrentlyEditedWarningModal.contextTypes = { getUser: PropTypes.func }; +SlideCurrentlyEditedWarningModal = connectToStores(SlideCurrentlyEditedWarningModal, [SlideCurrentlyEditedStore], (context, props) => { + return { + SlideCurrentlyEditedStore: context.getStore(SlideCurrentlyEditedStore).getState() + }; +}); + export default SlideCurrentlyEditedWarningModal; diff --git a/stores/SlideCurrentlyEditedStore.js b/stores/SlideCurrentlyEditedStore.js index 5dd1de429..55372417d 100644 --- a/stores/SlideCurrentlyEditedStore.js +++ b/stores/SlideCurrentlyEditedStore.js @@ -16,7 +16,7 @@ class SlideCurrentlyEditedStore extends BaseStore { return { eventId: this.eventId, slideCurrentlyEditedId: this.slideCurrentlyEditedId, - usersCurrentlyEditing: [] + usersCurrentlyEditing: this.usersCurrentlyEditing }; } dehydrate() { @@ -30,6 +30,7 @@ class SlideCurrentlyEditedStore extends BaseStore { updateEventId(params) { this.eventId = params.eventId; + this.emitChange(); } getUsersEditingSlide(params) { From d68d9ca2c08f4d56109b06d5c1bcb0f9c8abd06a Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 11 Feb 2019 18:01:15 +0100 Subject: [PATCH 13/23] Fixing mistake and '}' symbol in cancel button in slide Edition --- .../Deck/ContentPanel/ContentActions/ContentActionsHeader.js | 2 +- .../SlideEditPanel/SlideCurrentlyEditedWarningModal.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/Deck/ContentPanel/ContentActions/ContentActionsHeader.js b/components/Deck/ContentPanel/ContentActions/ContentActionsHeader.js index cf0c0816b..65d4592d6 100644 --- a/components/Deck/ContentPanel/ContentActions/ContentActionsHeader.js +++ b/components/Deck/ContentPanel/ContentActions/ContentActionsHeader.js @@ -291,7 +291,7 @@ class ContentActionsHeader extends React.Component { - {this.context.intl.formatMessage(this.messages.cancelButtonText)}} + {this.context.intl.formatMessage(this.messages.cancelButtonText)} ; } else { saveButton =''; diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index 2f0590f92..d153f802a 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -117,8 +117,8 @@ class SlideCurrentlyEditedWarningModal extends React.Component { }; const triggerStyle = { - display: none; - visibility: hidden; + display: none, + visibility: hidden }; let usersList = this.usersEditing.map((userEditing) => { From 00a16cbde7886d867c2005dab20290d06e930bd4 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 11 Feb 2019 19:00:25 +0100 Subject: [PATCH 14/23] Removing triggerStyle bug. --- .../SlideCurrentlyEditedWarningModal.js | 74 ++++++++++++------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index d153f802a..e4d74d31b 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -116,13 +116,31 @@ class SlideCurrentlyEditedWarningModal extends React.Component { height: '25%' }; - const triggerStyle = { - display: none, - visibility: hidden + const focusTrapStyle = { + padding: '5%' + }; + + const contentStyle = { + paddingLeft: '10%', + paddingRight: '10%' + }; + + const tableStyle = { + width: '100%' + }; + + const tableRowStyle = { + widht: '50%', + textAlign: 'center' + }; + + const actionSectionStyle = { + paddingTop: '5%', + textAlign: 'center' }; let usersList = this.usersEditing.map((userEditing) => { - return + return {userEditing.user} {userEditing.timestamp} ; @@ -134,7 +152,7 @@ class SlideCurrentlyEditedWarningModal extends React.Component { this.handleKeyPress(evt, 'handleOpen')}>hola k aseeee
+
this.handleKeyPress(evt, 'handleOpen')}/> } open={this.state.modalOpen} onOpen={this.handleOpen} @@ -154,26 +172,32 @@ class SlideCurrentlyEditedWarningModal extends React.Component { initialFocus: '#slideCurrentlyEditedWarningModalDescription' }} > - -

{this.context.intl.formatMessage(this.messages.modalTitle)}

-
- -
{this.context.intl.formatMessage(this.messages.modalWarning)}
-
- - - - - - {usersList} -
{this.context.intl.formatMessage(this.messages.users)}{this.context.intl.formatMessage(this.messages.editingSince)}
-
- - - +
+ +

{this.context.intl.formatMessage(this.messages.modalTitle)}

+
+ +
+
{this.context.intl.formatMessage(this.messages.modalWarning)}
+
+ + + + + + {usersList} +
{this.context.intl.formatMessage(this.messages.users)}{this.context.intl.formatMessage(this.messages.editingSince)}
+
+
+ +
+ +
+
+
From 895a72fbbb9340a378572a693dc95b47ae9ce26b Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 11 Feb 2019 21:10:05 +0100 Subject: [PATCH 15/23] Formatting timestamp output for the warning. --- .../SlideCurrentlyEditedWarningModal.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index e4d74d31b..7a2ed95a6 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -140,9 +140,19 @@ class SlideCurrentlyEditedWarningModal extends React.Component { }; let usersList = this.usersEditing.map((userEditing) => { + let date = new Date(userEditing.timestamp); + let year = date.getFullYear(); + let month = date.getMonth(); + let day = date.getDate(); + let hour = date.getHours(); + let minutes = date.getMinutes(); + + let dateStr = day + '-' + (month < 10 ? '0' + month : month) + '-' + year + ' ' + hour + ':' + minutes; + + console.log(dateStr); return {userEditing.user} - {userEditing.timestamp} + {dateStr} ; }); From 073b23f36e9f9e7436801e105933c61343a90cfd Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 11 Feb 2019 21:29:53 +0100 Subject: [PATCH 16/23] Removing event from db when edition is omitted without cancel / ie navlink --- .../SlideModes/SlideEditPanel/SlideContentEditor.js | 4 ++++ .../SlideEditPanel/SlideCurrentlyEditedWarningModal.js | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js index d0d129137..a1423d757 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js @@ -2660,6 +2660,10 @@ class SlideContentEditor extends React.Component { //console.log('destroy CKEDITOR instance'); CKEDITOR.instances.inlineSpeakerNotes.destroy(); } + + // Remove edition event on slideCurrentlyEdited in case that the edition is not cancelled or saved. + this.context.executeAction(removeCurrentlyEditedSlideEvent, {id: this.props.SlideCurrentlyEditedStore.eventId ? + this.props.SlideCurrentlyEditedStore.eventId : null }); } emitChange(context){ diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index 7a2ed95a6..9e40a40b3 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -149,7 +149,6 @@ class SlideCurrentlyEditedWarningModal extends React.Component { let dateStr = day + '-' + (month < 10 ? '0' + month : month) + '-' + year + ' ' + hour + ':' + minutes; - console.log(dateStr); return {userEditing.user} {dateStr} From 597b4b2e5a394519b371d4c8b6ad09cada494de7 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Mon, 11 Feb 2019 23:18:17 +0100 Subject: [PATCH 17/23] Adding link to the users currently editing --- .../SlideCurrentlyEditedWarningModal.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index 9e40a40b3..510f03e6b 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -55,13 +55,6 @@ class SlideCurrentlyEditedWarningModal extends React.Component { }); } -/* - - componentDidMount() { - this.handleOpen(); - } -*/ - handleOpen(){ $('#app').attr('aria-hidden', 'true'); this.setState({ @@ -75,7 +68,6 @@ class SlideCurrentlyEditedWarningModal extends React.Component { this.setState({ modalOpen: false, activeTrap: false, - usersEditing: [] }); } @@ -150,7 +142,11 @@ class SlideCurrentlyEditedWarningModal extends React.Component { let dateStr = day + '-' + (month < 10 ? '0' + month : month) + '-' + year + ' ' + hour + ':' + minutes; return - {userEditing.user} + + + {userEditing.user} + + {dateStr} ; }); From 80b3f5fbfe767ae1f239cbcb34ba16e567ed5ee9 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Tue, 12 Feb 2019 00:18:22 +0100 Subject: [PATCH 18/23] Added deletion of the users editing list in the store to avoid bug of opening the warning modal when it shouldn't --- .../slideCurrentlyEdited/forgetUsersEditing.js | 12 ++++++++++++ .../SlideCurrentlyEditedWarningModal.js | 15 +++++++++++---- stores/SlideCurrentlyEditedStore.js | 8 ++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 actions/slideCurrentlyEdited/forgetUsersEditing.js diff --git a/actions/slideCurrentlyEdited/forgetUsersEditing.js b/actions/slideCurrentlyEdited/forgetUsersEditing.js new file mode 100644 index 000000000..3dbb99033 --- /dev/null +++ b/actions/slideCurrentlyEdited/forgetUsersEditing.js @@ -0,0 +1,12 @@ +import log from '../log/clog'; + +export default function forgetUsersEditing(context, payload, done) { + + log.info(context); + + if (payload !== {}) done(); + + context.dispatch('DELETE_USERS_EDITING_LIST'); + done(); + +} diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index 510f03e6b..40fe0bf4e 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -5,6 +5,7 @@ import FocusTrap from 'focus-trap-react'; import { Button, Divider, Dropdown, Icon, Input, Modal, Popup, Segment } from 'semantic-ui-react'; import {defineMessages} from 'react-intl'; import SlideCurrentlyEditedStore from '../../../../../stores/SlideCurrentlyEditedStore'; +import forgetUsersEditing from '../../../../../actions/slideCurrentlyEdited/forgetUsersEditing'; class SlideCurrentlyEditedWarningModal extends React.Component { constructor(props) { @@ -57,10 +58,13 @@ class SlideCurrentlyEditedWarningModal extends React.Component { handleOpen(){ $('#app').attr('aria-hidden', 'true'); - this.setState({ - modalOpen:true, - activeTrap:true - }); + + if (this.usersEditing.length > 0) { + this.setState({ + modalOpen:true, + activeTrap:true + }); + } } handleClose(){ @@ -69,6 +73,9 @@ class SlideCurrentlyEditedWarningModal extends React.Component { modalOpen: false, activeTrap: false, }); + this.usersEditing = []; + + this.context.executeAction(forgetUsersEditing, {}); } unmountTrap() { diff --git a/stores/SlideCurrentlyEditedStore.js b/stores/SlideCurrentlyEditedStore.js index 55372417d..77a85fcaa 100644 --- a/stores/SlideCurrentlyEditedStore.js +++ b/stores/SlideCurrentlyEditedStore.js @@ -39,14 +39,18 @@ class SlideCurrentlyEditedStore extends BaseStore { this.emitChange(); } + deleteUsersList() { + this.usersCurrentlyEditing = []; + } + } SlideCurrentlyEditedStore.storeName = 'SlideCurrentlyEditedStore'; SlideCurrentlyEditedStore.handlers = { 'UPDATE_EVENT_ID': 'updateEventId', - 'GET_USERS_EDITING_SLIDE': 'getUsersEditingSlide' - + 'GET_USERS_EDITING_SLIDE': 'getUsersEditingSlide', + 'DELETE_USERS_EDITING_LIST': 'deleteUsersList' }; export default SlideCurrentlyEditedStore; From 117c9168ddbb99963a1c2e96f964e9afc29a59c1 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Wed, 13 Feb 2019 17:24:50 +0100 Subject: [PATCH 19/23] Adding note and changing icon on button. --- .../SlideCurrentlyEditedWarningModal.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index 40fe0bf4e..5d3aa6b37 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -51,7 +51,7 @@ class SlideCurrentlyEditedWarningModal extends React.Component { id: 'SCEWModal.note', defaultMessage: 'Note: we recommend you to cancel the edition of this slide to not overwrite the changes ' + 'performed by your colleagues. If they confirm you that they are not editing this slide anymore you can ' + - 'continue editing it.' + ' continue editing it.' } }); } @@ -115,6 +115,12 @@ class SlideCurrentlyEditedWarningModal extends React.Component { height: '25%' }; + const modalNoteStyle = { + paddingLeft: '10%', + paddingRight: '10%', + paddingTop: '20px' + } + const focusTrapStyle = { padding: '5%' }; @@ -164,7 +170,7 @@ class SlideCurrentlyEditedWarningModal extends React.Component { this.handleKeyPress(evt, 'handleOpen')}/> +
this.handleKeyPress(evt, 'handleOpen')}/> } open={this.state.modalOpen} onOpen={this.handleOpen} @@ -199,12 +205,13 @@ class SlideCurrentlyEditedWarningModal extends React.Component { {usersList} +
{this.context.intl.formatMessage(this.messages.note)}
From c91f3d3241ce5d2ccf1c6f741b9ed99096cd6a41 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Wed, 13 Feb 2019 17:40:51 +0100 Subject: [PATCH 20/23] Fixing padding on note --- .../SlideEditPanel/SlideCurrentlyEditedWarningModal.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index 5d3aa6b37..c7aa80766 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -116,8 +116,6 @@ class SlideCurrentlyEditedWarningModal extends React.Component { }; const modalNoteStyle = { - paddingLeft: '10%', - paddingRight: '10%', paddingTop: '20px' } From 3ada7b63ffb6701fc190061a8bdcf688ec3e991f Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Thu, 14 Feb 2019 21:23:20 +0100 Subject: [PATCH 21/23] Fix on lint error. --- .../SlideEditPanel/SlideCurrentlyEditedWarningModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index c7aa80766..376e32e49 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -117,7 +117,7 @@ class SlideCurrentlyEditedWarningModal extends React.Component { const modalNoteStyle = { paddingTop: '20px' - } + }; const focusTrapStyle = { padding: '5%' From 5dc2273baa083bb3bc0a57294faeef74197d9c4f Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Fri, 22 Feb 2019 14:55:43 +0100 Subject: [PATCH 22/23] Sending jwt token correctly and removing userid from payload. --- .../slideCurrentlyEdited/controlSlideCurrentlyEdited.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js index 3b8b22610..41b98a8d5 100644 --- a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js +++ b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js @@ -8,18 +8,19 @@ export default function controlSlidesCurrentlyEdited(context, payload, done) { let sid = payload.sid; + let jwt = payload.jwt = context.getStore(UserProfileStore).jwt; + context.service.read('slidesCurrentlyEdited.slide', payload, {timeout: 20 * 1000}, (err, res) => { if(err) { // console.log(err); } - let username = user.username ? user.username : null; let timestamp = new Date().toString(); let payload = { - userId: username, timestamp: timestamp, - slideCurrentlyEdited: sid + slideCurrentlyEdited: sid, + jwt: jwt }; context.service.create('slidesCurrentlyEdited.slide', payload, {timeout: 20 * 1000}, {}, (err2, res2) => { @@ -39,6 +40,8 @@ export default function controlSlidesCurrentlyEdited(context, payload, done) { usersCurrentlyEditing: [] }; + let username = user.username ? user.username : null; + // take only different users currently editing the slide. res.slidesCurrentlyEdited = res.slidesCurrentlyEdited.filter((elem) => elem.userId !== username); res.slidesCurrentlyEdited.forEach((elem) => { From be753cb5f3fb7ccff85507e841197d73fe8d8a68 Mon Sep 17 00:00:00 2001 From: Luis Fernandes Date: Fri, 22 Feb 2019 15:29:46 +0100 Subject: [PATCH 23/23] Refactoring table format and userid -> username --- .../controlSlideCurrentlyEdited.js | 4 ++-- .../SlideCurrentlyEditedWarningModal.js | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js index 41b98a8d5..9044e7027 100644 --- a/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js +++ b/actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js @@ -43,10 +43,10 @@ export default function controlSlidesCurrentlyEdited(context, payload, done) { let username = user.username ? user.username : null; // take only different users currently editing the slide. - res.slidesCurrentlyEdited = res.slidesCurrentlyEdited.filter((elem) => elem.userId !== username); + res.slidesCurrentlyEdited = res.slidesCurrentlyEdited.filter((elem) => elem.username !== username); res.slidesCurrentlyEdited.forEach((elem) => { params.usersCurrentlyEditing.push({ - user: elem.userId, + user: elem.username, timestamp: elem.timestamp }); }); diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js index 376e32e49..af33fbf34 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideCurrentlyEditedWarningModal.js @@ -197,11 +197,13 @@ class SlideCurrentlyEditedWarningModal extends React.Component {
{this.context.intl.formatMessage(this.messages.modalWarning)}

- - - - - {usersList} + + + + + + {usersList} +
{this.context.intl.formatMessage(this.messages.users)}{this.context.intl.formatMessage(this.messages.editingSince)}
{this.context.intl.formatMessage(this.messages.users)}{this.context.intl.formatMessage(this.messages.editingSince)}
{this.context.intl.formatMessage(this.messages.note)}