diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 3344e7f2a..b452d3ba2 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -562,23 +562,26 @@ define([ this.view.turnChanges(true); } else if ( this.appConfig.canReview ) { - var saveToFile = !!global; // save track changes flag (state) to file - if (saveToFile) { + if (!!global) { this.api.asc_SetLocalTrackRevisions(null); this.api.asc_SetGlobalTrackRevisions(!!state); } else 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 - // change global state - if (userId) { - this.showTips(Common.Utils.String.format(globalFlag ? this.textOnGlobal : this.textOffGlobal, this.getUserName(userId))); - if (Common.Utils.InternalSettings.get(this.view.appPrefix + "track-changes")>1) { - Common.NotificationCenter.trigger('reviewchanges:turn', globalFlag, true, true); + onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) { + if ( this.appConfig.isReviewOnly ) { + this.view.turnChanges(true); + } else + if ( this.appConfig.canReview ) { + 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) { resolve(); })).then(function () { - function _setReviewStatus(state, global) { - me.view.turnChanges(state, global); - !global && me.api.asc_SetLocalTrackRevisions(state); - 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); + // function _setReviewStatus(state, global) { + // me.view.turnChanges(state, global); + // !global && me.api.asc_SetLocalTrackRevisions(state); + // 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; + 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); - _setReviewStatus(state, global); + + // _setReviewStatus(state, global); if ( typeof (me.appConfig.customization) == 'object' && (me.appConfig.customization.showReviewChanges==true) ) { me.dlgChanges = (new Common.Views.ReviewChangesDialog({ diff --git a/apps/documenteditor/main/app/controller/Statusbar.js b/apps/documenteditor/main/app/controller/Statusbar.js index e57649a4f..b48ee0e7f 100644 --- a/apps/documenteditor/main/app/controller/Statusbar.js +++ b/apps/documenteditor/main/app/controller/Statusbar.js @@ -70,7 +70,7 @@ define([ Common.localStorage.setBool('de-hidden-status', 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('reviewchanges:turn', me.onTurnPreview.bind(me)); }, onAppReady: function (config) { @@ -137,6 +136,7 @@ define([ if (me.changesTooltip === undefined) me.changesTooltip = me.createChangesTip(me.textTrackChanges, 'de-track-changes-tip'); + me.hideTips(); me.changesTooltip.show(); } else { me.btnTurnReview.updateHint(me.tipReview); @@ -155,6 +155,7 @@ define([ if (me.newChangesTooltip === undefined) me.newChangesTooltip = me.createChangesTip(me.textHasChanges, 'de-new-changes'); + me.hideTips(); me.newChangesTooltip.show(); } else me.btnTurnReview.updateHint(me.tipReview); @@ -163,14 +164,21 @@ define([ }); }, - onTurnPreview: function(state, global, fromApi) { - if (!state && this.changesTooltip && this.changesTooltip.isVisible()) { - this.changesTooltip.hide(); - this.btnTurnReview.updateHint(this.tipReview); - } else if (fromApi && state && global ) { - if (this.globalChangesTooltip === undefined) - this.globalChangesTooltip = this.createChangesTip(this.textSetTrackChanges); - !this.globalChangesTooltip.isVisible() && this.globalChangesTooltip.show(); + onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) { + var global = (localFlag===null), + state = global ? globalFlag : localFlag; + if (this.btnTurnReview) { + if (!state) { + this.hideTips(); + this.btnTurnReview.updateHint(this.tipReview); + } 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.asc_registerCallback('asc_onZoomChange', _.bind(this._onZoomChange, 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); }, @@ -257,6 +266,12 @@ define([ 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) { var me = this; var tip = new Common.UI.SynchronizeTip({