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

Swik 1944 warning of simultaneous slide editing #1151

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b322204
Adding action and service to handle edition control on slides.
sednanref Nov 26, 2018
ed4ad2a
executing controlSlidesEdition from loadSlideEdit.
sednanref Nov 26, 2018
17778ea
Refactor and fixes on slideEditions -> slideCurrentlyEdited
sednanref Dec 6, 2018
d5d9472
Adding new slideCurrentlyEdited store
sednanref Dec 6, 2018
8a97a11
updating store (users editing) when accessing to edit a slide
sednanref Dec 6, 2018
530659c
Getting the event id for future deletion/track
sednanref Dec 6, 2018
b4d93ec
fetching slideCurrentlyEdited service.
sednanref Dec 6, 2018
efdadb0
Adding deletion in slidesCurrentlyEdited service.
sednanref Dec 10, 2018
f804026
Merge branch 'master' into SWIK-1944-warning-of-simultaneous-slide-ed…
sednanref Dec 17, 2018
76b5126
Removing slideedition event after cancelling edition without changes
sednanref Dec 17, 2018
4de1340
Deleting edition event when cancelling after changes made and when sa…
sednanref Dec 17, 2018
f175036
Creating modal layout
sednanref Feb 10, 2019
ee6a7ff
Merge branch 'master' into SWIK-1944-warning-of-simultaneous-slide-ed…
sednanref Feb 10, 2019
af5bc4f
Displaying modal with useful information.
sednanref Feb 11, 2019
d68d9ca
Fixing mistake and '}' symbol in cancel button in slide Edition
sednanref Feb 11, 2019
00a16cb
Removing triggerStyle bug.
sednanref Feb 11, 2019
895a72f
Formatting timestamp output for the warning.
sednanref Feb 11, 2019
073b23f
Removing event from db when edition is omitted without cancel / ie na…
sednanref Feb 11, 2019
597b4b2
Adding link to the users currently editing
sednanref Feb 11, 2019
80b3f5f
Added deletion of the users editing list in the store to avoid bug of…
sednanref Feb 11, 2019
117c916
Adding note and changing icon on button.
sednanref Feb 13, 2019
c91f3d3
Fixing padding on note
sednanref Feb 13, 2019
3ada7b6
Fix on lint error.
sednanref Feb 14, 2019
5cd1722
Merge branch 'master' into SWIK-1944-warning-of-simultaneous-slide-ed…
sednanref Feb 15, 2019
5dc2273
Sending jwt token correctly and removing userid from payload.
sednanref Feb 22, 2019
be753cb
Refactoring table format and userid -> username
sednanref Feb 22, 2019
1dd3093
Merge branch 'inclusiveOCW' into SWIK-1944-warning-of-simultaneous-sl…
sednanref Feb 25, 2019
a97bc43
Merge branch 'master' into SWIK-1944-warning-of-simultaneous-slide-ed…
kprist Feb 26, 2019
cddfc0d
Merge branch 'master' into SWIK-1944-warning-of-simultaneous-slide-ed…
sednanref Mar 27, 2019
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
6 changes: 6 additions & 0 deletions actions/slide/loadSlideEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 controlSlideCurrentlyEdited from '../slideCurrentlyEdited/controlSlideCurrentlyEdited';
const log = require('../log/clog');
import DeckTreeStore from '../../stores/DeckTreeStore';

Expand All @@ -21,6 +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,{}, () => {

let payload2 = {
sid: payload.params.sid
};
context.executeAction(controlSlideCurrentlyEdited, payload2, done);
context.dispatch('LOAD_SLIDE_EDIT_SUCCESS', res);
//});

Expand Down
59 changes: 59 additions & 0 deletions actions/slideCurrentlyEdited/controlSlideCurrentlyEdited.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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;

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 timestamp = new Date().toString();

let payload = {
timestamp: timestamp,
slideCurrentlyEdited: sid,
jwt: jwt
};

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: []
};

let username = user.username ? user.username : null;

// take only different users currently editing the slide.
res.slidesCurrentlyEdited = res.slidesCurrentlyEdited.filter((elem) => elem.username !== username);
res.slidesCurrentlyEdited.forEach((elem) => {
params.usersCurrentlyEditing.push({
user: elem.username,
timestamp: elem.timestamp
});
});

context.dispatch('GET_USERS_EDITING_SLIDE', params);

});

done();
}
12 changes: 12 additions & 0 deletions actions/slideCurrentlyEdited/forgetUsersEditing.js
Original file line number Diff line number Diff line change
@@ -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();

}
21 changes: 21 additions & 0 deletions actions/slideCurrentlyEdited/removeCurrentlyEditedSlideEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import log from '../log/clog';

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);
}

let params = {
eventId: ''
};
context.dispatch('UPDATE_EVENT_ID', params);
done();
});

}
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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
Expand Down Expand Up @@ -118,6 +119,7 @@ const app = new Fluxible({
UserGroupsStore,
GroupStatsStore,
DeckStatsStore,
SlideCurrentlyEditedStore
]
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -25,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');

Expand Down Expand Up @@ -895,14 +898,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) {
Expand Down Expand Up @@ -955,8 +958,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,
Expand Down Expand Up @@ -1947,6 +1955,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
Expand All @@ -1960,6 +1970,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
Expand Down Expand Up @@ -2159,7 +2171,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)
{
Expand Down Expand Up @@ -2648,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){
Expand Down Expand Up @@ -2790,6 +2806,7 @@ class SlideContentEditor extends React.Component {
<div ref='container' id='container'>
{(this.loading === 'loading') ? <div className="ui active dimmer"><div className="ui text loader">Loading</div></div> : ''}
<UploadMediaModal ref="uploadMediaModal" userFullName={this.props.UserProfileStore.user.fname + ' ' + this.props.UserProfileStore.user.lname + ' (username: ' + this.props.UserProfileStore.username + ')'}/>
<SlideCurrentlyEditedWarningModal/>
{/*
<button tabIndex="0" ref="submitbutton" className="ui button blue primary " onClick={this.handleSaveButton.bind(this)} onChange={this.handleSaveButton.bind(this)}>
<i className="save icon large"></i>
Expand Down Expand Up @@ -2860,7 +2877,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(),
Expand All @@ -2869,7 +2886,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;
Loading