From 82ba32c2ecb131501ea4df73dca1c3bc42a6b538 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 26 Jul 2022 15:04:14 +0300 Subject: [PATCH] [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",