From 952d4347ab5a1e94ba9d88e38bbda08c0f9ea402 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 4 Mar 2020 10:28:12 +0300 Subject: [PATCH 01/12] [SSE] Add hyperlink to named ranges --- .../main/app/controller/DocumentHolder.js | 3 +- .../main/app/controller/Toolbar.js | 3 +- .../main/app/view/HyperlinkSettingsDialog.js | 123 ++++++++++++++---- apps/spreadsheeteditor/main/locale/en.json | 2 +- .../main/resources/less/app.less | 1 + 5 files changed, 103 insertions(+), 29 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index c62edcc75..82cd8e62b 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -512,7 +512,7 @@ define([ while (++i < wc) { if (!this.api.asc_isWorksheetHidden(i)) { - items.push({displayValue: me.api.asc_getWorksheetName(i), value: me.api.asc_getWorksheetName(i)}); + items.push(me.api.asc_getWorksheetName(i)); } } @@ -536,6 +536,7 @@ define([ win.show(); win.setSettings({ sheets : items, + ranges : me.api.asc_getDefinedNames(Asc.c_oAscGetDefinedNamesList.All), currentSheet: me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()), props : props, text : cell.asc_getText(), diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index e49aed615..b70ded600 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -881,7 +881,7 @@ define([ while (++i < wc) { if (!this.api.asc_isWorksheetHidden(i)) { - items.push({displayValue: me.api.asc_getWorksheetName(i), value: me.api.asc_getWorksheetName(i)}); + items.push(me.api.asc_getWorksheetName(i)); } } @@ -905,6 +905,7 @@ define([ win.show(); win.setSettings({ sheets : items, + ranges : me.api.asc_getDefinedNames(Asc.c_oAscGetDefinedNamesList.All), currentSheet: me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()), props : props, text : cell.asc_getText(), diff --git a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js index 7e8b4b140..ff1ad9e0a 100644 --- a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js @@ -46,7 +46,8 @@ define([ 'common/main/lib/util/utils', 'common/main/lib/component/ComboBox', 'common/main/lib/component/InputField', - 'common/main/lib/component/Window' + 'common/main/lib/component/Window', + 'common/main/lib/component/TreeView' ], function () { 'use strict'; SSE.Views.HyperlinkSettingsDialog = Common.UI.Window.extend(_.extend({ @@ -63,7 +64,7 @@ define([ }, options || {}); this.template = [ - '
', + '
', '
', '', '', @@ -76,13 +77,10 @@ define([ '
', '', '
', '', @@ -124,13 +122,6 @@ define([ }); me.btnInternal.on('click', _.bind(me.onLinkTypeClick, me, Asc.c_oAscHyperlinkType.RangeLink)); - me.cmbSheets = new Common.UI.ComboBox({ - el : $('#id-dlg-hyperlink-sheet'), - cls : 'input-group-nr', - editable: false, - menuStyle: 'min-width: 100%;max-height: 150px;' - }); - me.inputUrl = new Common.UI.InputField({ el : $('#id-dlg-hyperlink-url'), allowBlank : false, @@ -175,8 +166,19 @@ define([ maxLength : Asc.c_oAscMaxTooltipLength }); - $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); + me.internalList = new Common.UI.TreeView({ + el: $('#id-dlg-hyperlink-list'), + store: new Common.UI.TreeViewStore(), + enableKeyEvents: true + }); + me.internalList.on('item:select', _.bind(this.onSelectItem, this)); + me.btnOk = new Common.UI.Button({ + el: $window.find('.primary') + }); + + $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); + me.internalList.on('entervalue', _.bind(me.onPrimary, me)); me.externalPanel = $window.find('#id-external-link'); me.internalPanel = $window.find('#id-internal-link'); }, @@ -193,32 +195,32 @@ define([ setSettings: function(settings) { if (settings) { var me = this; + me.settings = settings; - this.cmbSheets.setData(settings.sheets); var type = (settings.props) ? settings.props.asc_getType() : Asc.c_oAscHyperlinkType.WebLink; (type == Asc.c_oAscHyperlinkType.WebLink) ? me.btnExternal.toggle(true) : me.btnInternal.toggle(true); me.ShowHideElem(type); me.btnInternal.setDisabled(!settings.allowInternal && (type == Asc.c_oAscHyperlinkType.WebLink)); me.btnExternal.setDisabled(!settings.allowInternal && (type == Asc.c_oAscHyperlinkType.RangeLink)); + var sheet = settings.currentSheet; if (!settings.props) { this.inputDisplay.setValue(settings.isLock ? this.textDefault : settings.text); this.focusedInput = this.inputUrl.cmpEl.find('input'); - this.cmbSheets.setValue(settings.currentSheet); } else { if (type == Asc.c_oAscHyperlinkType.RangeLink) { - this.cmbSheets.setValue(settings.props.asc_getSheet()); + sheet = settings.props.asc_getSheet(); this.inputRange.setValue(settings.props.asc_getRange()); this.focusedInput = this.inputRange.cmpEl.find('input'); } else { this.inputUrl.setValue(settings.props.asc_getHyperlinkUrl().replace(new RegExp(" ",'g'), "%20")); this.focusedInput = this.inputUrl.cmpEl.find('input'); - this.cmbSheets.setValue(settings.currentSheet); } this.inputDisplay.setValue(settings.isLock ? this.textDefault : settings.props.asc_getText()); this.inputTip.setValue(settings.props.asc_getTooltip()); } - + var rec = this.internalList.store.findWhere({name: sheet }); + rec && this.internalList.scrollToRecord(this.internalList.selectRecord(rec)); this.inputDisplay.setDisabled(settings.isLock); } }, @@ -229,9 +231,12 @@ define([ props.asc_setType(this.btnInternal.isActive() ? Asc.c_oAscHyperlinkType.RangeLink : Asc.c_oAscHyperlinkType.WebLink); if (this.btnInternal.isActive()) { - props.asc_setSheet(this.cmbSheets.getValue()); - props.asc_setRange(this.inputRange.getValue()); - def_display = this.cmbSheets.getValue() + '!' + this.inputRange.getValue(); + var rec = this.internalList.getSelectedRec(); + if (rec) { + props.asc_setSheet(rec.get('name')); + props.asc_setRange(this.inputRange.getValue()); + def_display = rec.get('name') + '!' + this.inputRange.getValue(); + } } else { var url = this.inputUrl.getValue().replace(/^\s+|\s+$/g,''); if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) @@ -292,14 +297,78 @@ define([ ShowHideElem: function(value) { this.externalPanel.toggleClass('hidden', value !== Asc.c_oAscHyperlinkType.WebLink); this.internalPanel.toggleClass('hidden', value !== Asc.c_oAscHyperlinkType.RangeLink); + var store = this.internalList.store; + if (value==Asc.c_oAscHyperlinkType.RangeLink) { + if (store.length<1 && this.settings) { + var sheets = this.settings.sheets, + count = sheets.length, + arr = []; + arr.push(new Common.UI.TreeViewModel({ + name : this.textSheets, + level: 0, + index: 0, + hasParent: false, + isEmptyItem: false, + isNotHeader: true, + hasSubItems: true + })); + for (var i=0; i Date: Wed, 4 Mar 2020 14:45:42 +0300 Subject: [PATCH 02/12] [DE][SSE] Change hyperlink settings: disable Ok button when no url or data range --- .../main/app/view/HyperlinkSettingsDialog.js | 15 +++++++++++---- .../main/app/view/HyperlinkSettingsDialog.js | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js index 0d7f8c0c2..680f99917 100644 --- a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js @@ -67,19 +67,22 @@ define([ }, options || {}); this.template = [ - '
', + '
', '
', '', '', '
', '', '', '
', '', @@ -134,6 +137,9 @@ define([ return (urltype>0) ? true : me.txtNotUrl; } }); + me.inputUrl._input.on('input', function (e) { + me.btnOk.setDisabled($.trim($(e.target).val())==''); + }); me.inputDisplay = new Common.UI.InputField({ el : $('#id-dlg-hyperlink-display'), @@ -247,12 +253,13 @@ define([ } } store.reset(arr); + this.internalList.collapseAll(); } var rec = this.internalList.getSelectedRec(); this.btnOk.setDisabled(!rec || rec.get('level')==0 && rec.get('index')>0); } else - this.btnOk.setDisabled(false); + this.btnOk.setDisabled($.trim(this.inputUrl.getValue())==''); }, onLinkTypeClick: function(type, btn, event) { diff --git a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js index ff1ad9e0a..3dc4764a5 100644 --- a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js @@ -71,13 +71,13 @@ define([ '
', '', '