From 5c05508dcff669cb55c4928f9ccb87cb5efb4a47 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 11 Oct 2019 15:12:59 +0300 Subject: [PATCH] [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 59985afe8..5782fb9f7 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 b8e90ebad..b8726a329 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 659b45025..ab0f5760c 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 5e5f4daaf..35069f1c9 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 c17bb472a..c29231e22 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 4b6a86242..bc08a9de5 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.",