From 398691700b8a02c1a933e4bce4151074f1ec39d2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 7 Jun 2022 17:43:17 +0300 Subject: [PATCH 1/8] [SSE] Update external data --- apps/api/documents/api.js | 13 ++++- apps/common/Gateway.js | 8 +++ .../main/app/controller/DocumentHolder.js | 54 +++++++++++++++++++ .../main/app/controller/Main.js | 1 + 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 274993c62..ed3dc763b 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -23,6 +23,7 @@ options: , key: 'key', vkey: 'vkey', + referenceData: 'data for external paste', info: { owner: 'owner name', folder: 'path to document', @@ -262,6 +263,7 @@ 'onRequestCompareFile': ,// must call setRevisedFile method 'onRequestSharingSettings': ,// must call setSharingSettings method 'onRequestCreateNew': , + 'onRequestReferenceData': , } } @@ -325,6 +327,7 @@ _config.editorConfig.canRequestCompareFile = _config.events && !!_config.events.onRequestCompareFile; _config.editorConfig.canRequestSharingSettings = _config.events && !!_config.events.onRequestSharingSettings; _config.editorConfig.canRequestCreateNew = _config.events && !!_config.events.onRequestCreateNew; + _config.editorConfig.canRequestReferenceData = _config.events && !!_config.events.onRequestReferenceData; _config.frameEditorId = placeholderId; _config.parentOrigin = window.location.origin; @@ -731,6 +734,13 @@ }); }; + var _setReferenceData = function(data) { + _sendCommand({ + command: 'setReferenceData', + data: data + }); + }; + var _serviceCommand = function(command, data) { _sendCommand({ command: 'internalCommand', @@ -765,7 +775,8 @@ setFavorite : _setFavorite, requestClose : _requestClose, grabFocus : _grabFocus, - blurFocus : _blurFocus + blurFocus : _blurFocus, + setReferenceData : _setReferenceData } }; diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index 675a7421a..438ccce82 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -138,6 +138,10 @@ if (window.Common === undefined) { 'grabFocus': function(data) { $me.trigger('grabfocus', data); + }, + + 'setReferenceData': function(data) { + $me.trigger('setreferencedata', data); } }; @@ -347,6 +351,10 @@ if (window.Common === undefined) { _postMessage({event:'onRequestCreateNew'}); }, + requestReferenceData: function (data) { + _postMessage({event:'onRequestReferenceData', data: data}); + }, + pluginsReady: function() { _postMessage({ event: 'onPluginsReady' }); }, diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index e02a0297d..89c35715f 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -119,6 +119,11 @@ define([ me._state = {wsLock: false, wsProps: []}; me.fastcoauthtips = []; me._TtHeight = 20; + me.externalData = { + stackRequests: [], + stackResponse: [], + callback: undefined + }; /** coauthoring begin **/ this.wrapEvents = { apiHideComment: _.bind(this.onApiHideComment, this) @@ -369,6 +374,10 @@ define([ this.api.asc_registerCallback('asc_onShowPivotGroupDialog', _.bind(this.onShowPivotGroupDialog, this)); if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle) this.api.asc_registerCallback('asc_doubleClickOnTableOleObject', _.bind(this.onDoubleClickOnTableOleObject, this)); + if (this.permissions.canRequestReferenceData) { + this.api.asc_registerCallback('asc_onRefreshExternalData', _.bind(this.onRefreshExternalData, this)); + Common.Gateway.on('setreferencedata', _.bind(this.setReferenceData, this)); + } } this.api.asc_registerCallback('asc_onShowForeignCursorLabel', _.bind(this.onShowForeignCursorLabel, this)); this.api.asc_registerCallback('asc_onHideForeignCursorLabel', _.bind(this.onHideForeignCursorLabel, this)); @@ -4082,6 +4091,51 @@ define([ } }, + onRefreshExternalData: function(arr, callback) { + if (this.permissions.isEdit && !this._isDisabled) { + var me = this; + me.externalData = { + stackRequests: [], + stackResponse: [], + callback: undefined + }; + arr && arr.length>0 && arr.forEach(function(item) { + var data = {}; + switch (item.type) { + case Asc.externalReferenceType.link: + data['link'] = item.data; + break; + case Asc.externalReferenceType.path: + data['path'] = item.data; + break; + case Asc.externalReferenceType.referenceData: + data['referenceData'] = item.data; + break; + } + me.externalData.stackRequests.push(data); + }); + me.externalData.callback = callback; + me.requestReferenceData(); + } + }, + + requestReferenceData: function() { + if (this.externalData.stackRequests.length>0) { + var data = this.externalData.stackRequests.shift(); + Common.Gateway.requestReferenceData(data); + } + }, + + setReferenceData: function(data) { + if (this.permissions.isEdit && !this._isDisabled) { + data && this.externalData.stackResponse.push(data); + if (this.externalData.stackRequests.length>0) + this.requestReferenceData(); + else if (this.externalData.callback) + this.externalData.callback(this.externalData.stackResponse); + } + }, + getUserName: function(id){ var usersStore = SSE.getCollection('Common.Collections.Users'); if (usersStore){ diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 275aa3f6c..ea94868e4 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -505,6 +505,7 @@ define([ docInfo.put_EncryptedInfo(this.editorConfig.encryptionKeys); docInfo.put_Lang(this.editorConfig.lang); docInfo.put_Mode(this.editorConfig.mode); + docInfo.put_ReferenceData(data.doc.referenceData); var coEditMode = !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer From 5c4242f454355cea3b9c156ae050a03d3934d9db Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 7 Jun 2022 23:29:14 +0300 Subject: [PATCH 2/8] [SSE] Handle external data event --- .../main/app/controller/DocumentHolder.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 89c35715f..f7a7bdd70 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -375,7 +375,7 @@ define([ if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle) this.api.asc_registerCallback('asc_doubleClickOnTableOleObject', _.bind(this.onDoubleClickOnTableOleObject, this)); if (this.permissions.canRequestReferenceData) { - this.api.asc_registerCallback('asc_onRefreshExternalData', _.bind(this.onRefreshExternalData, this)); + this.api.asc_registerCallback('asc_onUpdateExternalReference', _.bind(this.onUpdateExternalReference, this)); Common.Gateway.on('setreferencedata', _.bind(this.setReferenceData, this)); } } @@ -4091,7 +4091,7 @@ define([ } }, - onRefreshExternalData: function(arr, callback) { + onUpdateExternalReference: function(arr, callback) { if (this.permissions.isEdit && !this._isDisabled) { var me = this; me.externalData = { @@ -4101,15 +4101,15 @@ define([ }; arr && arr.length>0 && arr.forEach(function(item) { var data = {}; - switch (item.type) { - case Asc.externalReferenceType.link: - data['link'] = item.data; + switch (item.asc_getType()) { + case Asc.c_oAscExternalReferenceType.link: + data['link'] = item.asc_getData(); break; - case Asc.externalReferenceType.path: - data['path'] = item.data; + case Asc.c_oAscExternalReferenceType.path: + data['path'] = item.asc_getData(); break; - case Asc.externalReferenceType.referenceData: - data['referenceData'] = item.data; + case Asc.c_oAscExternalReferenceType.referenceData: + data['referenceData'] = item.asc_getData(); break; } me.externalData.stackRequests.push(data); From a10d56616268e4d1cbad3a5eb274ffdf1e3c2609 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 7 Jun 2022 23:59:50 +0300 Subject: [PATCH 3/8] Fix bug --- apps/spreadsheeteditor/main/app/controller/Main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index ea94868e4..e880b93ef 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -414,6 +414,7 @@ define([ this.appOptions.canMakeActionLink = this.editorConfig.canMakeActionLink; this.appOptions.canFeaturePivot = true; this.appOptions.canFeatureViews = true; + this.appOptions.canRequestReferenceData = this.editorConfig.canRequestReferenceData; if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle) Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this)); From 4e5c30c46d53cecfc0052632424b2f0ed039c4a7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 8 Jun 2022 00:06:44 +0300 Subject: [PATCH 4/8] [SSE] Refactoring --- .../main/app/controller/DocumentHolder.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index f7a7bdd70..46e9d11bf 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -4100,19 +4100,19 @@ define([ callback: undefined }; arr && arr.length>0 && arr.forEach(function(item) { - var data = {}; + var data; switch (item.asc_getType()) { case Asc.c_oAscExternalReferenceType.link: - data['link'] = item.asc_getData(); + data = {link: item.asc_getData()}; break; case Asc.c_oAscExternalReferenceType.path: - data['path'] = item.asc_getData(); + data = {path: item.asc_getData()}; break; case Asc.c_oAscExternalReferenceType.referenceData: - data['referenceData'] = item.asc_getData(); + data = {referenceData: item.asc_getData()}; break; } - me.externalData.stackRequests.push(data); + data && me.externalData.stackRequests.push(data); }); me.externalData.callback = callback; me.requestReferenceData(); From 82ba32c2ecb131501ea4df73dca1c3bc42a6b538 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 26 Jul 2022 15:04:14 +0300 Subject: [PATCH 5/8] [SSE] Update external links --- .../main/app/controller/DataTab.js | 15 +- .../main/app/template/Toolbar.template | 4 + .../main/app/view/DataTab.js | 23 ++- .../main/app/view/ExternalLinksDlg.js | 172 ++++++++++++++++++ .../main/app/view/WatchDialog.js | 2 +- apps/spreadsheeteditor/main/locale/en.json | 7 + 6 files changed, 219 insertions(+), 4 deletions(-) create mode 100644 apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index de94aa22f..d1b023d43 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -45,6 +45,7 @@ define([ 'spreadsheeteditor/main/app/view/SortDialog', 'spreadsheeteditor/main/app/view/RemoveDuplicatesDialog', 'spreadsheeteditor/main/app/view/DataValidationDialog', + 'spreadsheeteditor/main/app/view/ExternalLinksDlg', 'common/main/lib/view/OptionsDialog' ], function () { 'use strict'; @@ -96,7 +97,8 @@ define([ 'data:sortcustom': this.onCustomSort, 'data:remduplicates': this.onRemoveDuplicates, 'data:datavalidation': this.onDataValidation, - 'data:fromtext': this.onDataFromText + 'data:fromtext': this.onDataFromText, + 'data:externallinks': this.onExternalLinks }, 'Statusbar': { 'sheet:changed': this.onApiSheetChanged @@ -429,6 +431,15 @@ define([ } }, + onExternalLinks: function() { + (new SSE.Views.ExternalLinksDlg({ + api: this.api, + handler: function(result) { + Common.NotificationCenter.trigger('edit:complete'); + } + })).show(); + }, + onWorksheetLocked: function(index,locked) { if (index == this.api.asc_getActiveWorksheetIndex()) { Common.Utils.lockControls(Common.enumLock.sheetLock, locked, {array: this.view.btnsSortDown.concat(this.view.btnsSortUp, this.view.btnCustomSort, this.view.btnGroup, this.view.btnUngroup)}); @@ -436,7 +447,7 @@ define([ }, onChangeProtectWorkbook: function() { - Common.Utils.lockControls(Common.enumLock.wbLock, this.api.asc_isProtectedWorkbook(), {array: [this.view.btnDataFromText]}); + Common.Utils.lockControls(Common.enumLock.wbLock, this.api.asc_isProtectedWorkbook(), {array: [this.view.btnDataFromText, this.view.btnExternalLinks]}); }, onApiSheetChanged: function() { diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index 67a8b615e..268050cf9 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -216,6 +216,10 @@
+
+ +
+
diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index c28e4ebce..01038b501 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -102,6 +102,11 @@ define([ me.btnCustomSort.on('click', function (b, e) { me.fireEvent('data:sortcustom'); }); + + me.btnExternalLinks.on('click', function (b, e) { + me.fireEvent('data:externallinks'); + }); + me.btnDataFromText.menu ? me.btnDataFromText.menu.on('item:click', function (menu, item, e) { me.fireEvent('data:fromtext', [item.value]); @@ -240,6 +245,19 @@ define([ }); this.lockedControls.push(this.btnCustomSort); + this.btnExternalLinks = new Common.UI.Button({ + parentEl: $host.find('#slot-btn-data-external-links'), + cls: 'btn-toolbar x-huge icon-top', + iconCls: 'toolbar__icon btn-import-data', + caption: this.capDataExternalLinks, + disabled: true, + lock: [_set.editCell, _set.sheetLock, _set.wbLock, _set.lostConnect, _set.coAuth, _set.wsLock], + dataHint: '1', + dataHintDirection: 'bottom', + dataHintOffset: 'small' + }); + this.lockedControls.push(this.btnExternalLinks); + this.btnsSortDown = Common.Utils.injectButtons($host.find('.slot-sortdesc'), '', 'toolbar__icon btn-sort-down', '', [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.cantModifyFilter, _set.sheetLock, _set.cantSort, _set['Sort']], undefined, undefined, undefined, '1', 'top', undefined, 'D'); @@ -301,6 +319,7 @@ define([ me.btnTextToColumns.updateHint(me.tipToColumns); me.btnRemoveDuplicates.updateHint(me.tipRemDuplicates); me.btnDataValidation.updateHint(me.tipDataValidation); + me.btnExternalLinks.updateHint(me.tipExternalLinks); me.btnsSortDown.forEach( function(btn) { btn.updateHint(me.toolbar.txtSortAZ); @@ -377,7 +396,9 @@ define([ capDataFromText: 'From Text/CSV', tipDataFromText: 'Get data from Text/CSV file', mniFromFile: 'Get Data from File', - mniFromUrl: 'Get Data from URL' + mniFromUrl: 'Get Data from URL', + capDataExternalLinks: 'External Links', + tipExternalLinks: 'View other files this spreadsheet is linked to' } }()), SSE.Views.DataTab || {})); }); diff --git a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js new file mode 100644 index 000000000..6493c53b4 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js @@ -0,0 +1,172 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2022 + * + * 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 + * +*/ +/** + * + * ExternalLinksDlg.js + * + * Created by Julia.Radzhabova on 26.07.22 + * Copyright (c) 2022 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'common/main/lib/view/AdvancedSettingsWindow', + 'common/main/lib/component/ListView' +], function () { + 'use strict'; + + SSE.Views = SSE.Views || {}; + + SSE.Views.ExternalLinksDlg = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + + options: { + alias: 'ExternalLinksDlg', + contentWidth: 400, + height: 294, + buttons: null + }, + + initialize: function (options) { + var me = this; + _.extend(this.options, { + title: this.txtTitle, + template: [ + '
', + '
', + '
', + '', + '', + '', + '', + '', + '', + '', + '
', + '', + '', + '
', + '', + '', + '
', + '
', + '
', + '
', + '' + ].join('') + }, options); + + this.api = options.api; + this.handler = options.handler; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + render: function () { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.linksList = new Common.UI.ListView({ + el: $('#external-links-list', this.$window), + store: new Common.UI.DataViewStore(), + simpleAddMode: true, + tabindex: 1 + }); + + this.btnUpdate = new Common.UI.Button({ + el: $('#external-links-btn-update', this.$window) + }); + this.btnUpdate.on('click', _.bind(this.onUpdate, this, false)); + + this.btnUpdateAll = new Common.UI.Button({ + el: $('#external-links-btn-update-all', this.$window) + }); + this.btnUpdateAll.on('click', _.bind(this.onUpdateAll, this, false)); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(); + }, + + getFocusedComponents: function() { + return [ this.btnUpdate, this.btnUpdateAll, this.linksList ]; + }, + + getDefaultFocusableComponent: function () { + return this.linksList; + }, + + _setDefaults: function (props) { + this.refreshList(); + }, + + refreshList: function() { + var arr = []; + var links = this.api.asc_getExternalReferences(); + if (links) { + for (var i=0; i0) && this.linksList.selectByIndex(0); + this.btnUpdate.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec()); + this.btnUpdateAll.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec()); + }, + + onUpdate: function() { + var rec = this.linksList.getSelectedRec(); + rec && this.api.asc_updateExternalReferences([rec.get('idx')]); + }, + + onUpdateAll: function() { + var arr = []; + this.linksList.store.each(function(item){ + arr.push(item.get('idx')); + }, this); + (arr.length>0) && this.api.asc_updateExternalReferences(arr); + }, + + txtTitle: 'External Links', + textUpdate: 'Update Values', + textUpdateAll: 'Update All', + textSource: 'Source', + closeButtonText: 'Close' + + }, SSE.Views.ExternalLinksDlg || {})); +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/WatchDialog.js b/apps/spreadsheeteditor/main/app/view/WatchDialog.js index 34cb911c1..c0da49764 100644 --- a/apps/spreadsheeteditor/main/app/view/WatchDialog.js +++ b/apps/spreadsheeteditor/main/app/view/WatchDialog.js @@ -32,7 +32,7 @@ */ /** * - * WatchDialogDialog.js + * WatchDialog.js * * Created by Julia.Radzhabova on 24.06.22 * Copyright (c) 2022 Ascensio System SIA. All rights reserved. diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 7cbbc188e..33bea3261 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1823,6 +1823,8 @@ "SSE.Views.DataTab.tipRemDuplicates": "Remove duplicate rows from a sheet", "SSE.Views.DataTab.tipToColumns": "Separate cell text into columns", "SSE.Views.DataTab.tipUngroup": "Ungroup range of cells", + "SSE.Views.DataTab.capDataExternalLinks": "External Links", + "SSE.Views.DataTab.tipExternalLinks": "View other files this spreadsheet is linked to", "SSE.Views.DataValidationDialog.errorFormula": "The value currently evaluates to an error. Do you want to continue?", "SSE.Views.DataValidationDialog.errorInvalid": "The value you entered for the field \"{0}\" is invalid.", "SSE.Views.DataValidationDialog.errorInvalidDate": "The date you entered for the field \"{0}\" is invalid.", @@ -2055,6 +2057,11 @@ "SSE.Views.DocumentHolder.txtWidth": "Width", "SSE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", "SSE.Views.DocumentHolder.txtGetLink": "Get link to this range", + "SSE.Views.ExternalLinksDlg.txtTitle": "External Links", + "SSE.Views.ExternalLinksDlg.textUpdate": "Update Values", + "SSE.Views.ExternalLinksDlg.textUpdateAll": "Update All", + "SSE.Views.ExternalLinksDlg.textSource": "Source", + "SSE.Views.ExternalLinksDlg.closeButtonText": "Close", "SSE.Views.FieldSettingsDialog.strLayout": "Layout", "SSE.Views.FieldSettingsDialog.strSubtotals": "Subtotals", "SSE.Views.FieldSettingsDialog.textReport": "Report Form", From 9b36d4274f888d5637e60a44ccfaf9dad5971806 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 30 Aug 2022 22:23:14 +0300 Subject: [PATCH 6/8] [SSE] Fix updating external references --- apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js index 6493c53b4..9ef84fa6e 100644 --- a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js @@ -139,7 +139,8 @@ define([ for (var i=0; i0) && this.api.asc_updateExternalReferences(arr); }, From 37a6d9568b91d9612dfdee0a1aa68ba3c62c5092 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 31 Aug 2022 23:31:17 +0300 Subject: [PATCH 7/8] [SSE] Update/Delete external links --- .../main/app/view/ExternalLinksDlg.js | 115 +++++++++++++++--- 1 file changed, 98 insertions(+), 17 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js index 9ef84fa6e..36d110f66 100644 --- a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js @@ -51,7 +51,7 @@ define([ options: { alias: 'ExternalLinksDlg', - contentWidth: 400, + contentWidth: 500, height: 294, buttons: null }, @@ -67,8 +67,10 @@ define([ '', '', '', '', '', @@ -104,14 +106,58 @@ define([ }); this.btnUpdate = new Common.UI.Button({ - el: $('#external-links-btn-update', this.$window) + parentEl: $('#external-links-btn-update', this.$window), + cls: 'btn-text-split-default auto', + caption: this.textUpdate, + split: true, + menu : new Common.UI.Menu({ + style: 'min-width:100px;', + items: [ + { + caption: this.textUpdate, + value: 0 + }, + { + caption: this.textUpdateAll, + value: 1 + }] + }) }); - this.btnUpdate.on('click', _.bind(this.onUpdate, this, false)); + $(this.btnUpdate.cmpEl.find('button')[0]).css('min-width', '87px'); + this.btnUpdate.on('click', _.bind(this.onUpdate, this)); + this.btnUpdate.menu.on('item:click', _.bind(this.onUpdateMenu, this)); - this.btnUpdateAll = new Common.UI.Button({ - el: $('#external-links-btn-update-all', this.$window) + this.btnDelete = new Common.UI.Button({ + parentEl: $('#external-links-btn-delete', this.$window), + cls: 'btn-text-split-default auto', + caption: this.textDelete, + split: true, + menu : new Common.UI.Menu({ + style: 'min-width:100px;', + items: [ + { + caption: this.textDelete, + value: 0 + }, + { + caption: this.textDeleteAll, + value: 1 + }] + }) }); - this.btnUpdateAll.on('click', _.bind(this.onUpdateAll, this, false)); + $(this.btnDelete.cmpEl.find('button')[0]).css('min-width', '87px'); + this.btnDelete.on('click', _.bind(this.onDelete, this)); + this.btnDelete.menu.on('item:click', _.bind(this.onDeleteMenu, this)); + + this.btnOpen = new Common.UI.Button({ + el: $('#external-links-btn-open', this.$window) + }); + this.btnOpen.on('click', _.bind(this.onOpen, this)); + + this.btnChange = new Common.UI.Button({ + el: $('#external-links-btn-change', this.$window) + }); + this.btnChange.on('click', _.bind(this.onChange, this)); this.afterRender(); }, @@ -121,7 +167,7 @@ define([ }, getFocusedComponents: function() { - return [ this.btnUpdate, this.btnUpdateAll, this.linksList ]; + return [ this.btnUpdate, this.btnDelete, this.btnOpen, this.btnChange, this.linksList ]; }, getDefaultFocusableComponent: function () { @@ -147,7 +193,9 @@ define([ this.linksList.store.reset(arr); (this.linksList.store.length>0) && this.linksList.selectByIndex(0); this.btnUpdate.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec()); - this.btnUpdateAll.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec()); + this.btnDelete.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec()); + this.btnOpen.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec()); + this.btnChange.setDisabled(this.linksList.store.length<1 || !this.linksList.getSelectedRec()); }, onUpdate: function() { @@ -155,19 +203,52 @@ define([ rec && this.api.asc_updateExternalReferences([rec.get('externalRef')]); }, - onUpdateAll: function() { - var arr = []; - this.linksList.store.each(function(item){ - arr.push(item.get('externalRef')); - }, this); - (arr.length>0) && this.api.asc_updateExternalReferences(arr); + onUpdateMenu: function(menu, item) { + if (item.value == 1) { + var arr = []; + this.linksList.store.each(function(item){ + arr.push(item.get('externalRef')); + }, this); + (arr.length>0) && this.api.asc_updateExternalReferences(arr); + } else + this.onUpdate(); + }, + + onDelete: function() { + var rec = this.linksList.getSelectedRec(); + rec && this.api.asc_removeExternalReferences([rec.get('externalRef')]); + this.refreshList(); + }, + + onDeleteMenu: function(menu, item) { + if (item.value == 1) { + var arr = []; + this.linksList.store.each(function(item){ + arr.push(item.get('externalRef')); + }, this); + (arr.length>0) && this.api.asc_removeExternalReferences(arr); + this.refreshList(); + } else + this.onDelete(); + }, + + onOpen: function() { + + }, + + onChange: function() { + }, txtTitle: 'External Links', textUpdate: 'Update Values', textUpdateAll: 'Update All', textSource: 'Source', - closeButtonText: 'Close' + closeButtonText: 'Close', + textDelete: 'Break Links', + textDeleteAll: 'Break All Links', + textOpen: 'Open Source', + textChange: 'Change Source' }, SSE.Views.ExternalLinksDlg || {})); }); \ No newline at end of file From b19aca6235175cafaa1736953f6b5b6bd93c4c5c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 6 Oct 2022 12:58:39 +0300 Subject: [PATCH 8/8] Refactoring --- apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js | 6 +++--- apps/spreadsheeteditor/main/locale/en.json | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js index 36d110f66..41c7b68b7 100644 --- a/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ExternalLinksDlg.js @@ -51,7 +51,7 @@ define([ options: { alias: 'ExternalLinksDlg', - contentWidth: 500, + contentWidth: 450, height: 294, buttons: null }, @@ -69,8 +69,8 @@ define([ '', '', '', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 33bea3261..2be711ab3 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2062,6 +2062,8 @@ "SSE.Views.ExternalLinksDlg.textUpdateAll": "Update All", "SSE.Views.ExternalLinksDlg.textSource": "Source", "SSE.Views.ExternalLinksDlg.closeButtonText": "Close", + "SSE.Views.ExternalLinksDlg.textDelete": "Break Links", + "SSE.Views.ExternalLinksDlg.textDeleteAll": "Break All Links", "SSE.Views.FieldSettingsDialog.strLayout": "Layout", "SSE.Views.FieldSettingsDialog.strSubtotals": "Subtotals", "SSE.Views.FieldSettingsDialog.textReport": "Report Form",
', - '', - '', + '', + '', + '', + '', '
', '', '', - '', - '', + // '', + // '', '