[SSE] Update external links

This commit is contained in:
Julia Radzhabova 2022-07-26 15:04:14 +03:00
parent d440ec5872
commit 82ba32c2ec
6 changed files with 219 additions and 4 deletions

View file

@ -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() {

View file

@ -216,6 +216,10 @@
<span class="btn-slot text x-huge" id="slot-btn-data-from-text"></span>
</div>
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-data-external-links"></span>
</div>
<div class="separator long"></div>
<div class="group">
<div class="elset">
<span class="btn-slot split slot-btn-setfilter"></span>

View file

@ -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 || {}));
});

View file

@ -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: [
'<div class="box" style="height:' + (me.options.height - 85) + 'px;">',
'<div class="content-panel" style="padding: 0;"><div class="inner-content">',
'<div class="settings-panel active">',
'<table cols="1" style="width: 100%;">',
'<tr>',
'<td class="padding-large">',
'<button type="button" class="btn btn-text-default auto sort-dialog-btn-text" id="external-links-btn-update">', me.textUpdate ,'</button>',
'<button type="button" class="btn btn-text-default auto sort-dialog-btn-text" id="external-links-btn-update-all">', me.textUpdateAll ,'</button>',
'</td>',
'</tr>',
'<tr>',
'<td class="padding-small">',
'<label class="header">', me.textSource,'</label>',
'<div id="external-links-list" class="range-tableview" style="width:100%; height: 148px;"></div>',
'</td>',
'</tr>',
'</table>',
'</div></div>',
'</div>',
'</div>',
'<div class="footer center">',
'<button class="btn normal dlg-btn" result="cancel" style="width: 86px;">' + this.closeButtonText + '</button>',
'</div>'
].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; i<links.length; i++) {
arr.push({
value: links[i].asc_getSource(),
idx: i
});
}
}
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());
},
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 || {}));
});

View file

@ -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.

View file

@ -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",