[DE] Fix new track changes

This commit is contained in:
Julia Radzhabova 2021-02-27 12:43:32 +03:00
parent 526732cc53
commit c3b0f9c2b6
2 changed files with 50 additions and 30 deletions

View file

@ -562,23 +562,26 @@ define([
this.view.turnChanges(true); this.view.turnChanges(true);
} else } else
if ( this.appConfig.canReview ) { if ( this.appConfig.canReview ) {
var saveToFile = !!global; // save track changes flag (state) to file if (!!global) {
if (saveToFile) {
this.api.asc_SetLocalTrackRevisions(null); this.api.asc_SetLocalTrackRevisions(null);
this.api.asc_SetGlobalTrackRevisions(!!state); this.api.asc_SetGlobalTrackRevisions(!!state);
} else } else
this.api.asc_SetLocalTrackRevisions(!!state); this.api.asc_SetLocalTrackRevisions(!!state);
Common.Utils.InternalSettings.set(this.view.appPrefix + "track-changes", (state ? 0 : 1) + (global ? 2 : 0));
this.view.turnChanges(state, global);
} }
}, },
onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) { // use userId only for globalFlag onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) {
// change global state if ( this.appConfig.isReviewOnly ) {
if (userId) { this.view.turnChanges(true);
this.showTips(Common.Utils.String.format(globalFlag ? this.textOnGlobal : this.textOffGlobal, this.getUserName(userId))); } else
if (Common.Utils.InternalSettings.get(this.view.appPrefix + "track-changes")>1) { if ( this.appConfig.canReview ) {
Common.NotificationCenter.trigger('reviewchanges:turn', globalFlag, true, true); var global = (localFlag===null),
state = global ? globalFlag : localFlag;
Common.Utils.InternalSettings.set(this.view.appPrefix + "track-changes", (state ? 0 : 1) + (global ? 2 : 0));
this.view.turnChanges(state, global);
if (userId && this.userCollection) {
var rec = this.userCollection.findOriginalUser(userId);
rec && this.showTips(Common.Utils.String.format(globalFlag ? this.textOnGlobal : this.textOffGlobal, Common.Utils.UserInfoParser.getParsedName(rec.get('username'))));
} }
} }
}, },
@ -778,18 +781,20 @@ define([
(new Promise(function (resolve) { (new Promise(function (resolve) {
resolve(); resolve();
})).then(function () { })).then(function () {
function _setReviewStatus(state, global) { // function _setReviewStatus(state, global) {
me.view.turnChanges(state, global); // me.view.turnChanges(state, global);
!global && me.api.asc_SetLocalTrackRevisions(state); // !global && me.api.asc_SetLocalTrackRevisions(state);
Common.Utils.InternalSettings.set(me.view.appPrefix + "track-changes", (state ? 0 : 1) + (global ? 2 : 0)); // Common.Utils.InternalSettings.set(me.view.appPrefix + "track-changes", (state ? 0 : 1) + (global ? 2 : 0));
}; // };
var trackChanges = typeof (me.appConfig.customization) == 'object' ? me.appConfig.customization.trackChanges : undefined,
state = config.isReviewOnly || trackChanges===true || (trackChanges!==false) && me.api.asc_IsTrackRevisions(),
global = !config.isReviewOnly && (trackChanges===undefined);
var trackChanges = typeof (me.appConfig.customization) == 'object' ? me.appConfig.customization.trackChanges : undefined;
if (config.isReviewOnly || trackChanges!==undefined)
me.api.asc_SetLocalTrackRevisions(config.isReviewOnly || trackChanges===true);
else
me.onApiTrackRevisionsChange(me.api.asc_GetLocalTrackRevisions(), me.api.asc_GetGlobalTrackRevisions());
me.api.asc_HaveRevisionsChanges() && me.view.markChanges(true); me.api.asc_HaveRevisionsChanges() && me.view.markChanges(true);
_setReviewStatus(state, global);
// _setReviewStatus(state, global);
if ( typeof (me.appConfig.customization) == 'object' && (me.appConfig.customization.showReviewChanges==true) ) { if ( typeof (me.appConfig.customization) == 'object' && (me.appConfig.customization.showReviewChanges==true) ) {
me.dlgChanges = (new Common.Views.ReviewChangesDialog({ me.dlgChanges = (new Common.Views.ReviewChangesDialog({

View file

@ -70,7 +70,7 @@ define([
Common.localStorage.setBool('de-hidden-status', status); Common.localStorage.setBool('de-hidden-status', status);
Common.NotificationCenter.trigger('layout:changed', 'status'); Common.NotificationCenter.trigger('layout:changed', 'status');
Common.NotificationCenter.trigger('edit:complete', this.statusbar); Common.NotificationCenter.trigger('edit:complete', me.statusbar);
} }
} }
}); });
@ -117,7 +117,6 @@ define([
}); });
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me)); Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me));
Common.NotificationCenter.on('reviewchanges:turn', me.onTurnPreview.bind(me));
}, },
onAppReady: function (config) { onAppReady: function (config) {
@ -137,6 +136,7 @@ define([
if (me.changesTooltip === undefined) if (me.changesTooltip === undefined)
me.changesTooltip = me.createChangesTip(me.textTrackChanges, 'de-track-changes-tip'); me.changesTooltip = me.createChangesTip(me.textTrackChanges, 'de-track-changes-tip');
me.hideTips();
me.changesTooltip.show(); me.changesTooltip.show();
} else { } else {
me.btnTurnReview.updateHint(me.tipReview); me.btnTurnReview.updateHint(me.tipReview);
@ -155,6 +155,7 @@ define([
if (me.newChangesTooltip === undefined) if (me.newChangesTooltip === undefined)
me.newChangesTooltip = me.createChangesTip(me.textHasChanges, 'de-new-changes'); me.newChangesTooltip = me.createChangesTip(me.textHasChanges, 'de-new-changes');
me.hideTips();
me.newChangesTooltip.show(); me.newChangesTooltip.show();
} else } else
me.btnTurnReview.updateHint(me.tipReview); me.btnTurnReview.updateHint(me.tipReview);
@ -163,14 +164,21 @@ define([
}); });
}, },
onTurnPreview: function(state, global, fromApi) { onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) {
if (!state && this.changesTooltip && this.changesTooltip.isVisible()) { var global = (localFlag===null),
this.changesTooltip.hide(); state = global ? globalFlag : localFlag;
this.btnTurnReview.updateHint(this.tipReview); if (this.btnTurnReview) {
} else if (fromApi && state && global ) { if (!state) {
if (this.globalChangesTooltip === undefined) this.hideTips();
this.globalChangesTooltip = this.createChangesTip(this.textSetTrackChanges); this.btnTurnReview.updateHint(this.tipReview);
!this.globalChangesTooltip.isVisible() && this.globalChangesTooltip.show(); } else if (userId && state && global ) {
if (this.globalChangesTooltip === undefined)
this.globalChangesTooltip = this.createChangesTip(this.textSetTrackChanges);
if (!this.globalChangesTooltip.isVisible()) {
this.hideTips();
this.globalChangesTooltip.show();
}
}
} }
}, },
@ -178,6 +186,7 @@ define([
this.api = api; this.api = api;
this.api.asc_registerCallback('asc_onZoomChange', _.bind(this._onZoomChange, this)); this.api.asc_registerCallback('asc_onZoomChange', _.bind(this._onZoomChange, this));
this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this._onTextLanguage, this)); this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this._onTextLanguage, this));
this.api.asc_registerCallback('asc_onOnTrackRevisionsChange', _.bind(this.onApiTrackRevisionsChange, this));
this.statusbar.setApi(api); this.statusbar.setApi(api);
}, },
@ -257,6 +266,12 @@ define([
this.setStatusCaption(''); this.setStatusCaption('');
}, },
hideTips: function () {
this.changesTooltip && this.changesTooltip.isVisible() && this.changesTooltip.hide();
this.newChangesTooltip && this.newChangesTooltip.isVisible() && this.newChangesTooltip.hide();
this.globalChangesTooltip && this.globalChangesTooltip.isVisible() && this.globalChangesTooltip.hide();
},
createChangesTip: function (text, storage) { createChangesTip: function (text, storage) {
var me = this; var me = this;
var tip = new Common.UI.SynchronizeTip({ var tip = new Common.UI.SynchronizeTip({