From 54c8d379accf4ed8ea8308924837dc78b22fd4e0 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 12 Jan 2017 17:09:15 +0300 Subject: [PATCH 01/16] [Common] ComboBox: use itemsTemplate for custom dropdown menu. --- apps/common/main/lib/component/ComboBox.js | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index 24e147e2f..ce988c852 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -112,6 +112,7 @@ define([ this.menuCls = me.options.menuCls; this.menuStyle = me.options.menuStyle; this.template = me.options.template || me.template; + this.itemsTemplate = me.options.itemsTemplate; this.hint = me.options.hint; this.editable = me.options.editable; this.disabled = me.options.disabled; @@ -134,15 +135,22 @@ define([ var me = this; if (!me.rendered) { + var items = this.store.toJSON(); this.cmpEl = $(this.template({ id : this.id, cls : this.cls, style : this.style, menuCls : this.menuCls, menuStyle : this.menuStyle, - items : this.store.toJSON(), + items : items, scope : me })); + if (this.itemsTemplate) + this.cmpEl.find('ul').append( + $(this.itemsTemplate({ + items : items, + scope : me + }))); if (parentEl) { this.setElement(parentEl, false); @@ -441,7 +449,7 @@ define([ return this.rendered ? this._input.val() : null; }, - setValue: function(value) { + setValue: function(value, defValue) { if (!this.rendered) return; @@ -454,7 +462,7 @@ define([ this.setRawValue(this._selectedItem.get(this.displayField)); $('#' + this._selectedItem.get('id'), $(this.el)).addClass('selected'); } else { - this.setRawValue(value); + this.setRawValue((defValue!==undefined) ? defValue : value); } }, @@ -529,14 +537,21 @@ define([ }, onResetItems: function() { - $(this.el).find('ul').html(_.template([ - '<% _.each(items, function(item) { %>', - '
  • <%= scope.getDisplayValue(item) %>
  • ', - '<% }); %>' - ].join(''), { - items: this.store.toJSON(), - scope: this - })); + if (this.itemsTemplate) { + $(this.el).find('ul').html( $(this.itemsTemplate({ + items: this.store.toJSON(), + scope: this + }))); + } else { + $(this.el).find('ul').html(_.template([ + '<% _.each(items, function(item) { %>', + '
  • <%= scope.getDisplayValue(item) %>
  • ', + '<% }); %>' + ].join(''), { + items: this.store.toJSON(), + scope: this + })); + } if (!_.isUndefined(this.scroller)) { this.scroller.destroy(); From 56fbd1e08507e6e1c0a68e72897ff1271d49442b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 12 Jan 2017 17:14:51 +0300 Subject: [PATCH 02/16] [SSE] Change control for Number Format. --- .../main/app/controller/Toolbar.js | 52 ++- .../main/app/template/Toolbar.template | 6 +- .../main/app/view/Toolbar.js | 401 +++++++++--------- 3 files changed, 245 insertions(+), 214 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 869f4c620..ccc4d6c24 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -101,7 +101,9 @@ define([ namedrange_locked: false, fontsize: undefined, multiselect: false, - sparklines_disabled: false + sparklines_disabled: false, + numformattype: undefined, + langId: 0x0409 }; var checkInsertAutoshape = function(e, action) { @@ -252,19 +254,14 @@ define([ if (toolbar.mnuZoomOut) toolbar.mnuZoomOut.on('click', _.bind(this.onZoomOutClick, this)); if (toolbar.btnShowMode.rendered) toolbar.btnShowMode.menu.on('item:click', _.bind(this.onHideMenu, this)); toolbar.listStyles.on('click', _.bind(this.onListStyleSelect, this)); - if (toolbar.btnNumberFormat.rendered) toolbar.btnNumberFormat.menu.on('item:click', _.bind(this.onNumberFormatMenu, this)); + toolbar.cmbNumberFormat.on('selected', _.bind(this.onNumberFormatSelect, this)); + toolbar.cmbNumberFormat.on('show:before', _.bind(this.onNumberFormatOpenBefore, this, true)); toolbar.btnCurrencyStyle.menu.on('item:click', _.bind(this.onNumberFormatMenu, this)); if (toolbar.mnuitemCompactToolbar) toolbar.mnuitemCompactToolbar.on('toggle', _.bind(this.onChangeViewMode, this)); $('#id-toolbar-menu-new-fontcolor').on('click', _.bind(this.onNewTextColor, this)); $('#id-toolbar-menu-new-paracolor').on('click', _.bind(this.onNewBackColor, this)); $('#id-toolbar-menu-new-bordercolor').on('click', _.bind(this.onNewBorderColor, this)); - _.each(toolbar.btnNumberFormat.menu.items, function(item) { - if (item.menu) { - item.menu.on('item:click', _.bind(me.onNumberFormatMenu, me)); - } - }); - this.onSetupCopyStyleButton(); }, @@ -885,6 +882,26 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Number Format'); }, + onNumberFormatSelect: function(combo, record) { + if (this.api) + this.api.asc_setCellFormat(record.format); + + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + Common.component.Analytics.trackEvent('ToolBar', 'Number Format'); + }, + + onNumberFormatOpenBefore: function(combo) { + if (this.api) { + var me = this, + info = me.api.asc_getCellInfo(); + me.toolbar.numFormatData.forEach( function(item, index) { + item.exampleval = me.api.asc_getLocaleExample2(item.format, info.asc_getText(), me._state.langId); + }); + me.toolbar.cmbNumberFormat.setData(me.toolbar.numFormatData); + me.toolbar.cmbNumberFormat.setValue(me._state.numformattype, me.toolbar.txtCustom); + } + }, + onDecrement: function(btn) { if (this.api) this.api.asc_decreaseCellDigitNumbers(); @@ -1459,7 +1476,7 @@ define([ var toolbar = this.toolbar; if (toolbar.mode.isEditDiagram || toolbar.mode.isEditMailMerge) { is_cell_edited = (state == Asc.c_oAscCellEditorState.editStart); - toolbar.lockToolbar(SSE.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, {array: [toolbar.btnDecDecimal,toolbar.btnIncDecimal,toolbar.btnNumberFormat]}); + toolbar.lockToolbar(SSE.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, {array: [toolbar.btnDecDecimal,toolbar.btnIncDecimal,toolbar.cmbNumberFormat]}); } else if (state == Asc.c_oAscCellEditorState.editStart || state == Asc.c_oAscCellEditorState.editEnd) { toolbar.lockToolbar(SSE.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, { @@ -1871,12 +1888,11 @@ define([ toolbar.lockToolbar(SSE.enumLock.multiselect, this._state.multiselect, { array: [toolbar.btnTableTemplate, toolbar.btnInsertHyperlink]}); } - fontparam = toolbar.numFormatTypes[info.asc_getNumFormatType()]; - - if (!fontparam) - fontparam = toolbar.numFormatTypes[1]; - - toolbar.btnNumberFormat.setCaption(fontparam); + val = info.asc_getNumFormatType(); + if (this._state.numformattype !== val) { + toolbar.cmbNumberFormat.setValue(val, toolbar.txtCustom); + this._state.numformattype = val; + } val = info.asc_getAngle(); if (this._state.angle !== val) { @@ -2544,6 +2560,12 @@ define([ for (var i=0; i - +
    @@ -124,7 +124,7 @@
    - +
    @@ -249,7 +249,7 @@
    - +
    diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 79ec7f70c..420a5ced0 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -124,19 +124,18 @@ define([ Text : '@' }; - me.numFormatTypes = {}; - me.numFormatTypes[Asc.c_oAscNumFormatType.General] = me.txtGeneral; - me.numFormatTypes[Asc.c_oAscNumFormatType.Custom] = me.txtCustom; - me.numFormatTypes[Asc.c_oAscNumFormatType.Text] = me.txtText; - me.numFormatTypes[Asc.c_oAscNumFormatType.Number] = me.txtNumber; - me.numFormatTypes[Asc.c_oAscNumFormatType.Integer] = me.txtInteger; - me.numFormatTypes[Asc.c_oAscNumFormatType.Scientific] = me.txtScientific; - me.numFormatTypes[Asc.c_oAscNumFormatType.Currency] = me.txtCurrency; - me.numFormatTypes[Asc.c_oAscNumFormatType.Accounting] = me.txtAccounting; - me.numFormatTypes[Asc.c_oAscNumFormatType.Date] = me.txtDate; - me.numFormatTypes[Asc.c_oAscNumFormatType.Time] = me.txtTime; - me.numFormatTypes[Asc.c_oAscNumFormatType.Percent] = me.txtPercentage; - me.numFormatTypes[Asc.c_oAscNumFormatType.Fraction] = me.txtFraction; + me.numFormatData = [ + { value: Asc.c_oAscNumFormatType.General, format: this.ascFormatOptions.General, displayValue: this.txtGeneral, exampleval: '100' }, + { value: Asc.c_oAscNumFormatType.Number, format: this.ascFormatOptions.Number, displayValue: this.txtNumber, exampleval: '100,00' }, + { value: Asc.c_oAscNumFormatType.Scientific,format: this.ascFormatOptions.Scientific, displayValue: this.txtScientific, exampleval: '1,00E+02' }, + { value: Asc.c_oAscNumFormatType.Accounting,format: this.ascFormatOptions.Accounting, displayValue: this.txtAccounting, exampleval: '100,00 $' }, + { value: Asc.c_oAscNumFormatType.Currency, format: this.ascFormatOptions.Currency, displayValue: this.txtCurrency, exampleval: '100,00 $' }, + { value: Asc.c_oAscNumFormatType.Date, format: 'MM-dd-yyyy', displayValue: this.txtDate, exampleval: '04-09-1900' }, + { value: Asc.c_oAscNumFormatType.Time, format: 'HH:MM:ss', displayValue: this.txtTime, exampleval: '00:00:00' }, + { value: Asc.c_oAscNumFormatType.Percent, format: this.ascFormatOptions.Percentage, displayValue: this.txtPercentage, exampleval: '100,00%' }, + { value: Asc.c_oAscNumFormatType.Fraction, format: this.ascFormatOptions.Fraction, displayValue: this.txtFraction, exampleval: '100' }, + { value: Asc.c_oAscNumFormatType.Text, format: this.ascFormatOptions.Text, displayValue: this.txtText, exampleval: '100' } + ]; function dummyCmp() { return { @@ -651,13 +650,24 @@ define([ } }); - me.btnNumberFormat = new Common.UI.Button({ - id : 'id-toolbar-btn-num-format', - cls : 'btn-toolbar btn-text-value', - caption : me.txtGeneral, - style : 'width: 100%;', + var formatTemplate = + _.template([ + '<% _.each(items, function(item) { %>', + '
  • ', + '
    <%= scope.getDisplayValue(item) %>
    ', + '
    <%= item.exampleval ? item.exampleval : "" %>
    ', + '
  • ', + '<% }); %>' + ].join('')); + + me.cmbNumberFormat = new Common.UI.ComboBox({ + cls : 'input-group-nr', + menuStyle : 'min-width: 180px;', + hint : me.tipNumFormat, lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRange, _set.lostConnect, _set.coAuth], - menu : true + itemsTemplate: formatTemplate, + editable : false, + data : me.numFormatData }); me.btnPercentStyle = new Common.UI.Button({ @@ -1080,7 +1090,7 @@ define([ me.btnMerge, me.btnInsertFormula, me.btnNamedRange, me.btnIncDecimal, me.btnInsertShape, me.btnInsertEquation, me.btnInsertText, me.btnSortUp, me.btnSortDown, me.btnSetAutofilter, me.btnClearAutofilter, me.btnTableTemplate, me.btnPercentStyle, me.btnCurrencyStyle, me.btnDecDecimal, me.btnAddCell, me.btnDeleteCell, - me.btnNumberFormat, me.btnBorders, me.btnInsertImage, me.btnInsertHyperlink, + me.cmbNumberFormat, me.btnBorders, me.btnInsertImage, me.btnInsertHyperlink, me.btnInsertChart, me.btnColorSchemas, me.btnAutofilter, me.btnCopy, me.btnPaste, me.btnSettings, me.listStyles, me.btnPrint, me.btnShowMode, /*me.btnSave, */me.btnClearStyle, me.btnCopyStyle @@ -1097,7 +1107,7 @@ define([ me.btnInsertImage, me.btnInsertText, me.btnInsertShape, me.btnInsertEquation, me.btnIncFontSize, me.btnDecFontSize, me.btnBold, me.btnItalic, me.btnUnderline, me.btnTextColor, me.btnBackColor, me.btnInsertHyperlink, me.btnBorders, me.btnTextOrient, me.btnPercentStyle, me.btnCurrencyStyle, me.btnColorSchemas, - me.btnSettings, me.btnInsertFormula, me.btnNamedRange, me.btnDecDecimal, me.btnIncDecimal, me.btnNumberFormat, me.btnWrap, + me.btnSettings, me.btnInsertFormula, me.btnNamedRange, me.btnDecDecimal, me.btnIncDecimal, me.cmbNumberFormat, me.btnWrap, me.btnInsertChart, me.btnMerge, me.btnAddCell, me.btnDeleteCell, me.btnShowMode, me.btnPrint, me.btnAutofilter, me.btnSortUp, me.btnSortDown, me.btnTableTemplate, me.btnSetAutofilter, me.btnClearAutofilter, me.btnSave, me.btnClearStyle, me.btnCopyStyle, me.btnCopy, me.btnPaste]; @@ -1229,7 +1239,7 @@ define([ replacePlacholder('#id-toolbar-' + mode + '-placeholder-btn-setfilter', this.btnSetAutofilter); replacePlacholder('#id-toolbar-' + mode + '-placeholder-btn-clear-filter', this.btnClearAutofilter); replacePlacholder('#id-toolbar-' + mode + '-placeholder-btn-table-tpl', this.btnTableTemplate); - replacePlacholder('#id-toolbar-' + mode + '-placeholder-btn-format', this.btnNumberFormat); + replacePlacholder('#id-toolbar-' + mode + '-placeholder-btn-format', this.cmbNumberFormat); replacePlacholder('#id-toolbar-' + mode + '-placeholder-btn-percents', this.btnPercentStyle); replacePlacholder('#id-toolbar-' + mode + '-placeholder-btn-currency', this.btnCurrencyStyle); replacePlacholder('#id-toolbar-' + mode + '-placeholder-btn-digit-dec', this.btnDecDecimal); @@ -1295,7 +1305,6 @@ define([ this.btnClearAutofilter.updateHint(this.txtClearFilter); this.btnSearch.updateHint(this.txtSearch); this.btnTableTemplate.updateHint(this.txtTableTemplate); - this.btnNumberFormat.updateHint(this.tipNumFormat); this.btnPercentStyle.updateHint(this.tipDigStylePercent); this.btnCurrencyStyle.updateHint(this.tipDigStyleAccounting); this.btnDecDecimal.updateHint(this.tipDecDecimal); @@ -1520,179 +1529,179 @@ define([ }); } - var formatTemplate = _.template('<%= caption %><%= options.tplval ? options.tplval : options.value %>'); - this.btnNumberFormat.setMenu( new Common.UI.Menu({ - style: 'margin-left: -1px;', - items: [ - { - caption : this.txtGeneral, - value : this.ascFormatOptions.General - }, - { - caption : this.txtNumber, - value : this.ascFormatOptions.Number - }, - { - caption : this.txtInteger, - value : '#0' - }, - { - caption : this.txtScientific, - value : this.ascFormatOptions.Scientific - }, - { - caption : this.txtAccounting, - menu : new Common.UI.Menu({ - style: 'min-width: 120px;', - menuAlign: 'tl-tr', - items : [ - { - caption : this.txtDollar, - value : this.ascFormatOptions.Accounting - }, - { - caption : this.txtEuro, - value : '_(€* #,##0.00_);_(€* (#,##0.00);_(€* "-"??_);_(@_)' - }, - { - caption : this.txtPound, - value : '_(£* #,##0.00_);_(£* (#,##0.00);_(£* "-"??_);_(@_)' - }, - { - caption : this.txtRouble, - value : '_-* #,##0.00[$р.-419]_-;-* #,##0.00[$р.-419]_-;_-* "-"??[$р.-419]_-;_-@_-' - }, - { - caption : this.txtYen, - value : '_(¥* #,##0.00_);_(¥* (#,##0.00);_(¥* "-"??_);_(@_)' - } - ] - }) - }, - { - caption : this.txtCurrency, - menu : new Common.UI.Menu({ - style: 'min-width: 120px;', - menuAlign: 'tl-tr', - items : [ - { - caption : this.txtDollar, - value : this.ascFormatOptions.Currency - }, - { - caption : this.txtEuro, - value : '€#,##0.00' - }, - { - caption : this.txtPound, - value : '£#,##0.00' - }, - { - caption : this.txtRouble, - value : '#,##0.00"р."' - }, - { - caption : this.txtYen, - value : '¥#,##0.00' - } - ] - }) - }, - { - caption : this.txtDate, - menu : new Common.UI.Menu({ - style: 'min-width: 200px;', - menuAlign: 'tl-tr', - items: [ - { - caption : '07-24-88', - value : 'MM-dd-yy', - template: formatTemplate - }, - { - caption : '07-24-1988', - value : 'MM-dd-yyyy', - template: formatTemplate - }, - { - caption : '24-07-88', - value : 'dd-MM-yy', - template: formatTemplate - }, - { - caption : '24-07-1988', - value : 'dd-MM-yyyy', - template: formatTemplate - }, - { - caption : '24-Jul-1988', - value : 'dd-MMM-yyyy', - template: formatTemplate - }, - { - caption : '24-Jul', - value : 'dd-MMM', - template: formatTemplate - }, - { - caption : 'Jul-88', - value : 'MMM-yy', - template: formatTemplate - } - ] - }) - }, - { - caption : this.txtTime, - menu : new Common.UI.Menu({ - style: 'min-width: 200px;', - menuAlign: 'tl-tr', - showSeparator : false, - items: [ - { - caption : '10:56', - value : 'HH:mm', - template: formatTemplate - }, - { - caption : '21:56:00', - value : 'HH:MM:ss', - template: formatTemplate - }, - { - caption : '05:56 AM', - tplval : 'hh:mm tt', - value : 'hh:mm AM/PM', - template: formatTemplate - }, - { - caption : '05:56:00 AM', - tplval : 'hh:mm:ss tt', - value : 'hh:mm:ss AM/PM', - template: formatTemplate - }, - { - caption : '38:56:00', - value : '[h]:mm:ss', - template: formatTemplate - } - ] - }) - }, - { - caption : this.txtPercentage, - value : this.ascFormatOptions.Percentage - }, - { - caption : this.txtFraction, - value : this.ascFormatOptions.Fraction - }, - { - caption : this.txtText, - value : this.ascFormatOptions.Text - } - ] - })); + // var formatTemplate = _.template('<%= caption %><%= options.tplval ? options.tplval : options.value %>'); + // this.btnNumberFormat.setMenu( new Common.UI.Menu({ + // style: 'margin-left: -1px;', + // items: [ + // { + // caption : this.txtGeneral, + // value : this.ascFormatOptions.General + // }, + // { + // caption : this.txtNumber, + // value : this.ascFormatOptions.Number + // }, + // { + // caption : this.txtInteger, + // value : '#0' + // }, + // { + // caption : this.txtScientific, + // value : this.ascFormatOptions.Scientific + // }, + // { + // caption : this.txtAccounting, + // menu : new Common.UI.Menu({ + // style: 'min-width: 120px;', + // menuAlign: 'tl-tr', + // items : [ + // { + // caption : this.txtDollar, + // value : this.ascFormatOptions.Accounting + // }, + // { + // caption : this.txtEuro, + // value : '_(€* #,##0.00_);_(€* (#,##0.00);_(€* "-"??_);_(@_)' + // }, + // { + // caption : this.txtPound, + // value : '_(£* #,##0.00_);_(£* (#,##0.00);_(£* "-"??_);_(@_)' + // }, + // { + // caption : this.txtRouble, + // value : '_-* #,##0.00[$р.-419]_-;-* #,##0.00[$р.-419]_-;_-* "-"??[$р.-419]_-;_-@_-' + // }, + // { + // caption : this.txtYen, + // value : '_(¥* #,##0.00_);_(¥* (#,##0.00);_(¥* "-"??_);_(@_)' + // } + // ] + // }) + // }, + // { + // caption : this.txtCurrency, + // menu : new Common.UI.Menu({ + // style: 'min-width: 120px;', + // menuAlign: 'tl-tr', + // items : [ + // { + // caption : this.txtDollar, + // value : this.ascFormatOptions.Currency + // }, + // { + // caption : this.txtEuro, + // value : '€#,##0.00' + // }, + // { + // caption : this.txtPound, + // value : '£#,##0.00' + // }, + // { + // caption : this.txtRouble, + // value : '#,##0.00"р."' + // }, + // { + // caption : this.txtYen, + // value : '¥#,##0.00' + // } + // ] + // }) + // }, + // { + // caption : this.txtDate, + // menu : new Common.UI.Menu({ + // style: 'min-width: 200px;', + // menuAlign: 'tl-tr', + // items: [ + // { + // caption : '07-24-88', + // value : 'MM-dd-yy', + // template: formatTemplate + // }, + // { + // caption : '07-24-1988', + // value : 'MM-dd-yyyy', + // template: formatTemplate + // }, + // { + // caption : '24-07-88', + // value : 'dd-MM-yy', + // template: formatTemplate + // }, + // { + // caption : '24-07-1988', + // value : 'dd-MM-yyyy', + // template: formatTemplate + // }, + // { + // caption : '24-Jul-1988', + // value : 'dd-MMM-yyyy', + // template: formatTemplate + // }, + // { + // caption : '24-Jul', + // value : 'dd-MMM', + // template: formatTemplate + // }, + // { + // caption : 'Jul-88', + // value : 'MMM-yy', + // template: formatTemplate + // } + // ] + // }) + // }, + // { + // caption : this.txtTime, + // menu : new Common.UI.Menu({ + // style: 'min-width: 200px;', + // menuAlign: 'tl-tr', + // showSeparator : false, + // items: [ + // { + // caption : '10:56', + // value : 'HH:mm', + // template: formatTemplate + // }, + // { + // caption : '21:56:00', + // value : 'HH:MM:ss', + // template: formatTemplate + // }, + // { + // caption : '05:56 AM', + // tplval : 'hh:mm tt', + // value : 'hh:mm AM/PM', + // template: formatTemplate + // }, + // { + // caption : '05:56:00 AM', + // tplval : 'hh:mm:ss tt', + // value : 'hh:mm:ss AM/PM', + // template: formatTemplate + // }, + // { + // caption : '38:56:00', + // value : '[h]:mm:ss', + // template: formatTemplate + // } + // ] + // }) + // }, + // { + // caption : this.txtPercentage, + // value : this.ascFormatOptions.Percentage + // }, + // { + // caption : this.txtFraction, + // value : this.ascFormatOptions.Fraction + // }, + // { + // caption : this.txtText, + // value : this.ascFormatOptions.Text + // } + // ] + // })); this.mnuInsertChartPicker = new Common.UI.DataView({ el: $('#id-toolbar-menu-insertchart'), From 1caa8bd6c0ec1ab1fd6ba8cb98a2b7ae8dd18c28 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Jan 2017 11:01:32 +0300 Subject: [PATCH 03/16] [SSE] Set current cell value for format example. --- apps/spreadsheeteditor/main/app/controller/Toolbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index ccc4d6c24..31d8620b5 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -895,7 +895,7 @@ define([ var me = this, info = me.api.asc_getCellInfo(); me.toolbar.numFormatData.forEach( function(item, index) { - item.exampleval = me.api.asc_getLocaleExample2(item.format, info.asc_getText(), me._state.langId); + item.exampleval = me.api.asc_getLocaleExample2(item.format, null, me._state.langId); }); me.toolbar.cmbNumberFormat.setData(me.toolbar.numFormatData); me.toolbar.cmbNumberFormat.setValue(me._state.numformattype, me.toolbar.txtCustom); From fbd59015428cab7b6744ad5307d04d65b55dff31 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 16 Jan 2017 11:48:21 +0300 Subject: [PATCH 04/16] [SSE] Added dialog for custom number format. --- .../main/app/controller/Toolbar.js | 35 +- .../main/app/view/FileMenuPanels.js | 4 + .../main/app/view/FormatSettingsDialog.js | 467 ++++++++++++++++++ .../main/app/view/Toolbar.js | 7 +- apps/spreadsheeteditor/main/locale/en.json | 1 + 5 files changed, 499 insertions(+), 15 deletions(-) create mode 100644 apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 31d8620b5..6c128246a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -50,7 +50,8 @@ define([ 'spreadsheeteditor/main/app/view/TableOptionsDialog', 'spreadsheeteditor/main/app/view/NamedRangeEditDlg', 'spreadsheeteditor/main/app/view/NamedRangePasteDlg', - 'spreadsheeteditor/main/app/view/NameManagerDlg' + 'spreadsheeteditor/main/app/view/NameManagerDlg', + 'spreadsheeteditor/main/app/view/FormatSettingsDialog' ], function () { 'use strict'; SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend({ @@ -102,8 +103,7 @@ define([ fontsize: undefined, multiselect: false, sparklines_disabled: false, - numformattype: undefined, - langId: 0x0409 + numformattype: undefined }; var checkInsertAutoshape = function(e, action) { @@ -256,6 +256,8 @@ define([ toolbar.listStyles.on('click', _.bind(this.onListStyleSelect, this)); toolbar.cmbNumberFormat.on('selected', _.bind(this.onNumberFormatSelect, this)); toolbar.cmbNumberFormat.on('show:before', _.bind(this.onNumberFormatOpenBefore, this, true)); + if (toolbar.cmbNumberFormat.cmpEl) + toolbar.cmbNumberFormat.cmpEl.on('click', '#id-toolbar-mnu-item-more-formats a', _.bind(this.onNumberFormatSelect, this)); toolbar.btnCurrencyStyle.menu.on('item:click', _.bind(this.onNumberFormatMenu, this)); if (toolbar.mnuitemCompactToolbar) toolbar.mnuitemCompactToolbar.on('toggle', _.bind(this.onChangeViewMode, this)); $('#id-toolbar-menu-new-fontcolor').on('click', _.bind(this.onNewTextColor, this)); @@ -883,9 +885,22 @@ define([ }, onNumberFormatSelect: function(combo, record) { - if (this.api) - this.api.asc_setCellFormat(record.format); - + if (record) { + if (this.api) + this.api.asc_setCellFormat(record.format); + } else { + var me = this; + (new SSE.Views.FormatSettingsDialog({ + api: me.api, + handler: function(result, settings) { + if (settings) { + me.api.asc_setCellFormat(settings.format); + } + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + }, + props : {} + })).show(); + } Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.component.Analytics.trackEvent('ToolBar', 'Number Format'); }, @@ -895,7 +910,7 @@ define([ var me = this, info = me.api.asc_getCellInfo(); me.toolbar.numFormatData.forEach( function(item, index) { - item.exampleval = me.api.asc_getLocaleExample2(item.format, null, me._state.langId); + item.exampleval = me.api.asc_getLocaleExample2(item.format); }); me.toolbar.cmbNumberFormat.setData(me.toolbar.numFormatData); me.toolbar.cmbNumberFormat.setValue(me._state.numformattype, me.toolbar.txtCustom); @@ -2560,12 +2575,6 @@ define([ for (var i=0; i', + '
    ', + '
    ', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '
    ', + '', + '
    ', + '
    ', + '', + '', + '
    ', + '', + '
    ', + '
    ', + '', + '
    ', + '
    ', + '
    ', + '
    ', + '', + '
    ', + '
    ', + '', + '
    ', + '
    ', + '', + '
    ', + '
    ', + '
    ', + '
    ', + '
    ', + '
    ', + '' + ].join('') + }, options); + + this.api = options.api; + this.handler = options.handler; + this.props = options.props; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + + this.FormatType = Asc.c_oAscNumFormatType.General; + this.Format = this.ascFormatOptions.General; + }, + + render: function() { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.cmbFormat = new Common.UI.ComboBox({ + el: $('#format-settings-combo-format'), + cls: 'input-group-nr', + menuStyle: 'min-width: 140px;', + editable: false, + data: this.numFormatData + }); + this.cmbFormat.setValue(this.FormatType); + this.cmbFormat.on('selected', _.bind(this.onFormatSelect, this)); + + this.cmbNegative = new Common.UI.ComboBox({ + el: $('#format-settings-combo-negative'), + cls: 'input-group-nr', + menuStyle: 'min-width: 140px;', + editable: false, + data: [] + }); + this.cmbNegative.on('selected', _.bind(this.onNegativeSelect, this)); + + this.spnDecimal = new Common.UI.MetricSpinner({ + el: $('#format-settings-spin-decimal'), + step: 1, + width: 45, + defaultUnit : "", + value: 2, + maxValue: 30, + minValue: 0, + allowDecimal: false + }); + this.spnDecimal.on('change', _.bind(this.onDecimalChange, this)); + + this.chSeparator = new Common.UI.CheckBox({ + el: $('#format-settings-checkbox-separator'), + labelText: this.textSeparator + }); + this.chSeparator.on('change', _.bind(this.onSeparatorChange, this)); + + this.cmbSymbols = new Common.UI.ComboBox({ + el: $('#format-settings-combo-symbols'), + cls: 'input-group-nr', + menuStyle: 'min-width: 140px;', + editable: false, + data: [ + { displayValue: this.txtDollar, value: 0 }, + { displayValue: this.txtEuro, value: 1 }, + { displayValue: this.txtPound, value: 2 }, + { displayValue: this.txtRouble, value: 3 }, + { displayValue: this.txtYen, value: 4 } + ] + }); + this.cmbSymbols.setValue(0); + this.cmbSymbols.on('selected', _.bind(this.onSymbolsSelect, this)); + + this.cmbType = new Common.UI.ComboBox({ + el: $('#format-settings-combo-type'), + cls: 'input-group-nr', + menuStyle: 'min-width: 140px;', + editable: false, + data: [] + }); + this.cmbType.setValue(-1); + this.cmbType.on('selected', _.bind(this.onTypeSelect, this)); + + this.cmbCode = new Common.UI.ComboBox({ + el: $('#format-settings-combo-code'), + cls: 'input-group-nr', + menuStyle: 'min-width: 310px;', + editable: false, + data: [] + }); + // this.cmbCode.on('selected', _.bind(this.onCodeSelect, this)); + + this._decimalPanel = this.$window.find('.format-decimal'); + this._negativePanel = this.$window.find('.format-negative'); + this._separatorPanel = this.$window.find('.format-separator'); + this._typePanel = this.$window.find('.format-type'); + this._symbolsPanel = this.$window.find('.format-symbols'); + this._codePanel = this.$window.find('.format-code'); + + this.lblExample = this.$window.find('#format-settings-label-example'); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + show: function() { + Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); + }, + + _setDefaults: function (props) { + if (props) { + // var val = props.get_NumFormat(); + // this.cmbFormat.setValue(val); + this.onFormatSelect(this.cmbFormat, this.cmbFormat.getSelectedRecord()); + } + }, + + getSettings: function () { + return {format: ''}; + }, + + onDlgBtnClick: function(event) { + var me = this; + var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event; + if (state == 'ok') { + this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined); + } + + this.close(); + }, + + onPrimary: function() { + return true; + }, + + onNegativeSelect: function(combo, record) { + this.Format = record.value; + this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + }, + + onSymbolsSelect: function(combo, record) { + var info = new Asc.asc_CFormatCellsInfo(); + info.asc_setType(this.FormatType); + info.asc_setDecimalPlaces(this.spnDecimal.getNumberValue()); + info.asc_setSeparator(false); + info.asc_setSymbol(record.value); + + var format = this.api.asc_getFormatCells(info); + if (this.FormatType == Asc.c_oAscNumFormatType.Currency) { + this.cmbNegative.setData(format); + this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); + this.Format = format[0]; + } else { + this.Format = format; + } + + this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + }, + + onDecimalChange: function(field, newValue, oldValue, eOpts){ + var info = new Asc.asc_CFormatCellsInfo(); + info.asc_setType(this.FormatType); + info.asc_setDecimalPlaces(field.getNumberValue()); + info.asc_setSeparator((this.FormatType == Asc.c_oAscNumFormatType.Number) ? this.chSeparator.getValue()=='checked' : false); + info.asc_setSymbol((this.FormatType == Asc.c_oAscNumFormatType.Currency || this.FormatType == Asc.c_oAscNumFormatType.Accounting) ? this.cmbSymbols.getValue() : false); + + var format = this.api.asc_getFormatCells(info); + if (this.FormatType == Asc.c_oAscNumFormatType.Number || this.FormatType == Asc.c_oAscNumFormatType.Currency) { + this.cmbNegative.setData(format); + this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); + this.Format = format[0]; + } else { + this.Format = format; + } + + this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + }, + + onSeparatorChange: function(field, newValue, oldValue, eOpts){ + var info = new Asc.asc_CFormatCellsInfo(); + info.asc_setType(this.FormatType); + info.asc_setDecimalPlaces(this.spnDecimal.getNumberValue()); + info.asc_setSeparator(field.getValue()=='checked'); + + var format = this.api.asc_getFormatCells(info); + this.cmbNegative.setData(format); + this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); + this.Format = format[0]; + + this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + }, + + onTypeSelect: function(combo, record){ + var info = new Asc.asc_CFormatCellsInfo(); + info.asc_setType(this.FormatType); + info.asc_setDecimalPlaces(0); + info.asc_setSeparator(false); + + if (this.FormatType == Asc.c_oAscNumFormatType.Fraction) { + // info.asc_setFraction(record.value); + this.Format = this.api.asc_getFormatCells(info); + } else { + this.Format = record.value; + } + + this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + }, + + onCodeSelect: function(combo, record){ + this.Format = record.value; + this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + }, + + onFormatSelect: function(combo, record) { + if (!record) return; + + this.FormatType = record.value; + + var hasDecimal = (record.value == Asc.c_oAscNumFormatType.Number || record.value == Asc.c_oAscNumFormatType.Scientific || record.value == Asc.c_oAscNumFormatType.Accounting || + record.value == Asc.c_oAscNumFormatType.Currency || record.value == Asc.c_oAscNumFormatType.Percent), + hasNegative = (record.value == Asc.c_oAscNumFormatType.Number || record.value == Asc.c_oAscNumFormatType.Currency), + hasSeparator = (record.value == Asc.c_oAscNumFormatType.Number), + hasType = (record.value == Asc.c_oAscNumFormatType.Date || record.value == Asc.c_oAscNumFormatType.Time || record.value == Asc.c_oAscNumFormatType.Fraction), + hasSymbols = (record.value == Asc.c_oAscNumFormatType.Accounting || record.value == Asc.c_oAscNumFormatType.Currency), + hasCode = (record.value == -1); + + if (record.value !== -1) { + var info = new Asc.asc_CFormatCellsInfo(); + info.asc_setType(record.value); + info.asc_setDecimalPlaces(hasDecimal ? this.spnDecimal.getNumberValue() : 0); + info.asc_setSeparator(hasSeparator ? this.chSeparator.getValue()=='checked' : false); + info.asc_setSymbol(hasSymbols ? this.cmbSymbols.getValue() : false); + + if (hasNegative || record.value == Asc.c_oAscNumFormatType.Date || record.value == Asc.c_oAscNumFormatType.Time) { + var formatsarr = this.api.asc_getFormatCells(info); + if (hasNegative) { + this.cmbNegative.setData(formatsarr); + this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); + } else { + this.cmbType.setData(formatsarr); + this.cmbType.selectRecord(this.cmbType.store.at(0)); + } + this.Format = formatsarr[0]; + } else { + if (record.value == Asc.c_oAscNumFormatType.Fraction) { + this.cmbType.setData(this.FractionData); + this.cmbType.setValue(0); + // info.asc_setFraction(this.cmbType.getValue()); + } + this.Format = this.api.asc_getFormatCells(info); + } + + } else { + var formatsarr = this.api.asc_getFormatCells(null); + this.cmbCode.setData(formatsarr); + this.cmbCode.setValue(this.Format); + } + + // this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + + this._decimalPanel.toggleClass('hidden', !hasDecimal); + this._negativePanel.css('visibility', hasNegative ? '' : 'hidden'); + this._separatorPanel.toggleClass('hidden', !hasSeparator); + this._typePanel.toggleClass('hidden', !hasType); + this._symbolsPanel.toggleClass('hidden', !hasSymbols); + this._codePanel.toggleClass('hidden', !hasCode); + }, + + textTitle: 'Number Format', + textSample: 'Sample', + textDecimal: 'Decimal', + textNegative: 'Negative numbers', + textSeparator: 'Use 1000 separator', + textType: 'Type', + textSymbols: 'Symbols', + textCode: 'Code', + textCancel: 'Cancel', + textOk: 'OK', + txtGeneral: 'General', + txtNumber: 'Number', + txtCustom: 'Custom', + txtCurrency: 'Currency', + txtAccounting: 'Accounting', + txtDate: 'Date', + txtTime: 'Time', + txtPercentage: 'Percentage', + txtFraction: 'Fraction', + txtScientific: 'Scientific', + txtText: 'Text', + txtDollar: '$ Dollar', + txtEuro: '€ Euro', + txtRouble: 'р. Rouble', + txtPound: '£ Pound', + txtYen: '¥ Yen', + txtUpto1: 'Up to one digit', + txtUpto2: 'Up to two digits', + txtUpto3: 'Up to three digits', + txtAs2: 'As halfs', + txtAs8: 'As eighths', + txtAs4: 'As fourths', + txtAs16: 'As sixteenths', + txtAs10: 'As tenths', + txtAs100: 'As hundredths' + + + }, SSE.Views.FormatSettingsDialog || {})) +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 420a5ced0..353981382 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -657,7 +657,9 @@ define([ '
    <%= scope.getDisplayValue(item) %>
    ', '
    <%= item.exampleval ? item.exampleval : "" %>
    ', '
    ', - '<% }); %>' + '<% }); %>', + '
  • ', + '
  • ' + me.textMoreFormats + '
  • ' ].join('')); me.cmbNumberFormat = new Common.UI.ComboBox({ @@ -2112,6 +2114,7 @@ define([ tipInsertEquation: 'Insert Equation', textCharts: 'Charts', textSparks: 'Sparklines', - tipInsertChartSpark: 'Insert Chart or Sparkline' + tipInsertChartSpark: 'Insert Chart or Sparkline', + textMoreFormats: 'More formats' }, SSE.Views.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 5c9560616..fdd164c11 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1625,6 +1625,7 @@ "SSE.Views.Toolbar.textLineSpark": "Line", "SSE.Views.Toolbar.textColumnSpark": "Column", "SSE.Views.Toolbar.textWinLossSpark": "Win/Loss", + "SSE.Views.Toolbar.textMoreFormats": "More formats", "SSE.Views.Top10FilterDialog.cancelButtonText": "Cancel", "SSE.Views.Top10FilterDialog.okButtonText": "OK", "SSE.Views.Top10FilterDialog.textType": "Show", From 15a25b82e54ed177487820c0458fea6b0a5dfe6e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 16 Jan 2017 14:14:47 +0300 Subject: [PATCH 05/16] [SSE] Debug custom number formats. --- apps/common/main/lib/component/ComboBox.js | 2 +- .../main/app/view/FormatSettingsDialog.js | 63 +++++++++++++------ 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index ce988c852..04e483887 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -282,7 +282,7 @@ define([ } if (this.scroller) - this.scroller.update(); + this.scroller.update({alwaysVisibleY: this.scrollAlwaysVisible}); this.trigger('show:after', this, e); }, diff --git a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js index 8e84b54e1..2b5d90523 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js @@ -188,9 +188,10 @@ define([ this.cmbNegative = new Common.UI.ComboBox({ el: $('#format-settings-combo-negative'), cls: 'input-group-nr', - menuStyle: 'min-width: 140px;', + menuStyle: 'min-width: 140px;max-height:210px;', editable: false, - data: [] + data: [], + scrollAlwaysVisible: true }); this.cmbNegative.on('selected', _.bind(this.onNegativeSelect, this)); @@ -215,7 +216,7 @@ define([ this.cmbSymbols = new Common.UI.ComboBox({ el: $('#format-settings-combo-symbols'), cls: 'input-group-nr', - menuStyle: 'min-width: 140px;', + menuStyle: 'min-width: 140px', editable: false, data: [ { displayValue: this.txtDollar, value: 0 }, @@ -231,9 +232,10 @@ define([ this.cmbType = new Common.UI.ComboBox({ el: $('#format-settings-combo-type'), cls: 'input-group-nr', - menuStyle: 'min-width: 140px;', + menuStyle: 'min-width: 140px;max-height:210px;', editable: false, - data: [] + data: [], + scrollAlwaysVisible: true }); this.cmbType.setValue(-1); this.cmbType.on('selected', _.bind(this.onTypeSelect, this)); @@ -241,11 +243,12 @@ define([ this.cmbCode = new Common.UI.ComboBox({ el: $('#format-settings-combo-code'), cls: 'input-group-nr', - menuStyle: 'min-width: 310px;', + menuStyle: 'min-width: 310px;max-height:210px;', editable: false, - data: [] + data: [], + scrollAlwaysVisible: true }); - // this.cmbCode.on('selected', _.bind(this.onCodeSelect, this)); + this.cmbCode.on('selected', _.bind(this.onCodeSelect, this)); this._decimalPanel = this.$window.find('.format-decimal'); this._negativePanel = this.$window.find('.format-negative'); @@ -307,7 +310,11 @@ define([ var format = this.api.asc_getFormatCells(info); if (this.FormatType == Asc.c_oAscNumFormatType.Currency) { - this.cmbNegative.setData(format); + var data = []; + format.forEach(function(item) { + data.push({value: item, displayValue: item}); + }); + this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); this.Format = format[0]; } else { @@ -326,7 +333,11 @@ define([ var format = this.api.asc_getFormatCells(info); if (this.FormatType == Asc.c_oAscNumFormatType.Number || this.FormatType == Asc.c_oAscNumFormatType.Currency) { - this.cmbNegative.setData(format); + var data = []; + format.forEach(function(item) { + data.push({value: item, displayValue: item}); + }); + this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); this.Format = format[0]; } else { @@ -342,8 +353,12 @@ define([ info.asc_setDecimalPlaces(this.spnDecimal.getNumberValue()); info.asc_setSeparator(field.getValue()=='checked'); - var format = this.api.asc_getFormatCells(info); - this.cmbNegative.setData(format); + var format = this.api.asc_getFormatCells(info), + data = []; + format.forEach(function(item) { + data.push({value: item, displayValue: item}); + }); + this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); this.Format = format[0]; @@ -357,7 +372,7 @@ define([ info.asc_setSeparator(false); if (this.FormatType == Asc.c_oAscNumFormatType.Fraction) { - // info.asc_setFraction(record.value); + info.asc_setFractionType(record.value); this.Format = this.api.asc_getFormatCells(info); } else { this.Format = record.value; @@ -392,12 +407,16 @@ define([ info.asc_setSymbol(hasSymbols ? this.cmbSymbols.getValue() : false); if (hasNegative || record.value == Asc.c_oAscNumFormatType.Date || record.value == Asc.c_oAscNumFormatType.Time) { - var formatsarr = this.api.asc_getFormatCells(info); + var formatsarr = this.api.asc_getFormatCells(info), + data = []; + formatsarr.forEach(function(item) { + data.push({value: item, displayValue: item}); + }); if (hasNegative) { - this.cmbNegative.setData(formatsarr); + this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); } else { - this.cmbType.setData(formatsarr); + this.cmbType.setData(data); this.cmbType.selectRecord(this.cmbType.store.at(0)); } this.Format = formatsarr[0]; @@ -405,18 +424,22 @@ define([ if (record.value == Asc.c_oAscNumFormatType.Fraction) { this.cmbType.setData(this.FractionData); this.cmbType.setValue(0); - // info.asc_setFraction(this.cmbType.getValue()); + info.asc_setFractionType(this.cmbType.getValue()); } this.Format = this.api.asc_getFormatCells(info); } } else { - var formatsarr = this.api.asc_getFormatCells(null); - this.cmbCode.setData(formatsarr); + var formatsarr = this.api.asc_getFormatCells(null), + data = []; + formatsarr.forEach(function(item) { + data.push({value: item, displayValue: item}); + }); + this.cmbCode.setData(data); this.cmbCode.setValue(this.Format); } - // this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); this._decimalPanel.toggleClass('hidden', !hasDecimal); this._negativePanel.css('visibility', hasNegative ? '' : 'hidden'); From 56e6f1c780c1046be754457fda38ae4b57638515 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 16 Jan 2017 17:06:46 +0300 Subject: [PATCH 06/16] [SSE] Debug custom number format. --- .../main/app/controller/Toolbar.js | 2 +- .../main/app/view/FormatSettingsDialog.js | 140 ++++++++---------- 2 files changed, 60 insertions(+), 82 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 6c128246a..88ead621c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -898,7 +898,7 @@ define([ } Common.NotificationCenter.trigger('edit:complete', me.toolbar); }, - props : {} + props : {formatType: me._state.numformattype} })).show(); } Common.NotificationCenter.trigger('edit:complete', this.toolbar); diff --git a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js index 2b5d90523..aa2e3ac2d 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js @@ -55,45 +55,30 @@ define([ initialize : function(options) { var me = this; - me.ascFormatOptions = { - General : 'General', - Number : '0.00', - Currency : '$#,##0.00', - Accounting : '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)', - DateShort : 'm/d/yyyy', - DateLong : '[$-F800]dddd, mmmm dd, yyyy', - Time : '[$-F400]h:mm:ss AM/PM', - Percentage : '0.00%', - Percent : '0%', - Fraction : '# ?/?', - Scientific : '0.00E+00', - Text : '@' - }; - me.numFormatData = [ - { value: Asc.c_oAscNumFormatType.General, format: this.ascFormatOptions.General, displayValue: this.txtGeneral, exampleval: '100' }, - { value: Asc.c_oAscNumFormatType.Number, format: this.ascFormatOptions.Number, displayValue: this.txtNumber, exampleval: '100,00' }, - { value: Asc.c_oAscNumFormatType.Scientific,format: this.ascFormatOptions.Scientific, displayValue: this.txtScientific, exampleval: '1,00E+02' }, - { value: Asc.c_oAscNumFormatType.Accounting,format: this.ascFormatOptions.Accounting, displayValue: this.txtAccounting, exampleval: '100,00 $' }, - { value: Asc.c_oAscNumFormatType.Currency, format: this.ascFormatOptions.Currency, displayValue: this.txtCurrency, exampleval: '100,00 $' }, - { value: Asc.c_oAscNumFormatType.Date, format: 'MM-dd-yyyy', displayValue: this.txtDate, exampleval: '04-09-1900' }, - { value: Asc.c_oAscNumFormatType.Time, format: 'HH:MM:ss', displayValue: this.txtTime, exampleval: '00:00:00' }, - { value: Asc.c_oAscNumFormatType.Percent, format: this.ascFormatOptions.Percentage, displayValue: this.txtPercentage, exampleval: '100,00%' }, - { value: Asc.c_oAscNumFormatType.Fraction, format: this.ascFormatOptions.Fraction, displayValue: this.txtFraction, exampleval: '100' }, - { value: Asc.c_oAscNumFormatType.Text, format: this.ascFormatOptions.Text, displayValue: this.txtText, exampleval: '100' }, - { value: -1, format: '', displayValue: this.txtCustom, exampleval: '100' } + { value: Asc.c_oAscNumFormatType.General, displayValue: this.txtGeneral }, + { value: Asc.c_oAscNumFormatType.Number, displayValue: this.txtNumber }, + { value: Asc.c_oAscNumFormatType.Scientific,displayValue: this.txtScientific }, + { value: Asc.c_oAscNumFormatType.Accounting,displayValue: this.txtAccounting }, + { value: Asc.c_oAscNumFormatType.Currency, displayValue: this.txtCurrency }, + { value: Asc.c_oAscNumFormatType.Date, displayValue: this.txtDate }, + { value: Asc.c_oAscNumFormatType.Time, displayValue: this.txtTime }, + { value: Asc.c_oAscNumFormatType.Percent, displayValue: this.txtPercentage }, + { value: Asc.c_oAscNumFormatType.Fraction, displayValue: this.txtFraction }, + { value: Asc.c_oAscNumFormatType.Text, displayValue: this.txtText }, + { value: Asc.c_oAscNumFormatType.Custom, displayValue: this.txtCustom } ]; me.FractionData = [ - { displayValue: this.txtUpto1, value: 0 }, - { displayValue: this.txtUpto2, value: 1 }, - { displayValue: this.txtUpto3, value: 2 }, - { displayValue: this.txtAs2, value: 3 }, - { displayValue: this.txtAs4, value: 4 }, - { displayValue: this.txtAs8, value: 5 }, - { displayValue: this.txtAs16, value: 6 }, - { displayValue: this.txtAs10, value: 7 }, - { displayValue: this.txtAs100, value: 8 } + { displayValue: this.txtUpto1, value: "# ?/?" }, + { displayValue: this.txtUpto2, value: "# ??/??" }, + { displayValue: this.txtUpto3, value: "# ???/???" }, + { displayValue: this.txtAs2, value: "# ?/2" }, + { displayValue: this.txtAs4, value: "# ?/4" }, + { displayValue: this.txtAs8, value: "# ?/8" }, + { displayValue: this.txtAs16, value: "# ??/16" }, + { displayValue: this.txtAs10, value: "# ?/10" }, + { displayValue: this.txtAs100, value: "# ??/100" } ]; _.extend(this.options, { @@ -168,7 +153,7 @@ define([ Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); this.FormatType = Asc.c_oAscNumFormatType.General; - this.Format = this.ascFormatOptions.General; + this.Format = "General"; }, render: function() { @@ -237,7 +222,6 @@ define([ data: [], scrollAlwaysVisible: true }); - this.cmbType.setValue(-1); this.cmbType.on('selected', _.bind(this.onTypeSelect, this)); this.cmbCode = new Common.UI.ComboBox({ @@ -272,9 +256,11 @@ define([ _setDefaults: function (props) { if (props) { - // var val = props.get_NumFormat(); - // this.cmbFormat.setValue(val); + this.cmbFormat.setValue(props.formatType, this.txtCustom); this.onFormatSelect(this.cmbFormat, this.cmbFormat.getSelectedRecord()); + // for fraction - if props.format not in cmbType - setValue(this.txtCustom) + // for date/time - if props.format not in cmbType - setValue(this.api.asc_getLocaleExample2(props.format, 37973)) + // for cmbNegative - if props.format not in cmbNegative - setValue(this.api.asc_getLocaleExample2(props.format)) } }, @@ -302,53 +288,54 @@ define([ }, onSymbolsSelect: function(combo, record) { - var info = new Asc.asc_CFormatCellsInfo(); + var me = this, + info = new Asc.asc_CFormatCellsInfo(); info.asc_setType(this.FormatType); info.asc_setDecimalPlaces(this.spnDecimal.getNumberValue()); info.asc_setSeparator(false); info.asc_setSymbol(record.value); - var format = this.api.asc_getFormatCells(info); - if (this.FormatType == Asc.c_oAscNumFormatType.Currency) { - var data = []; - format.forEach(function(item) { - data.push({value: item, displayValue: item}); - }); - this.cmbNegative.setData(data); - this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); - this.Format = format[0]; - } else { - this.Format = format; - } + var format = this.api.asc_getFormatCells(info), + data = []; + format.forEach(function(item) { + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item)}); + }); + this.cmbNegative.setData(data); + this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); + this.cmbNegative.cmpEl.find('li:nth-child(2) a, li:nth-child(4) a').css({color: '#ff0000'}); + this.Format = format[0]; this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); }, onDecimalChange: function(field, newValue, oldValue, eOpts){ - var info = new Asc.asc_CFormatCellsInfo(); + var me = this, + info = new Asc.asc_CFormatCellsInfo(); info.asc_setType(this.FormatType); info.asc_setDecimalPlaces(field.getNumberValue()); info.asc_setSeparator((this.FormatType == Asc.c_oAscNumFormatType.Number) ? this.chSeparator.getValue()=='checked' : false); info.asc_setSymbol((this.FormatType == Asc.c_oAscNumFormatType.Currency || this.FormatType == Asc.c_oAscNumFormatType.Accounting) ? this.cmbSymbols.getValue() : false); var format = this.api.asc_getFormatCells(info); - if (this.FormatType == Asc.c_oAscNumFormatType.Number || this.FormatType == Asc.c_oAscNumFormatType.Currency) { + if (this.FormatType == Asc.c_oAscNumFormatType.Number || this.FormatType == Asc.c_oAscNumFormatType.Currency || this.FormatType == Asc.c_oAscNumFormatType.Accounting) { var data = []; format.forEach(function(item) { - data.push({value: item, displayValue: item}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); + this.cmbNegative.cmpEl.find('li:nth-child(2) a, li:nth-child(4) a').css({color: '#ff0000'}); this.Format = format[0]; } else { - this.Format = format; + this.Format = format[0]; } this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); }, onSeparatorChange: function(field, newValue, oldValue, eOpts){ - var info = new Asc.asc_CFormatCellsInfo(); + var me = this, + info = new Asc.asc_CFormatCellsInfo(); info.asc_setType(this.FormatType); info.asc_setDecimalPlaces(this.spnDecimal.getNumberValue()); info.asc_setSeparator(field.getValue()=='checked'); @@ -356,28 +343,18 @@ define([ var format = this.api.asc_getFormatCells(info), data = []; format.forEach(function(item) { - data.push({value: item, displayValue: item}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); + this.cmbNegative.cmpEl.find('li:nth-child(2) a, li:nth-child(4) a').css({color: '#ff0000'}); this.Format = format[0]; this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); }, onTypeSelect: function(combo, record){ - var info = new Asc.asc_CFormatCellsInfo(); - info.asc_setType(this.FormatType); - info.asc_setDecimalPlaces(0); - info.asc_setSeparator(false); - - if (this.FormatType == Asc.c_oAscNumFormatType.Fraction) { - info.asc_setFractionType(record.value); - this.Format = this.api.asc_getFormatCells(info); - } else { - this.Format = record.value; - } - + this.Format = record.value; this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); }, @@ -393,13 +370,13 @@ define([ var hasDecimal = (record.value == Asc.c_oAscNumFormatType.Number || record.value == Asc.c_oAscNumFormatType.Scientific || record.value == Asc.c_oAscNumFormatType.Accounting || record.value == Asc.c_oAscNumFormatType.Currency || record.value == Asc.c_oAscNumFormatType.Percent), - hasNegative = (record.value == Asc.c_oAscNumFormatType.Number || record.value == Asc.c_oAscNumFormatType.Currency), + hasNegative = (record.value == Asc.c_oAscNumFormatType.Number || record.value == Asc.c_oAscNumFormatType.Currency || record.value == Asc.c_oAscNumFormatType.Accounting), hasSeparator = (record.value == Asc.c_oAscNumFormatType.Number), hasType = (record.value == Asc.c_oAscNumFormatType.Date || record.value == Asc.c_oAscNumFormatType.Time || record.value == Asc.c_oAscNumFormatType.Fraction), hasSymbols = (record.value == Asc.c_oAscNumFormatType.Accounting || record.value == Asc.c_oAscNumFormatType.Currency), - hasCode = (record.value == -1); + hasCode = (record.value == Asc.c_oAscNumFormatType.Custom); - if (record.value !== -1) { + if (record.value !== Asc.c_oAscNumFormatType.Custom) { var info = new Asc.asc_CFormatCellsInfo(); info.asc_setType(record.value); info.asc_setDecimalPlaces(hasDecimal ? this.spnDecimal.getNumberValue() : 0); @@ -408,25 +385,26 @@ define([ if (hasNegative || record.value == Asc.c_oAscNumFormatType.Date || record.value == Asc.c_oAscNumFormatType.Time) { var formatsarr = this.api.asc_getFormatCells(info), - data = []; + data = [], + me = this; formatsarr.forEach(function(item) { - data.push({value: item, displayValue: item}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item)}); }); if (hasNegative) { this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); + this.cmbNegative.cmpEl.find('li:nth-child(2) a, li:nth-child(4) a').css({color: '#ff0000'}); } else { this.cmbType.setData(data); this.cmbType.selectRecord(this.cmbType.store.at(0)); } this.Format = formatsarr[0]; + } else if (record.value == Asc.c_oAscNumFormatType.Fraction) { + this.cmbType.setData(this.FractionData); + this.cmbType.selectRecord(this.cmbType.store.at(0)); + this.Format = this.cmbType.getValue(); } else { - if (record.value == Asc.c_oAscNumFormatType.Fraction) { - this.cmbType.setData(this.FractionData); - this.cmbType.setValue(0); - info.asc_setFractionType(this.cmbType.getValue()); - } - this.Format = this.api.asc_getFormatCells(info); + this.Format = this.api.asc_getFormatCells(info)[0]; } } else { From 05e604686a5666d7a9b78141430a584069bf9188 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 17 Jan 2017 09:51:08 +0300 Subject: [PATCH 07/16] [SSE] Debug custom number format. --- .../main/app/view/FormatSettingsDialog.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js index aa2e3ac2d..599b671b7 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js @@ -95,7 +95,7 @@ define([ '', '', '', - '', + '', '', '', '', @@ -298,7 +298,7 @@ define([ var format = this.api.asc_getFormatCells(info), data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, 1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); @@ -320,7 +320,7 @@ define([ if (this.FormatType == Asc.c_oAscNumFormatType.Number || this.FormatType == Asc.c_oAscNumFormatType.Currency || this.FormatType == Asc.c_oAscNumFormatType.Accounting) { var data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, 1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); @@ -343,7 +343,7 @@ define([ var format = this.api.asc_getFormatCells(info), data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, 1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); @@ -386,9 +386,10 @@ define([ if (hasNegative || record.value == Asc.c_oAscNumFormatType.Date || record.value == Asc.c_oAscNumFormatType.Time) { var formatsarr = this.api.asc_getFormatCells(info), data = [], + exampleVal = (record.value == Asc.c_oAscNumFormatType.Date) ? 37973 : ((record.value == Asc.c_oAscNumFormatType.Time) ? 0.123 : parseFloat("1234.12345678901234567890")), me = this; formatsarr.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, exampleVal)}); }); if (hasNegative) { this.cmbNegative.setData(data); From f956912aa8f874fdedcd629ae2a8b138241a4326 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 17 Jan 2017 11:19:26 +0300 Subject: [PATCH 08/16] [SSE] FormatSettingsDialog: Use asc_getCurrencySymbols --- .../main/app/controller/Toolbar.js | 7 ++- .../main/app/view/FormatSettingsDialog.js | 46 ++++++++++++------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 88ead621c..45f917886 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -889,7 +889,10 @@ define([ if (this.api) this.api.asc_setCellFormat(record.format); } else { - var me = this; + var me = this, + value = Common.localStorage.getItem("sse-settings-reg-settings"); + value = (value!==null) ? parseInt(value) : ((me.toolbar.mode.lang) ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(me.toolbar.mode.lang)) : 0x0409); + (new SSE.Views.FormatSettingsDialog({ api: me.api, handler: function(result, settings) { @@ -898,7 +901,7 @@ define([ } Common.NotificationCenter.trigger('edit:complete', me.toolbar); }, - props : {formatType: me._state.numformattype} + props : {formatType: me._state.numformattype, langId: value} })).show(); } Common.NotificationCenter.trigger('edit:complete', this.toolbar); diff --git a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js index 599b671b7..1799682b8 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js @@ -81,6 +81,9 @@ define([ { displayValue: this.txtAs100, value: "# ??/100" } ]; + me.CurrencySymbolsData = null; + me.langId = 0x0409; + _.extend(this.options, { title: this.textTitle, template: [ @@ -201,17 +204,11 @@ define([ this.cmbSymbols = new Common.UI.ComboBox({ el: $('#format-settings-combo-symbols'), cls: 'input-group-nr', - menuStyle: 'min-width: 140px', + menuStyle: 'min-width: 140px;max-height:210px;', editable: false, - data: [ - { displayValue: this.txtDollar, value: 0 }, - { displayValue: this.txtEuro, value: 1 }, - { displayValue: this.txtPound, value: 2 }, - { displayValue: this.txtRouble, value: 3 }, - { displayValue: this.txtYen, value: 4 } - ] + data: [], + scrollAlwaysVisible: true }); - this.cmbSymbols.setValue(0); this.cmbSymbols.on('selected', _.bind(this.onSymbolsSelect, this)); this.cmbType = new Common.UI.ComboBox({ @@ -256,7 +253,10 @@ define([ _setDefaults: function (props) { if (props) { + if (this.langId) + this.langId = props.langId; this.cmbFormat.setValue(props.formatType, this.txtCustom); + this.onFormatSelect(this.cmbFormat, this.cmbFormat.getSelectedRecord()); // for fraction - if props.format not in cmbType - setValue(this.txtCustom) // for date/time - if props.format not in cmbType - setValue(this.api.asc_getLocaleExample2(props.format, 37973)) @@ -298,7 +298,7 @@ define([ var format = this.api.asc_getFormatCells(info), data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, 1234.12345678901234567890)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, -1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); @@ -320,7 +320,7 @@ define([ if (this.FormatType == Asc.c_oAscNumFormatType.Number || this.FormatType == Asc.c_oAscNumFormatType.Currency || this.FormatType == Asc.c_oAscNumFormatType.Accounting) { var data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, 1234.12345678901234567890)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, -1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); @@ -343,7 +343,7 @@ define([ var format = this.api.asc_getFormatCells(info), data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, 1234.12345678901234567890)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, -1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); @@ -374,20 +374,34 @@ define([ hasSeparator = (record.value == Asc.c_oAscNumFormatType.Number), hasType = (record.value == Asc.c_oAscNumFormatType.Date || record.value == Asc.c_oAscNumFormatType.Time || record.value == Asc.c_oAscNumFormatType.Fraction), hasSymbols = (record.value == Asc.c_oAscNumFormatType.Accounting || record.value == Asc.c_oAscNumFormatType.Currency), - hasCode = (record.value == Asc.c_oAscNumFormatType.Custom); + hasCode = (record.value == Asc.c_oAscNumFormatType.Custom), + me = this; if (record.value !== Asc.c_oAscNumFormatType.Custom) { var info = new Asc.asc_CFormatCellsInfo(); info.asc_setType(record.value); info.asc_setDecimalPlaces(hasDecimal ? this.spnDecimal.getNumberValue() : 0); info.asc_setSeparator(hasSeparator ? this.chSeparator.getValue()=='checked' : false); - info.asc_setSymbol(hasSymbols ? this.cmbSymbols.getValue() : false); if (hasNegative || record.value == Asc.c_oAscNumFormatType.Date || record.value == Asc.c_oAscNumFormatType.Time) { + if (hasSymbols) { + if (!me.CurrencySymbolsData) { + me.CurrencySymbolsData = []; + var symbolssarr = this.api.asc_getCurrencySymbols(); + for (var code in symbolssarr) { + if (symbolssarr.hasOwnProperty(code)) { + me.CurrencySymbolsData.push({value: parseInt(code), displayValue: symbolssarr[code] + ' ' + Common.util.LanguageInfo.getLocalLanguageName(code)[1]}); + } + } + this.cmbSymbols.setData(this.CurrencySymbolsData); + this.cmbSymbols.setValue(this.langId); + } + info.asc_setSymbol(this.cmbSymbols.getValue()); + } + var formatsarr = this.api.asc_getFormatCells(info), data = [], - exampleVal = (record.value == Asc.c_oAscNumFormatType.Date) ? 37973 : ((record.value == Asc.c_oAscNumFormatType.Time) ? 0.123 : parseFloat("1234.12345678901234567890")), - me = this; + exampleVal = (record.value == Asc.c_oAscNumFormatType.Date) ? 37973 : ((record.value == Asc.c_oAscNumFormatType.Time) ? 0.123 : parseFloat("-1234.12345678901234567890")); formatsarr.forEach(function(item) { data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, exampleVal)}); }); From 5cf5f1e0c7bf1fdfaa510b1d32c30d3804661de3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 17 Jan 2017 12:45:48 +0300 Subject: [PATCH 09/16] [SSE] Use asc_getLocaleExample2 instead of asc_getLocaleExample. --- .../main/app/view/FileMenuPanels.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index f8030fd39..b4a72d465 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -754,11 +754,16 @@ define([ updateRegionalExample: function(landId) { if (this.api) { - var text = (landId) ? this.api.asc_getLocaleExample(landId, 1000.01, new Date()) : ''; - //var arr = this.api.asc_getFormatCells(null, landId); // all formats - // text = this.api.asc_getLocaleExample2(arr[0], 1000.01, landId); - // text = text + ' ' + this.api.asc_getLocaleExample2(arr[3], new Date(), landId); - // text = text + ' ' + this.api.asc_getLocaleExample2(arr[5], new Date(), landId); + var text = ''; + if (landId) { + var info = new Asc.asc_CFormatCellsInfo(); + info.asc_setType(Asc.c_oAscNumFormatType.None); + info.asc_setSymbol(landId); + var arr = this.api.asc_getFormatCells(info); // all formats + text = this.api.asc_getLocaleExample2(arr[2], 1000.01, landId); + text = text + ' ' + this.api.asc_getLocaleExample2(arr[4], (new Date()).getExcelDateWithTime(), landId); + text = text + ' ' + this.api.asc_getLocaleExample2(arr[6], (new Date()).getExcelDateWithTime(), landId); + } $('#fms-lbl-reg-settings').text(_.isEmpty(text) ? '' : this.strRegSettingsEx + text); } }, From 4deb5c68734d13e7e8306a52555b3024cbd2ce9c Mon Sep 17 00:00:00 2001 From: "Alexander.Trofimov" Date: Tue, 17 Jan 2017 13:15:36 +0300 Subject: [PATCH 10/16] asc_getLocaleExample2 -> asc_getLocaleExample --- .../main/app/controller/Toolbar.js | 2 +- .../main/app/view/FileMenuPanels.js | 6 ++--- .../main/app/view/FormatSettingsDialog.js | 26 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 45f917886..ece2432b9 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -913,7 +913,7 @@ define([ var me = this, info = me.api.asc_getCellInfo(); me.toolbar.numFormatData.forEach( function(item, index) { - item.exampleval = me.api.asc_getLocaleExample2(item.format); + item.exampleval = me.api.asc_getLocaleExample(item.format); }); me.toolbar.cmbNumberFormat.setData(me.toolbar.numFormatData); me.toolbar.cmbNumberFormat.setValue(me._state.numformattype, me.toolbar.txtCustom); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index b4a72d465..a9610142c 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -760,9 +760,9 @@ define([ info.asc_setType(Asc.c_oAscNumFormatType.None); info.asc_setSymbol(landId); var arr = this.api.asc_getFormatCells(info); // all formats - text = this.api.asc_getLocaleExample2(arr[2], 1000.01, landId); - text = text + ' ' + this.api.asc_getLocaleExample2(arr[4], (new Date()).getExcelDateWithTime(), landId); - text = text + ' ' + this.api.asc_getLocaleExample2(arr[6], (new Date()).getExcelDateWithTime(), landId); + text = this.api.asc_getLocaleExample(arr[2], 1000.01, landId); + text = text + ' ' + this.api.asc_getLocaleExample(arr[4], (new Date()).getExcelDateWithTime(), landId); + text = text + ' ' + this.api.asc_getLocaleExample(arr[6], (new Date()).getExcelDateWithTime(), landId); } $('#fms-lbl-reg-settings').text(_.isEmpty(text) ? '' : this.strRegSettingsEx + text); } diff --git a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js index 1799682b8..e7c918338 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js @@ -259,8 +259,8 @@ define([ this.onFormatSelect(this.cmbFormat, this.cmbFormat.getSelectedRecord()); // for fraction - if props.format not in cmbType - setValue(this.txtCustom) - // for date/time - if props.format not in cmbType - setValue(this.api.asc_getLocaleExample2(props.format, 37973)) - // for cmbNegative - if props.format not in cmbNegative - setValue(this.api.asc_getLocaleExample2(props.format)) + // for date/time - if props.format not in cmbType - setValue(this.api.asc_getLocaleExample(props.format, 37973)) + // for cmbNegative - if props.format not in cmbNegative - setValue(this.api.asc_getLocaleExample(props.format)) } }, @@ -284,7 +284,7 @@ define([ onNegativeSelect: function(combo, record) { this.Format = record.value; - this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); }, onSymbolsSelect: function(combo, record) { @@ -298,14 +298,14 @@ define([ var format = this.api.asc_getFormatCells(info), data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, -1234.12345678901234567890)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample(item, -1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); this.cmbNegative.cmpEl.find('li:nth-child(2) a, li:nth-child(4) a').css({color: '#ff0000'}); this.Format = format[0]; - this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); }, onDecimalChange: function(field, newValue, oldValue, eOpts){ @@ -320,7 +320,7 @@ define([ if (this.FormatType == Asc.c_oAscNumFormatType.Number || this.FormatType == Asc.c_oAscNumFormatType.Currency || this.FormatType == Asc.c_oAscNumFormatType.Accounting) { var data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, -1234.12345678901234567890)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample(item, -1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); @@ -330,7 +330,7 @@ define([ this.Format = format[0]; } - this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); }, onSeparatorChange: function(field, newValue, oldValue, eOpts){ @@ -343,24 +343,24 @@ define([ var format = this.api.asc_getFormatCells(info), data = []; format.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, -1234.12345678901234567890)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample(item, -1234.12345678901234567890)}); }); this.cmbNegative.setData(data); this.cmbNegative.selectRecord(this.cmbNegative.store.at(0)); this.cmbNegative.cmpEl.find('li:nth-child(2) a, li:nth-child(4) a').css({color: '#ff0000'}); this.Format = format[0]; - this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); }, onTypeSelect: function(combo, record){ this.Format = record.value; - this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); }, onCodeSelect: function(combo, record){ this.Format = record.value; - this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); }, onFormatSelect: function(combo, record) { @@ -403,7 +403,7 @@ define([ data = [], exampleVal = (record.value == Asc.c_oAscNumFormatType.Date) ? 37973 : ((record.value == Asc.c_oAscNumFormatType.Time) ? 0.123 : parseFloat("-1234.12345678901234567890")); formatsarr.forEach(function(item) { - data.push({value: item, displayValue: me.api.asc_getLocaleExample2(item, exampleVal)}); + data.push({value: item, displayValue: me.api.asc_getLocaleExample(item, exampleVal)}); }); if (hasNegative) { this.cmbNegative.setData(data); @@ -432,7 +432,7 @@ define([ this.cmbCode.setValue(this.Format); } - this.lblExample.text(this.api.asc_getLocaleExample2(this.Format)); + this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); this._decimalPanel.toggleClass('hidden', !hasDecimal); this._negativePanel.css('visibility', hasNegative ? '' : 'hidden'); From 75904432d69a647ac9eab380ab5e2a33c97146eb Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 17 Jan 2017 14:04:55 +0300 Subject: [PATCH 11/16] [SSE] Change layout for FormatSettingsDialog. --- .../main/app/view/FormatSettingsDialog.js | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js index 1799682b8..ef2c57607 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js @@ -48,8 +48,8 @@ define([ SSE.Views.FormatSettingsDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { - contentWidth: 330, - height: 250 + contentWidth: 200, + height: 330 }, initialize : function(options) { @@ -88,60 +88,59 @@ define([ title: this.textTitle, template: [ '
    ', - '
    ', + '
    ', '
    ', - '', + '
    ', '', - '', + '', + '', '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', '', '', - '', - '', - '', - '', - '', '', '', - '', - '', - '', - '', - '', - '', '', '', - '', '', '
    ', - '', - '
    ', + '
    ', + '', + '
    ', '
    ', - '', - '', + '', + '
    ', + '', + '
    ', + '
    ', + '
    ', + '
    ', + '', + '
    ', '
    ', '', - '
    ', - '
    ', - '', - '
    ', - '
    ', - '
    ', + '
    ', '
    ', + '', '', - '
    ', - '
    ', - '', - '
    ', + '
    ', '
    ', + '', '', - '
    ', + '
    ', '
    ', '
    ', '
    ', '
    ', - '
    ', '