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