From 5794800988122e9197308c3567ed88b1db8b50ab Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 7 Dec 2020 22:20:22 +0300 Subject: [PATCH] [SSE] Change axis label format --- .../main/app/controller/Main.js | 1 + .../main/app/view/ChartSettingsDlg.js | 32 ++++++++++-- .../main/app/view/FormatSettingsDialog.js | 49 +++++++++++++++---- 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index a8fcf876e..3abcd0296 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -385,6 +385,7 @@ define([ reg = (this.editorConfig.lang) ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.editorConfig.lang)) : 0x0409; this.api.asc_setLocale(reg, decimal, group); } + Common.Utils.InternalSettings.set("sse-config-lang", this.editorConfig.lang); var value = Common.localStorage.getBool("sse-settings-r1c1"); Common.Utils.InternalSettings.set("sse-settings-r1c1", value); diff --git a/apps/spreadsheeteditor/main/app/view/ChartSettingsDlg.js b/apps/spreadsheeteditor/main/app/view/ChartSettingsDlg.js index baa36f167..6fd5f62d4 100644 --- a/apps/spreadsheeteditor/main/app/view/ChartSettingsDlg.js +++ b/apps/spreadsheeteditor/main/app/view/ChartSettingsDlg.js @@ -513,7 +513,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template' me.btnVFormat[i] = new Common.UI.Button({ el: $('#chart-dlg-btn-v-format-' + i) - }).on('click', _.bind(me.openFormat, me, me.currentAxisProps[i])); + }).on('click', _.bind(me.openFormat, me, i)); }; addControlsV(0); addControlsV(1); @@ -764,7 +764,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template' me.btnHFormat[i] = new Common.UI.Button({ el: $('#chart-dlg-btn-h-format-' + i) - }).on('click', _.bind(me.openFormat, me, me.currentAxisProps[i])); + }).on('click', _.bind(me.openFormat, me, i)); }; addControlsH(0); addControlsH(1); @@ -1681,7 +1681,33 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template' } }, - openFormat: function(props) { + openFormat: function(index) { + var me = this, + props = me.currentAxisProps[index], + fmt = props.getNumFmt(), + value = me.api.asc_getLocale(), + lang = Common.Utils.InternalSettings.get("sse-config-lang"); + (!value) && (value = (lang ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(lang)) : 0x0409)); + + var win = (new SSE.Views.FormatSettingsDialog({ + api: me.api, + handler: function(result, settings) { + if (result=='ok' && settings) { + fmt.putSourceLinked(settings.linked); + fmt.putFormatCode(settings.format); + me.chartSettings.endEditData(); + me._isEditFormat = false; + } + }, + linked: true, + props : {format: fmt.getFormatCode(), formatInfo: fmt.getFormatCellsInfo(), langId: value, linked: fmt.getSourceLinked()} + })).on('close', function() { + me._isEditFormat && me.chartSettings.cancelEditData(); + me._isEditFormat = false; + }); + me._isEditFormat = true; + me.chartSettings.startEditData(); + win.show(); }, show: function() { diff --git a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js index 169b2bb0c..2c50c7028 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/FormatSettingsDialog.js @@ -84,10 +84,17 @@ define([ me.CurrencySymbolsData = null; me.langId = 0x0409; + this.api = options.api; + this.handler = options.handler; + this.props = options.props; + this.linked = options.linked || false; + + var height = this.linked ? 360 : 340; _.extend(this.options, { title: this.textTitle, + height: height, template: [ - '
', + '
', '
', '
', '', @@ -99,8 +106,8 @@ define([ '', '', '', '', '', @@ -143,6 +150,11 @@ define([ '
', '', '', + '', + '', + '', '
', - '', - '', + '', + '', '
', + '
', + '
', '
', '
', @@ -151,13 +163,9 @@ define([ ].join('') }, options); - this.api = options.api; - this.handler = options.handler; - this.props = options.props; - this._state = {hasDecimal: false, hasNegative: false, hasSeparator: false, hasType: false, hasSymbols: false, hasCode: false}; - Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + this._state = {hasDecimal: false, hasNegative: false, hasSeparator: false, hasType: false, hasSymbols: false, hasCode: false}; this.FormatType = Asc.c_oAscNumFormatType.General; this.Format = "General"; this.CustomFormat = null; @@ -247,8 +255,18 @@ define([ me.codesList.deselectAll(); me.Format = me.api.asc_convertNumFormatLocal2NumFormat(value); me.lblExample.text(me.api.asc_getLocaleExample(me.Format)); + me.chLinked.setValue(false, true); }); + this.chLinked = new Common.UI.CheckBox({ + el: $('#format-settings-chk-linked'), + labelText: this.textLinked + }).on ('change', function (field, newValue, oldValue, eOpts) { + if (field.getValue()=='checked') + me._setDefaults(me.props); + }); + this.chLinked.setVisible(this.linked); + this._decimalPanel = this.$window.find('.format-decimal'); this._negativePanel = this.$window.find('.format-negative'); this._separatorPanel = this.$window.find('.format-separator'); @@ -256,6 +274,7 @@ define([ this._symbolsPanel = this.$window.find('.format-symbols'); this._codePanel = this.$window.find('.format-code'); this._nocodePanel = this.$window.find('.format-no-code'); + this.$window.find('.format-sample').toggleClass('hidden', this.linked); this.lblExample = this.$window.find('#format-settings-label-example'); @@ -320,10 +339,11 @@ define([ // for date/time - if props.format not in cmbType - setValue(this.api.asc_getLocaleExample(props.format, 38822)) // for cmbNegative - if props.format not in cmbNegative - setValue(this.api.asc_getLocaleExample(props.format)) } + props && this.chLinked.setValue(!!props.linked, true); }, getSettings: function () { - return {format: this.Format}; + return {format: this.Format, linked: this.chLinked.getValue()==='checked'}; }, onDlgBtnClick: function(event) { @@ -344,6 +364,7 @@ define([ onNegativeSelect: function(combo, record) { this.Format = record.value; this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); + this.chLinked.setValue(false, true); }, onSymbolsSelect: function(combo, record) { @@ -365,6 +386,7 @@ define([ this.Format = format[0]; this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); + this.chLinked.setValue(false, true); }, onDecimalChange: function(field, newValue, oldValue, eOpts){ @@ -390,6 +412,7 @@ define([ } this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); + this.chLinked.setValue(false, true); }, onSeparatorChange: function(field, newValue, oldValue, eOpts){ @@ -410,11 +433,13 @@ define([ this.Format = format[0]; this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); + this.chLinked.setValue(false, true); }, onTypeSelect: function(combo, record){ this.Format = record.value; this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); + this.chLinked.setValue(false, true); }, onCodeSelect: function(listView, itemView, record){ @@ -423,6 +448,7 @@ define([ this.Format = record.get('format'); this.lblExample.text(this.api.asc_getLocaleExample(this.Format)); this.inputCustomFormat.setValue(record.get('value')); + this.chLinked.setValue(false, true); }, onFormatSelect: function(combo, record, e, initFormatInfo) { @@ -536,6 +562,8 @@ define([ this._codePanel.toggleClass('hidden', !hasCode); this._nocodePanel.toggleClass('hidden', hasCode); this._state = { hasDecimal: hasDecimal, hasNegative: hasNegative, hasSeparator: hasSeparator, hasType: hasType, hasSymbols: hasSymbols, hasCode: hasCode}; + + !initFormatInfo && this.chLinked.setValue(false, true); }, textTitle: 'Number Format', @@ -565,7 +593,8 @@ define([ txtAs10: 'As tenths (5/10)', txtAs100: 'As hundredths (50/100)', txtSample: 'Sample:', - txtNone: 'None' + txtNone: 'None', + textLinked: 'Linked to source' }, SSE.Views.FormatSettingsDialog || {})) }); \ No newline at end of file