[DE] Use new methods for review display

This commit is contained in:
Julia Radzhabova 2021-08-10 19:32:12 +03:00
parent 2954b9ded5
commit a9c32f368e
2 changed files with 48 additions and 31 deletions

View file

@ -131,8 +131,7 @@ define([
this.api.asc_registerCallback('asc_onUpdateRevisionsChangesPosition', _.bind(this.onApiUpdateChangePosition, this)); this.api.asc_registerCallback('asc_onUpdateRevisionsChangesPosition', _.bind(this.onApiUpdateChangePosition, this));
this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onAuthParticipantsChanged, this)); this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onAuthParticipantsChanged, this));
this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onAuthParticipantsChanged, this)); this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onAuthParticipantsChanged, this));
this.api.asc_registerCallback('asc_onBeginViewModeInReview', _.bind(this.onBeginViewModeInReview, this)); this.api.asc_registerCallback('asc_onChangeDisplayModeInReview', _.bind(this.onChangeDisplayModeInReview, this));
this.api.asc_registerCallback('asc_onEndViewModeInReview', _.bind(this.onEndViewModeInReview, this));
} }
if (this.appConfig.canReview) if (this.appConfig.canReview)
this.api.asc_registerCallback('asc_onOnTrackRevisionsChange', _.bind(this.onApiTrackRevisionsChange, this)); this.api.asc_registerCallback('asc_onOnTrackRevisionsChange', _.bind(this.onApiTrackRevisionsChange, this));
@ -688,27 +687,40 @@ define([
turnDisplayMode: function(mode) { turnDisplayMode: function(mode) {
if (this.api) { if (this.api) {
if (mode === 'final') var type = Asc.c_oAscDisplayModeInReview.Edit;
this.api.asc_BeginViewModeInReview(true); switch (mode) {
else if (mode === 'original') case 'final':
this.api.asc_BeginViewModeInReview(false); type = Asc.c_oAscDisplayModeInReview.Final;
else break;
this.api.asc_EndViewModeInReview(mode=='simple'); case 'original':
type = Asc.c_oAscDisplayModeInReview.Original;
break;
case 'simple':
type = Asc.c_oAscDisplayModeInReview.Simple;
break;
}
this.api.asc_SetDisplayModeInReview(type);
} }
this.disableEditing(mode == 'final' || mode == 'original'); this.disableEditing(mode == 'final' || mode == 'original');
this._state.previewMode = (mode == 'final' || mode == 'original'); this._state.previewMode = (mode == 'final' || mode == 'original');
}, },
onBeginViewModeInReview: function(mode) { onChangeDisplayModeInReview: function(type) {
this.disableEditing(true); this.disableEditing(type===Asc.c_oAscDisplayModeInReview.Final || type===Asc.c_oAscDisplayModeInReview.Original);
this.view && this.view.turnDisplayMode(mode ? 'final' : 'original'); var mode = 'markup';
this._state.previewMode = true; switch (type) {
}, case Asc.c_oAscDisplayModeInReview.Final:
mode = 'final';
onEndViewModeInReview: function(mode) { break;
this.disableEditing(false); case Asc.c_oAscDisplayModeInReview.Original:
this.view && this.view.turnDisplayMode(mode ? 'simple' : 'markup'); mode = 'original';
this._state.previewMode = false; break;
case Asc.c_oAscDisplayModeInReview.Simple:
mode = 'simple';
break;
}
this.view && this.view.turnDisplayMode(mode);
this._state.previewMode = (type===Asc.c_oAscDisplayModeInReview.Final || type===Asc.c_oAscDisplayModeInReview.Original);
}, },
isPreviewChangesMode: function() { isPreviewChangesMode: function() {

View file

@ -31,14 +31,16 @@ class InitReview extends Component {
if (viewReviewMode === null) if (viewReviewMode === null)
viewReviewMode = appOptions.customization && /^(original|final|markup|simple)$/i.test(appOptions.customization.reviewDisplay) ? appOptions.customization.reviewDisplay.toLocaleLowerCase() : ( appOptions.isEdit || appOptions.isRestrictedEdit ? 'markup' : 'original'); viewReviewMode = appOptions.customization && /^(original|final|markup|simple)$/i.test(appOptions.customization.reviewDisplay) ? appOptions.customization.reviewDisplay.toLocaleLowerCase() : ( appOptions.isEdit || appOptions.isRestrictedEdit ? 'markup' : 'original');
let displayMode = viewReviewMode.toLocaleLowerCase(); let displayMode = viewReviewMode.toLocaleLowerCase();
if (displayMode === 'final') { let type = Asc.c_oAscDisplayModeInReview.Edit;
api.asc_BeginViewModeInReview(true); switch (displayMode) {
} else if (displayMode === 'original') { case 'final':
api.asc_BeginViewModeInReview(false); type = Asc.c_oAscDisplayModeInReview.Final;
} else { break;
(displayMode === 'simple') && (displayMode = 'markup'); case 'original':
api.asc_EndViewModeInReview(); type = Asc.c_oAscDisplayModeInReview.Original;
break;
} }
api.asc_SetDisplayModeInReview(type);
props.storeReview.changeDisplayMode(displayMode); props.storeReview.changeDisplayMode(displayMode);
} }
}); });
@ -95,13 +97,16 @@ class Review extends Component {
onDisplayMode (mode) { onDisplayMode (mode) {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
if (mode === 'final') { let type = Asc.c_oAscDisplayModeInReview.Edit;
api.asc_BeginViewModeInReview(true); switch (mode) {
} else if (mode === 'original') { case 'final':
api.asc_BeginViewModeInReview(false); type = Asc.c_oAscDisplayModeInReview.Final;
} else { break;
api.asc_EndViewModeInReview(); case 'original':
type = Asc.c_oAscDisplayModeInReview.Original;
break;
} }
api.asc_SetDisplayModeInReview(type);
!this.appConfig.isEdit && !this.appConfig.isRestrictedEdit && LocalStorage.setItem("de-view-review-mode", mode); !this.appConfig.isEdit && !this.appConfig.isRestrictedEdit && LocalStorage.setItem("de-view-review-mode", mode);
this.props.storeReview.changeDisplayMode(mode); this.props.storeReview.changeDisplayMode(mode);
} }