From dfa807f4b11166df3bf8877234720cdda22a6509 Mon Sep 17 00:00:00 2001 From: Sergey Luzyanin Date: Tue, 13 Aug 2019 14:34:20 +0300 Subject: [PATCH 01/14] [comapre] Add scripts --- apps/documenteditor/sdk_dev_scripts.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/documenteditor/sdk_dev_scripts.js b/apps/documenteditor/sdk_dev_scripts.js index 7eb4346000..6e10464297 100644 --- a/apps/documenteditor/sdk_dev_scripts.js +++ b/apps/documenteditor/sdk_dev_scripts.js @@ -13,6 +13,7 @@ var sdk_dev_scrpipts = [ "../../../../sdkjs/common/TableId.js", "../../../../sdkjs/common/TableIdChanges.js", "../../../../sdkjs/common/macros.js", + "../../../../sdkjs/common/delta.js", "../../../../sdkjs/common/NumFormat.js", "../../../../sdkjs/common/SerializeChart.js", "../../../../sdkjs/common/AdvancedOptions.js", @@ -91,6 +92,7 @@ var sdk_dev_scrpipts = [ "../../../../sdkjs/word/Editor/GraphicObjects/WrapManager.js", "../../../../sdkjs/word/Editor/CollaborativeEditing.js", "../../../../sdkjs/word/Editor/DocumentContentElementBase.js", + "../../../../sdkjs/word/Editor/DocumentComparison.js", "../../../../sdkjs/word/Editor/ParagraphContentBase.js", "../../../../sdkjs/word/Editor/Comments.js", "../../../../sdkjs/word/Editor/CommentsChanges.js", From 9b0047189df3920013de45579a3e1bcfbf0f3f68 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 13 Aug 2019 17:40:52 +0300 Subject: [PATCH 02/14] [DE] Compare two documents --- .../main/lib/controller/ReviewChanges.js | 53 ++++++++++++++++++- .../main/lib/view/ImageFromUrlDialog.js | 2 +- apps/common/main/lib/view/ReviewChanges.js | 47 +++++++++++++++- apps/documenteditor/main/app/view/Toolbar.js | 4 +- apps/documenteditor/main/locale/en.json | 7 +++ 5 files changed, 106 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 9fe50e74da..b1aa9de10c 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -74,7 +74,8 @@ define([ 'reviewchange:reject': _.bind(this.onRejectClick, this), 'reviewchange:delete': _.bind(this.onDeleteClick, this), 'reviewchange:preview': _.bind(this.onBtnPreviewClick, this), - 'reviewchanges:view': _.bind(this.onReviewViewClick, this), + 'reviewchange:view': _.bind(this.onReviewViewClick, this), + 'reviewchange:compare': _.bind(this.onCompareClick, this), 'lang:document': _.bind(this.onDocLanguage, this), 'collaboration:coauthmode': _.bind(this.onCoAuthMode, this) }, @@ -554,6 +555,53 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.view); }, + onCompareClick: function(item) { + if (this.api) { + if (item === 'file') { + // if (this.api) + // this.api.asc_addDocument(); + Common.NotificationCenter.trigger('edit:complete', this.view); + } else if (item === 'url') { + var me = this; + (new Common.Views.ImageFromUrlDialog({ + title: me.textUrl, + handler: function(result, value) { + if (result == 'ok') { + if (me.api) { + var checkUrl = value.replace(/ /g, ''); + if (!_.isEmpty(checkUrl)) { + // me.api.AddDocumentUrl(checkUrl); + } + } + Common.NotificationCenter.trigger('edit:complete', me.view); + } + } + })).show(); + } else if (item === 'storage') { + // if (this.toolbar.mode.canRequestInsertImage) { + // Common.Gateway.requestInsertImage(); + // } else { + // (new Common.Views.SelectFileDlg({ + // fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly") + // })).on('selectfile', function(obj, file){ + // me.insertImage(file); + // }).show(); + // } + } else if (item === 'settings') { + // show settings dialog + } + } + Common.NotificationCenter.trigger('edit:complete', this.view); + }, + + insertImage: function(data) { + if (data && data.url) { + this.toolbar.fireEvent('insertimage', this.toolbar); + this.api.AddImageUrl(data.url, undefined, data.token);// for loading from storage + Common.component.Analytics.trackEvent('ToolBar', 'Image'); + } + }, + turnDisplayMode: function(mode) { if (this.api) { if (mode === 'final') @@ -797,6 +845,7 @@ define([ textTableRowsDel: 'Table Rows Deleted', textParaMoveTo: 'Moved:', textParaMoveFromUp: 'Moved Up:', - textParaMoveFromDown: 'Moved Down:' + textParaMoveFromDown: 'Moved Down:', + textUrl: 'Paste a document URL' }, Common.Controllers.ReviewChanges || {})); }); \ No newline at end of file diff --git a/apps/common/main/lib/view/ImageFromUrlDialog.js b/apps/common/main/lib/view/ImageFromUrlDialog.js index 63b0ea6851..9f25ef4343 100644 --- a/apps/common/main/lib/view/ImageFromUrlDialog.js +++ b/apps/common/main/lib/view/ImageFromUrlDialog.js @@ -55,7 +55,7 @@ define([ this.template = [ '
', '
', - '', + '', '
', '
', '
', diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index 2325f1b31e..5e5f4daaf4 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -79,6 +79,10 @@ define([ '' + '' + '
' + + '
' + + '' + + '
' + + '
' + '
' + '' + '
' + @@ -115,6 +119,14 @@ define([ me.fireEvent('reviewchange:reject', [menu, item]); }); + this.btnCompare.on('click', function (e) { + me.fireEvent('reviewchange:compare', ['file']); + }); + + this.btnCompare.menu.on('item:click', function (menu, item, e) { + me.fireEvent('reviewchange:compare', [item.value]); + }); + this.btnsTurnReview.forEach(function (button) { button.on('click', _click_turnpreview.bind(me)); }); @@ -129,7 +141,7 @@ define([ }); this.btnReviewView && this.btnReviewView.menu.on('item:click', function (menu, item, e) { - me.fireEvent('reviewchanges:view', [menu, item]); + me.fireEvent('reviewchange:view', [menu, item]); }); } @@ -188,6 +200,13 @@ define([ iconCls: 'review-deny' }); + this.btnCompare = new Common.UI.Button({ + cls : 'btn-toolbar x-huge icon-top', + caption : this.txtCompare, + split : true, + iconCls: 'review-deny' + }); + this.btnTurnOn = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'btn-ic-review', @@ -348,6 +367,17 @@ define([ ); me.btnReject.updateHint([me.tipRejectCurrent, me.txtRejectChanges]); + me.btnCompare.setMenu(new Common.UI.Menu({ + items: [ + {caption: me.mniFromFile, value: 'file'}, + {caption: me.mniFromUrl, value: 'url'}, + {caption: me.mniFromStorage, value: 'storage'}, + {caption: '--'}, + {caption: me.mniSettings, value: 'settings'} + ] + })); + me.btnCompare.updateHint(me.tipCompare); + me.btnAccept.setDisabled(config.isReviewOnly); me.btnReject.setDisabled(config.isReviewOnly); } @@ -400,6 +430,7 @@ define([ var separator_sharing = !(me.btnSharing || me.btnCoAuthMode) ? me.$el.find('.separator.sharing') : '.separator.sharing', separator_comments = !(config.canComments && config.canCoAuthoring) ? me.$el.find('.separator.comments') : '.separator.comments', separator_review = !(config.canReview || config.canViewReview) ? me.$el.find('.separator.review') : '.separator.review', + separator_compare = !config.canReview ? me.$el.find('.separator.compare') : '.separator.compare', separator_chat = !me.btnChat ? me.$el.find('.separator.chat') : '.separator.chat', separator_last; @@ -418,6 +449,11 @@ define([ else separator_last = separator_review; + if (typeof separator_compare == 'object') + separator_compare.hide().prev('.group').hide(); + else + separator_last = separator_compare; + if (typeof separator_chat == 'object') separator_chat.hide().prev('.group').hide(); else @@ -438,6 +474,7 @@ define([ if ( this.appConfig.canReview ) { this.btnAccept.render(this.$el.find('#btn-change-accept')); this.btnReject.render(this.$el.find('#btn-change-reject')); + this.btnCompare.render(this.$el.find('#btn-compare')); this.btnTurnOn.render(this.$el.find('#btn-review-on')); } this.btnPrev && this.btnPrev.render(this.$el.find('#btn-change-prev')); @@ -609,7 +646,13 @@ define([ txtFinalCap: 'Final', txtOriginalCap: 'Original', strFastDesc: 'Real-time co-editing. All changes are saved automatically.', - strStrictDesc: 'Use the \'Save\' button to sync the changes you and others make.' + strStrictDesc: 'Use the \'Save\' button to sync the changes you and others make.', + txtCompare: 'Compare', + tipCompare: 'Compare current document with another one', + mniFromFile: 'Document from File', + mniFromUrl: 'Document from URL', + mniFromStorage: 'Document from Storage', + mniSettings: 'Comparison Settings' } }()), Common.Views.ReviewChanges || {})); diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 6a1ee4caa1..9a4365729d 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -2272,8 +2272,8 @@ define([ tipBack: 'Back', tipInsertShape: 'Insert Autoshape', tipInsertEquation: 'Insert Equation', - mniImageFromFile: 'Image from file', - mniImageFromUrl: 'Image from url', + mniImageFromFile: 'Image from File', + mniImageFromUrl: 'Image from URL', mniCustomTable: 'Insert Custom Table', textTitleError: 'Error', textInsertPageNumber: 'Insert page number', diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 135c39df38..e8842a0414 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -69,6 +69,7 @@ "Common.Controllers.ReviewChanges.textTabs": "Change tabs", "Common.Controllers.ReviewChanges.textUnderline": "Underline", "Common.Controllers.ReviewChanges.textWidow": "Widow control", + "Common.Controllers.ReviewChanges.textUrl": "Paste a document URL", "Common.UI.ComboBorderSize.txtNoBorders": "No borders", "Common.UI.ComboBorderSizeEditable.txtNoBorders": "No borders", "Common.UI.ComboDataView.emptyComboText": "No styles", @@ -268,6 +269,12 @@ "Common.Views.ReviewChanges.txtSpelling": "Spell Checking", "Common.Views.ReviewChanges.txtTurnon": "Track Changes", "Common.Views.ReviewChanges.txtView": "Display Mode", + "Common.Views.ReviewChanges.txtCompare": "Compare", + "Common.Views.ReviewChanges.tipCompare": "Compare current document with another one", + "Common.Views.ReviewChanges.mniFromFile": "Document from File", + "Common.Views.ReviewChanges.mniFromUrl": "Document from URL", + "Common.Views.ReviewChanges.mniFromStorage": "Document from Storage", + "Common.Views.ReviewChanges.mniSettings": "Comparison Settings", "Common.Views.ReviewChangesDialog.textTitle": "Review Changes", "Common.Views.ReviewChangesDialog.txtAccept": "Accept", "Common.Views.ReviewChangesDialog.txtAcceptAll": "Accept All Changes", From 8ae13a7fdecc50325a3f02c293d80c23cad61e13 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 14 Aug 2019 11:07:24 +0300 Subject: [PATCH 03/14] [DE] Add settings for comparison of documents --- .../main/lib/controller/ReviewChanges.js | 26 ++- .../main/app/controller/Toolbar.js | 3 +- .../main/app/view/CompareSettingsDialog.js | 154 ++++++++++++++++++ apps/documenteditor/main/locale/en.json | 4 + 4 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 apps/documenteditor/main/app/view/CompareSettingsDialog.js diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index b1aa9de10c..3eff2a871d 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -96,7 +96,7 @@ define([ this.collection = this.getApplication().getCollection('Common.Collections.ReviewChanges'); this.userCollection = this.getApplication().getCollection('Common.Collections.Users'); - this._state = {posx: -1000, posy: -1000, popoverVisible: false, previewMode: false}; + this._state = {posx: -1000, posy: -1000, popoverVisible: false, previewMode: false, compareSettings: null /*new AscCommon.CComparisonPr()*/}; Common.NotificationCenter.on('reviewchanges:turn', this.onTurnPreview.bind(this)); Common.NotificationCenter.on('spelling:turn', this.onTurnSpelling.bind(this)); @@ -559,7 +559,7 @@ define([ if (this.api) { if (item === 'file') { // if (this.api) - // this.api.asc_addDocument(); + // this.api.asc_addDocument(me._state.compareSettings); Common.NotificationCenter.trigger('edit:complete', this.view); } else if (item === 'url') { var me = this; @@ -570,7 +570,7 @@ define([ if (me.api) { var checkUrl = value.replace(/ /g, ''); if (!_.isEmpty(checkUrl)) { - // me.api.AddDocumentUrl(checkUrl); + // me.api.AddDocumentUrl(checkUrl, me._state.compareSettings); } } Common.NotificationCenter.trigger('edit:complete', me.view); @@ -584,21 +584,29 @@ define([ // (new Common.Views.SelectFileDlg({ // fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly") // })).on('selectfile', function(obj, file){ - // me.insertImage(file); + // me.selectFile(file, me._state.compareSettings); // }).show(); // } } else if (item === 'settings') { - // show settings dialog + var me = this; + (new DE.Views.CompareSettingsDialog({ + props: me._state.compareSettings, + handler: function(result, value) { + if (result == 'ok') { + me._state.compareSettings = value; + } + + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + } + })).show(); } } Common.NotificationCenter.trigger('edit:complete', this.view); }, - insertImage: function(data) { + selectFile: function(data) { if (data && data.url) { - this.toolbar.fireEvent('insertimage', this.toolbar); - this.api.AddImageUrl(data.url, undefined, data.token);// for loading from storage - Common.component.Analytics.trackEvent('ToolBar', 'Image'); + // this.api.AddDocumentUrl(data.url, this._state.compareSettings, data.token);// for loading from storage } }, diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index f093edef46..ff10841e20 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -56,7 +56,8 @@ define([ 'documenteditor/main/app/controller/PageLayout', 'documenteditor/main/app/view/CustomColumnsDialog', 'documenteditor/main/app/view/ControlSettingsDialog', - 'documenteditor/main/app/view/WatermarkSettingsDialog' + 'documenteditor/main/app/view/WatermarkSettingsDialog', + 'documenteditor/main/app/view/CompareSettingsDialog' ], function () { 'use strict'; diff --git a/apps/documenteditor/main/app/view/CompareSettingsDialog.js b/apps/documenteditor/main/app/view/CompareSettingsDialog.js new file mode 100644 index 0000000000..20fc1bc1b0 --- /dev/null +++ b/apps/documenteditor/main/app/view/CompareSettingsDialog.js @@ -0,0 +1,154 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +/** + * CompareSettingsDialog.js.js + * + * Created by Julia Radzhabova on 14.08.2019 + * Copyright (c) 2019 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'common/main/lib/util/utils', + 'common/main/lib/component/CheckBox', + 'common/main/lib/component/InputField', + 'common/main/lib/view/AdvancedSettingsWindow' +], function () { 'use strict'; + + DE.Views.CompareSettingsDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + options: { + contentWidth: 220, + height: 160 + }, + + initialize : function(options) { + var me = this; + + _.extend(this.options, { + title: this.textTitle, + template: [ + '
', + '
', + '
', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '
', + '', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '' + ].join('') + }, options); + + this.handler = options.handler; + this.props = options.props; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + + render: function() { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.radioChar = new Common.UI.RadioBox({ + el: $('#compare-settings-radio-char'), + labelText: this.textChar, + name: 'asc-radio-compare-show' + }); + + this.radioWord = new Common.UI.RadioBox({ + el: $('#compare-settings-radio-word'), + labelText: this.textWord, + name: 'asc-radio-compare-show', + checked: true + }); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + show: function() { + Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); + }, + + _setDefaults: function (props) { + if (props) { + // var val = props.get_ShowAt(); + // val ? this.radioChar.setValue(true, true) : this.radioWord.setValue(true, true); + } + }, + + getSettings: function () { + // var props = new AscCommon.CComparisonPr(); + // props.put_ShowAt(this.radioChar.getValue()); + // return props; + }, + + onDlgBtnClick: function(event) { + var me = this; + var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event; + if (state == 'ok') { + this.handler && this.handler.call(this, state, this.getSettings()); + } + + this.close(); + }, + + textTitle: 'Comparison Settings', + textShow: 'Show changes at', + textChar: 'Character level', + textWord: 'Word level' + + }, DE.Views.CompareSettingsDialog || {})) +}); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index e8842a0414..082b4f28b4 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1054,6 +1054,10 @@ "DE.Views.ChartSettings.txtTight": "Tight", "DE.Views.ChartSettings.txtTitle": "Chart", "DE.Views.ChartSettings.txtTopAndBottom": "Top and bottom", + "DE.Views.CompareSettingsDialog.textTitle": "Comparison Settings", + "DE.Views.CompareSettingsDialog.textShow": "Show changes at", + "DE.Views.CompareSettingsDialog.textChar": "Character level", + "DE.Views.CompareSettingsDialog.textWord": "Word level", "DE.Views.ControlSettingsDialog.cancelButtonText": "Cancel", "DE.Views.ControlSettingsDialog.okButtonText": "OK", "DE.Views.ControlSettingsDialog.textAppearance": "Appearance", From 322888f37d32df875df95660a08f5891529b2e8c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 14 Aug 2019 16:18:57 +0300 Subject: [PATCH 04/14] [DE] Compare documents: use sdk methods --- apps/common/main/lib/controller/ReviewChanges.js | 10 +++++++--- .../main/app/view/CompareSettingsDialog.js | 14 +++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 3eff2a871d..5eea76e1f5 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -557,9 +557,13 @@ define([ onCompareClick: function(item) { if (this.api) { + if (!this._state.compareSettings) { + this._state.compareSettings = new AscCommonWord.ComparisonOptions(); + this._state.compareSettings.putWords(!Common.localStorage.getBool("de-compare-char")); + } if (item === 'file') { - // if (this.api) - // this.api.asc_addDocument(me._state.compareSettings); + if (this.api) + this.api.asc_CompareDocumentFile(this._state.compareSettings); Common.NotificationCenter.trigger('edit:complete', this.view); } else if (item === 'url') { var me = this; @@ -570,7 +574,7 @@ define([ if (me.api) { var checkUrl = value.replace(/ /g, ''); if (!_.isEmpty(checkUrl)) { - // me.api.AddDocumentUrl(checkUrl, me._state.compareSettings); + me.api.asc_CompareDocumentUrl(checkUrl, me._state.compareSettings); } } Common.NotificationCenter.trigger('edit:complete', me.view); diff --git a/apps/documenteditor/main/app/view/CompareSettingsDialog.js b/apps/documenteditor/main/app/view/CompareSettingsDialog.js index 20fc1bc1b0..dbf6f5c462 100644 --- a/apps/documenteditor/main/app/view/CompareSettingsDialog.js +++ b/apps/documenteditor/main/app/view/CompareSettingsDialog.js @@ -107,8 +107,7 @@ define([ this.radioWord = new Common.UI.RadioBox({ el: $('#compare-settings-radio-word'), labelText: this.textWord, - name: 'asc-radio-compare-show', - checked: true + name: 'asc-radio-compare-show' }); this.afterRender(); @@ -124,15 +123,15 @@ define([ _setDefaults: function (props) { if (props) { - // var val = props.get_ShowAt(); - // val ? this.radioChar.setValue(true, true) : this.radioWord.setValue(true, true); + var value = props.getWords(); + (value==false) ? this.radioChar.setValue(true, true) : this.radioWord.setValue(true, true); } }, getSettings: function () { - // var props = new AscCommon.CComparisonPr(); - // props.put_ShowAt(this.radioChar.getValue()); - // return props; + var props = new AscCommonWord.ComparisonOptions(); + props.putWords(this.radioWord.getValue()); + return props; }, onDlgBtnClick: function(event) { @@ -140,6 +139,7 @@ define([ var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event; if (state == 'ok') { this.handler && this.handler.call(this, state, this.getSettings()); + Common.localStorage.setItem("de-compare-char", this.radioChar.getValue()); } this.close(); From fa4e0a6cda0ca7fa70577e3456126d8cc0815163 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 9 Oct 2019 17:33:29 +0300 Subject: [PATCH 05/14] [DE] Add asc_onAcceptChangesBeforeCompare event --- .../main/lib/controller/ReviewChanges.js | 20 ++++++++++++++++++- apps/documenteditor/main/locale/en.json | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index ff9b70a8d8..659b45025e 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -125,6 +125,7 @@ define([ this.api.asc_registerCallback('asc_onShowRevisionsChange', _.bind(this.onApiShowChange, this)); this.api.asc_registerCallback('asc_onUpdateRevisionsChangesPosition', _.bind(this.onApiUpdateChangePosition, this)); } + this.api.asc_registerCallback('asc_onAcceptChangesBeforeCompare',_.bind(this.onAcceptChangesBeforeCompare, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } }, @@ -624,6 +625,22 @@ define([ } }, + onAcceptChangesBeforeCompare: function(callback) { + var me = this; + Common.UI.warning({ + width: 550, + msg: this.textAcceptBeforeCompare, + buttons: ['yes', 'no'], + primary: 'yes', + callback: function(result) { + _.defer(function() { + if (callback) callback.call(result=='yes'); + }); + Common.NotificationCenter.trigger('edit:complete', this.view); + } + }); + }, + turnDisplayMode: function(mode) { if (this.api) { if (mode === 'final') @@ -893,6 +910,7 @@ define([ textParaMoveTo: 'Moved:', textParaMoveFromUp: 'Moved Up:', textParaMoveFromDown: 'Moved Down:', - textUrl: 'Paste a document URL' + textUrl: 'Paste a document URL', + textAcceptBeforeCompare: 'In order to compare documents all the tracked changes in them will be considered to have been accepted. Do you want to continue?' }, Common.Controllers.ReviewChanges || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index fcd0043ea6..4b6a862422 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -70,6 +70,7 @@ "Common.Controllers.ReviewChanges.textUnderline": "Underline", "Common.Controllers.ReviewChanges.textWidow": "Widow control", "Common.Controllers.ReviewChanges.textUrl": "Paste a document URL", + "Common.Controllers.ReviewChanges.textAcceptBeforeCompare": "In order to compare documents all the tracked changes in them will be considered to have been accepted. Do you want to continue?", "Common.UI.ComboBorderSize.txtNoBorders": "No borders", "Common.UI.ComboBorderSizeEditable.txtNoBorders": "No borders", "Common.UI.ComboDataView.emptyComboText": "No styles", From 5c05508dcff669cb55c4928f9ccb87cb5efb4a47 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 11 Oct 2019 15:12:59 +0300 Subject: [PATCH 06/14] [DE] Compare files: add errors. --- apps/api/documents/api.js | 1 + apps/common/Gateway.js | 8 ++++++++ .../main/lib/controller/ReviewChanges.js | 20 ++++++++++++------- apps/common/main/lib/view/ReviewChanges.js | 1 + .../main/app/controller/Main.js | 20 +++++++++++++++++-- apps/documenteditor/main/locale/en.json | 3 +++ 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 59985afe84..5782fb9f74 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -206,6 +206,7 @@ _config.editorConfig.canRequestSaveAs = _config.events && !!_config.events.onRequestSaveAs; _config.editorConfig.canRequestInsertImage = _config.events && !!_config.events.onRequestInsertImage; _config.editorConfig.canRequestMailMergeRecipients = _config.events && !!_config.events.onRequestMailMergeRecipients; + _config.editorConfig.canRequestCompareFile = _config.events && !!_config.events.onRequestCompareFile; _config.frameEditorId = placeholderId; var onMouseUp = function (evt) { diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index b8e90ebada..b8726a329f 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -118,6 +118,10 @@ if (Common === undefined) { 'setMailMergeRecipients': function(data) { $me.trigger('setmailmergerecipients', data); + }, + + 'compareFile': function(data) { + $me.trigger('comparefile', data); } }; @@ -308,6 +312,10 @@ if (Common === undefined) { _postMessage({event:'onRequestMailMergeRecipients'}) }, + requestCompareFile: function () { + _postMessage({event:'onRequestCompareFile'}) + }, + on: function(event, handler){ var localHandler = function(event, data){ handler.call(me, data) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 659b45025e..ab0f5760ce 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -127,6 +127,8 @@ define([ } this.api.asc_registerCallback('asc_onAcceptChangesBeforeCompare',_.bind(this.onAcceptChangesBeforeCompare, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); + + Common.Gateway.on('comparefile', _.bind(this.compareFile, this)); } }, @@ -593,13 +595,13 @@ define([ } })).show(); } else if (item === 'storage') { - // if (this.toolbar.mode.canRequestInsertImage) { - // Common.Gateway.requestInsertImage(); + // if (this.appConfig.canRequestCompareFile) { + // Common.Gateway.requestCompareFile(); // } else { // (new Common.Views.SelectFileDlg({ - // fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "ImagesOnly") - // })).on('selectfile', function(obj, file){ - // me.selectFile(file, me._state.compareSettings); + // fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "DocumentsOnly") + // })).on('comparefile', function(obj, file){ + // me.compareFile(file, me._state.compareSettings); // }).show(); // } } else if (item === 'settings') { @@ -619,9 +621,13 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.view); }, - selectFile: function(data) { + compareFile: function(data) { + if (!this._state.compareSettings) { + this._state.compareSettings = new AscCommonWord.ComparisonOptions(); + this._state.compareSettings.putWords(!Common.localStorage.getBool("de-compare-char")); + } if (data && data.url) { - // this.api.AddDocumentUrl(data.url, this._state.compareSettings, data.token);// for loading from storage + this.api.asc_CompareDocumentUrl(data.url, this._state.compareSettings, data.token);// for loading from storage } }, diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index 5e5f4daaf4..35069f1c9d 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -376,6 +376,7 @@ define([ {caption: me.mniSettings, value: 'settings'} ] })); + me.btnCompare.menu.items[2].setVisible(me.appConfig.canRequestCompareFile || me.appConfig.fileChoiceUrl && me.appConfig.fileChoiceUrl.indexOf("{documentType}")>-1); me.btnCompare.updateHint(me.tipCompare); me.btnAccept.setDisabled(config.isReviewOnly); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index c17bb472a0..c29231e22c 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -351,6 +351,7 @@ define([ this.appOptions.canRequestSendNotify = this.editorConfig.canRequestSendNotify; this.appOptions.canRequestSaveAs = this.editorConfig.canRequestSaveAs; this.appOptions.canRequestInsertImage = this.editorConfig.canRequestInsertImage; + this.appOptions.canRequestCompareFile = this.editorConfig.canRequestCompareFile; this.appOptions.canRequestMailMergeRecipients = this.editorConfig.canRequestMailMergeRecipients; appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); @@ -1384,6 +1385,18 @@ define([ config.msg = this.uploadImageFileCountMessage; break; + case Asc.c_oAscError.ID.UplDocumentSize: + config.msg = this.uploadDocSizeMessage; + break; + + case Asc.c_oAscError.ID.UplDocumentExt: + config.msg = this.uploadDocExtMessage; + break; + + case Asc.c_oAscError.ID.UplDocumentFileCount: + config.msg = this.uploadDocFileCountMessage; + break; + case Asc.c_oAscError.ID.SplitCellMaxRows: config.msg = this.splitMaxRowsErrorText.replace('%1', errData.get_Value()); break; @@ -2157,7 +2170,7 @@ define([ uploadImageTextText: 'Uploading image...', savePreparingText: 'Preparing to save', savePreparingTitle: 'Preparing to save. Please wait...', - uploadImageSizeMessage: 'Maximium image size limit exceeded.', + uploadImageSizeMessage: 'Maximum image size limit exceeded.', uploadImageExtMessage: 'Unknown image format.', uploadImageFileCountMessage: 'No images uploaded.', reloadButtonText: 'Reload Page', @@ -2473,7 +2486,10 @@ define([ errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
Please contact your Document Server administrator for details.', txtMainDocOnly: 'Error! Main Document Only.', txtNotValidBookmark: 'Error! Not a valid bookmark self-reference.', - txtNoText: 'Error! No text of specified style in document.' + txtNoText: 'Error! No text of specified style in document.', + uploadDocSizeMessage: 'Maximum document size limit exceeded.', + uploadDocExtMessage: 'Unknown document format.', + uploadDocFileCountMessage: 'No documents uploaded.' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 4b6a862422..bc08a9de58 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -641,6 +641,9 @@ "DE.Controllers.Main.txtZeroDivide": "Zero Divide", "DE.Controllers.Main.unknownErrorText": "Unknown error.", "DE.Controllers.Main.unsupportedBrowserErrorText": "Your browser is not supported.", + "DE.Controllers.Main.uploadDocSizeMessage": "Maximum document size limit exceeded.", + "DE.Controllers.Main.uploadDocExtMessage": "Unknown document format.", + "DE.Controllers.Main.uploadDocFileCountMessage": "No documents uploaded.", "DE.Controllers.Main.uploadImageExtMessage": "Unknown image format.", "DE.Controllers.Main.uploadImageFileCountMessage": "No images uploaded.", "DE.Controllers.Main.uploadImageSizeMessage": "Maximum image size limit exceeded.", From 3facb70ebad3aa260189ff025b4d68571466d6e8 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 15 Oct 2019 10:58:18 +0300 Subject: [PATCH 07/14] [DE] Compare: use loading from fileChoiceUrl --- apps/common/main/lib/controller/ReviewChanges.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index ab0f5760ce..b06d4be0ab 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -595,14 +595,15 @@ define([ } })).show(); } else if (item === 'storage') { + var me = this; // if (this.appConfig.canRequestCompareFile) { // Common.Gateway.requestCompareFile(); // } else { - // (new Common.Views.SelectFileDlg({ - // fileChoiceUrl: this.toolbar.mode.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "DocumentsOnly") - // })).on('comparefile', function(obj, file){ - // me.compareFile(file, me._state.compareSettings); - // }).show(); + (new Common.Views.SelectFileDlg({ + fileChoiceUrl: this.appConfig.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "DocumentsOnly") + })).on('selectfile', function(obj, file){ + me.compareFile(file, me._state.compareSettings); + }).show(); // } } else if (item === 'settings') { var me = this; From e605452cfb34b615342d33531d024ec8af71b88e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 15 Oct 2019 11:44:38 +0300 Subject: [PATCH 08/14] [DE] Compare use onRequestCompareFile/setRevisedFile for loading file --- apps/api/documents/api.js | 10 +++++++++- apps/common/Gateway.js | 4 ++-- .../main/lib/controller/ReviewChanges.js | 18 ++++++++---------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 5782fb9f74..e46df27fd0 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -576,6 +576,13 @@ }); }; + var _setRevisedFile = function(data) { + _sendCommand({ + command: 'setRevisedFile', + data: data + }); + }; + var _processMouse = function(evt) { var r = iframe.getBoundingClientRect(); var data = { @@ -620,7 +627,8 @@ showSharingSettings : _showSharingSettings, setSharingSettings : _setSharingSettings, insertImage : _insertImage, - setMailMergeRecipients: _setMailMergeRecipients + setMailMergeRecipients: _setMailMergeRecipients, + setRevisedFile : _setRevisedFile } }; diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index b8726a329f..6d45aa3a75 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -120,8 +120,8 @@ if (Common === undefined) { $me.trigger('setmailmergerecipients', data); }, - 'compareFile': function(data) { - $me.trigger('comparefile', data); + 'setRevisedFile': function(data) { + $me.trigger('setrevisedfile', data); } }; diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index b06d4be0ab..2b0415dcf8 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -128,7 +128,7 @@ define([ this.api.asc_registerCallback('asc_onAcceptChangesBeforeCompare',_.bind(this.onAcceptChangesBeforeCompare, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); - Common.Gateway.on('comparefile', _.bind(this.compareFile, this)); + Common.Gateway.on('setrevisedfile', _.bind(this.setRevisedFile, this)); } }, @@ -570,6 +570,7 @@ define([ onCompareClick: function(item) { if (this.api) { + var me = this; if (!this._state.compareSettings) { this._state.compareSettings = new AscCommonWord.ComparisonOptions(); this._state.compareSettings.putWords(!Common.localStorage.getBool("de-compare-char")); @@ -579,7 +580,6 @@ define([ this.api.asc_CompareDocumentFile(this._state.compareSettings); Common.NotificationCenter.trigger('edit:complete', this.view); } else if (item === 'url') { - var me = this; (new Common.Views.ImageFromUrlDialog({ title: me.textUrl, handler: function(result, value) { @@ -595,18 +595,16 @@ define([ } })).show(); } else if (item === 'storage') { - var me = this; - // if (this.appConfig.canRequestCompareFile) { - // Common.Gateway.requestCompareFile(); - // } else { + if (this.appConfig.canRequestCompareFile) { + Common.Gateway.requestCompareFile(); + } else { (new Common.Views.SelectFileDlg({ fileChoiceUrl: this.appConfig.fileChoiceUrl.replace("{fileExt}", "").replace("{documentType}", "DocumentsOnly") })).on('selectfile', function(obj, file){ - me.compareFile(file, me._state.compareSettings); + me.setRevisedFile(file, me._state.compareSettings); }).show(); - // } + } } else if (item === 'settings') { - var me = this; (new DE.Views.CompareSettingsDialog({ props: me._state.compareSettings, handler: function(result, value) { @@ -622,7 +620,7 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.view); }, - compareFile: function(data) { + setRevisedFile: function(data) { if (!this._state.compareSettings) { this._state.compareSettings = new AscCommonWord.ComparisonOptions(); this._state.compareSettings.putWords(!Common.localStorage.getBool("de-compare-char")); From dfd3f3f3eaef9096dec7129583cd7fae7be743b8 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 15 Oct 2019 12:52:23 +0300 Subject: [PATCH 09/14] [DE] Change icon for compare button --- apps/common/main/lib/view/ReviewChanges.js | 2 +- apps/common/main/resources/less/toolbar.less | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index 35069f1c9d..21dd2a1d19 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -204,7 +204,7 @@ define([ cls : 'btn-toolbar x-huge icon-top', caption : this.txtCompare, split : true, - iconCls: 'review-deny' + iconCls: 'btn-compare' }); this.btnTurnOn = new Common.UI.Button({ diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less index cbab0599bf..e3d40846f0 100644 --- a/apps/common/main/resources/less/toolbar.less +++ b/apps/common/main/resources/less/toolbar.less @@ -533,6 +533,7 @@ .button-normal-icon(btn-caption, 76, @toolbar-big-icon-size); .button-normal-icon(btn-calculation, 80, @toolbar-big-icon-size); .button-normal-icon(btn-scale, 81, @toolbar-big-icon-size); +.button-normal-icon(btn-compare, 82, @toolbar-big-icon-size); [applang=ru] { .btn-toolbar { From a32ac3ec9e8c34c3b482785c305edc7751cabfe2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 18 Oct 2019 10:22:23 +0300 Subject: [PATCH 10/14] [DE] Compare: refactoring --- apps/documenteditor/main/app/view/CompareSettingsDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/CompareSettingsDialog.js b/apps/documenteditor/main/app/view/CompareSettingsDialog.js index e758e3e2f8..d7c9f84ba4 100644 --- a/apps/documenteditor/main/app/view/CompareSettingsDialog.js +++ b/apps/documenteditor/main/app/view/CompareSettingsDialog.js @@ -135,7 +135,7 @@ define([ var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event; if (state == 'ok') { this.handler && this.handler.call(this, state, this.getSettings()); - Common.localStorage.setItem("de-compare-char", this.radioChar.getValue()); + Common.localStorage.setBool("de-compare-char", this.radioChar.getValue()); } this.close(); From a7aa69f454185dba61008316f14c23a457ff9309 Mon Sep 17 00:00:00 2001 From: Sergey Luzyanin Date: Fri, 25 Oct 2019 13:46:37 +0300 Subject: [PATCH 11/14] [de][comparison] Fix callback call --- apps/common/main/lib/controller/ReviewChanges.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 2b0415dcf8..fdfda5bd5b 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -639,7 +639,7 @@ define([ primary: 'yes', callback: function(result) { _.defer(function() { - if (callback) callback.call(result=='yes'); + if (callback) callback(result=='yes'); }); Common.NotificationCenter.trigger('edit:complete', this.view); } From 6cbee37f9b25021e746826ea00903859d59454d2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 28 Oct 2019 14:40:17 +0300 Subject: [PATCH 12/14] [DE] Hide compare settings --- apps/common/main/lib/view/ReviewChanges.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index 21dd2a1d19..af11cb47c2 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -371,9 +371,9 @@ define([ items: [ {caption: me.mniFromFile, value: 'file'}, {caption: me.mniFromUrl, value: 'url'}, - {caption: me.mniFromStorage, value: 'storage'}, - {caption: '--'}, - {caption: me.mniSettings, value: 'settings'} + {caption: me.mniFromStorage, value: 'storage'} + // ,{caption: '--'}, + // {caption: me.mniSettings, value: 'settings'} ] })); me.btnCompare.menu.items[2].setVisible(me.appConfig.canRequestCompareFile || me.appConfig.fileChoiceUrl && me.appConfig.fileChoiceUrl.indexOf("{documentType}")>-1); From 9d8675f041d658ab1a5438083ecffa4393a4e49b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 14 Nov 2019 13:25:01 +0300 Subject: [PATCH 13/14] [DE] Disable comparing of documents in the co-editing mode --- apps/common/main/lib/controller/ReviewChanges.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index fdfda5bd5b..289cdd0bd8 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -124,6 +124,8 @@ define([ if (this.appConfig.canReview || this.appConfig.canViewReview) { this.api.asc_registerCallback('asc_onShowRevisionsChange', _.bind(this.onApiShowChange, 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_onParticipantsChanged', _.bind(this.onAuthParticipantsChanged, this)); } this.api.asc_registerCallback('asc_onAcceptChangesBeforeCompare',_.bind(this.onAcceptChangesBeforeCompare, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); @@ -856,6 +858,17 @@ define([ }); }, + onAuthParticipantsChanged: function(users) { + if (this.view && this.view.btnCompare) { + var length = 0; + _.each(users, function(item){ + if (!item.asc_getView()) + length++; + }); + this.view.btnCompare.setDisabled(length>1 || this.viewmode); + } + }, + textInserted: 'Inserted:', textDeleted: 'Deleted:', textParaInserted: 'Paragraph Inserted ', From 46ab90e14030ab53a0fa1229970c54c090bde7a3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Nov 2019 13:15:59 +0300 Subject: [PATCH 14/14] [DE] Check the availability of the comparison feature --- apps/common/main/lib/view/ReviewChanges.js | 55 ++++++++++--------- .../main/app/controller/Main.js | 1 + 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index d5bf5097b9..b8943753d0 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -120,13 +120,15 @@ define([ me.fireEvent('reviewchange:reject', [menu, item]); }); - this.btnCompare.on('click', function (e) { - me.fireEvent('reviewchange:compare', ['file']); - }); + if (me.appConfig.canFeatureComparison) { + this.btnCompare.on('click', function (e) { + me.fireEvent('reviewchange:compare', ['file']); + }); - this.btnCompare.menu.on('item:click', function (menu, item, e) { - me.fireEvent('reviewchange:compare', [item.value]); - }); + this.btnCompare.menu.on('item:click', function (menu, item, e) { + me.fireEvent('reviewchange:compare', [item.value]); + }); + } this.btnsTurnReview.forEach(function (button) { button.on('click', _click_turnpreview.bind(me)); @@ -211,12 +213,13 @@ define([ iconCls: 'review-deny' }); - this.btnCompare = new Common.UI.Button({ - cls : 'btn-toolbar x-huge icon-top', - caption : this.txtCompare, - split : true, - iconCls: 'btn-compare' - }); + if (this.appConfig.canFeatureComparison) + this.btnCompare = new Common.UI.Button({ + cls : 'btn-toolbar x-huge icon-top', + caption : this.txtCompare, + split : true, + iconCls: 'btn-compare' + }); this.btnTurnOn = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', @@ -387,17 +390,19 @@ define([ ); me.btnReject.updateHint([me.tipRejectCurrent, me.txtRejectChanges]); - me.btnCompare.setMenu(new Common.UI.Menu({ - items: [ - {caption: me.mniFromFile, value: 'file'}, - {caption: me.mniFromUrl, value: 'url'}, - {caption: me.mniFromStorage, value: 'storage'} - // ,{caption: '--'}, - // {caption: me.mniSettings, value: 'settings'} - ] - })); - me.btnCompare.menu.items[2].setVisible(me.appConfig.canRequestCompareFile || me.appConfig.fileChoiceUrl && me.appConfig.fileChoiceUrl.indexOf("{documentType}")>-1); - me.btnCompare.updateHint(me.tipCompare); + if (config.canFeatureComparison) { + me.btnCompare.setMenu(new Common.UI.Menu({ + items: [ + {caption: me.mniFromFile, value: 'file'}, + {caption: me.mniFromUrl, value: 'url'}, + {caption: me.mniFromStorage, value: 'storage'} + // ,{caption: '--'}, + // {caption: me.mniSettings, value: 'settings'} + ] + })); + me.btnCompare.menu.items[2].setVisible(me.appConfig.canRequestCompareFile || me.appConfig.fileChoiceUrl && me.appConfig.fileChoiceUrl.indexOf("{documentType}")>-1); + me.btnCompare.updateHint(me.tipCompare); + } me.btnAccept.setDisabled(config.isReviewOnly); me.btnReject.setDisabled(config.isReviewOnly); @@ -473,7 +478,7 @@ define([ var separator_sharing = !(me.btnSharing || me.btnCoAuthMode) ? me.$el.find('.separator.sharing') : '.separator.sharing', separator_comments = !(config.canComments && config.canCoAuthoring) ? me.$el.find('.separator.comments') : '.separator.comments', separator_review = !(config.canReview || config.canViewReview) ? me.$el.find('.separator.review') : '.separator.review', - separator_compare = !config.canReview ? me.$el.find('.separator.compare') : '.separator.compare', + separator_compare = !(config.canReview && config.canFeatureComparison) ? me.$el.find('.separator.compare') : '.separator.compare', separator_chat = !me.btnChat ? me.$el.find('.separator.chat') : '.separator.chat', separator_last; @@ -517,7 +522,7 @@ define([ if ( this.appConfig.canReview ) { this.btnAccept.render(this.$el.find('#btn-change-accept')); this.btnReject.render(this.$el.find('#btn-change-reject')); - this.btnCompare.render(this.$el.find('#btn-compare')); + this.appConfig.canFeatureComparison && this.btnCompare.render(this.$el.find('#btn-compare')); this.btnTurnOn.render(this.$el.find('#btn-review-on')); } this.btnPrev && this.btnPrev.render(this.$el.find('#btn-change-prev')); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 133ba6f7c2..c75edb3b0f 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -355,6 +355,7 @@ define([ this.appOptions.canRequestCompareFile = this.editorConfig.canRequestCompareFile; this.appOptions.canRequestMailMergeRecipients = this.editorConfig.canRequestMailMergeRecipients; this.appOptions.compatibleFeatures = (typeof (this.appOptions.customization) == 'object') && !!this.appOptions.customization.compatibleFeatures; + this.appOptions.canFeatureComparison = !!this.api.asc_isSupportFeature("comparison"); appHeader = this.getApplication().getController('Viewport').getView('Common.Views.Header'); appHeader.setCanBack(this.appOptions.canBackToFolder === true, (this.appOptions.canBackToFolder) ? this.editorConfig.customization.goback.text : '')