From ff233c9043ae0e1177d4956e50feb67d438fe9ff Mon Sep 17 00:00:00 2001 From: OVSharova Date: Thu, 19 Jan 2023 16:14:24 +0300 Subject: [PATCH] add item Long Date --- .../main/app/controller/DocumentHolder.js | 5 +++- .../main/app/controller/Toolbar.js | 20 ++++++++++++---- .../main/app/view/FormatRulesEditDlg.js | 23 ++++++++++++++++--- .../main/app/view/Toolbar.js | 5 +++- apps/spreadsheeteditor/main/locale/en.json | 4 ++++ 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 04625bc0ac..648f5d8213 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -4164,8 +4164,11 @@ define([ info.asc_setType(Asc.c_oAscNumFormatType.None); info.asc_setSymbol(this._state.langId); var arr = this.api.asc_getFormatCells(info); // all formats + var disp=0 for (var i=0; i Asc.c_oAscNumFormatType.Date)|0; + this.toolbar.cmbNumberFormat.setRawValue( + (numformattype === Asc.c_oAscNumFormatType.Date) ? this.toolbar.txtDate : this.toolbar.numFormatData[indexNFD].displayValue + ); + }, + onDecrement: function(btn) { if (this.api) this.api.asc_decreaseCellDigitNumbers(); @@ -3190,8 +3200,8 @@ define([ this._state.numformatinfo = val; val = val.asc_getType(); if (this._state.numformattype !== val) { - toolbar.cmbNumberFormat.setValue(val, toolbar.txtCustom); this._state.numformattype = val; + this.cmbNumberFormatSetValue(); } } @@ -3348,8 +3358,8 @@ define([ this._state.numformatinfo = val; val = val.asc_getType(); if (this._state.numformattype !== val) { - me.toolbar.cmbNumberFormat.setValue(val, me.toolbar.txtCustom); this._state.numformattype = val; + this.cmbNumberFormatSetValue(); } } }, @@ -3719,8 +3729,8 @@ define([ this._state.numformatinfo = val; val = val.asc_getType(); if (this._state.numformattype !== val) { - me.toolbar.cmbNumberFormat.setValue(val, me.toolbar.txtCustom); this._state.numformattype = val; + this.cmbNumberFormatSetValue(); } } }, diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js index a5f8eaf6e6..6a2ad9e2bf 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js @@ -579,7 +579,8 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', { 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.Date, format: 'MM-dd-yyyy', displayValue: this.txtDateShort, exampleval: '04-09-1900' }, + { value: Asc.c_oAscNumFormatType.Date, format: 'MMMM d yyyy', displayValue: this.txtDateLong, exampleval: 'April-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' }, @@ -620,8 +621,9 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', data : this.numFormatData, takeFocusOnClose: true }); - this.cmbNumberFormat.setValue(Asc.c_oAscNumFormatType.General); + this.cmbNumberFormat.setRawValue(this.numFormatData[Asc.c_oAscNumFormatType.General].displayValue); this.cmbNumberFormat.on('selected', _.bind(this.onNumberFormatSelect, this)); + this.cmbNumberFormat.on('show:before', _.bind(this.onNumberFormatShowBefore, this)); Common.UI.FocusManager.add(this, this.cmbNumberFormat); this.btnClear = new Common.UI.Button({ @@ -1313,7 +1315,13 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', color = this.setColor(xfs.asc_getFillColor(), this.btnFillColor, this.mnuFillColorPicker); var val = xfs.asc_getNumFormatInfo(); - val && this.cmbNumberFormat.setValue(val.asc_getType(), this.textCustom); + if (val) { + val = val.asc_getType(); + var indexNFD = val + (val > Asc.c_oAscNumFormatType.Date)|0; + this.cmbNumberFormat.setRawValue( + (val === Asc.c_oAscNumFormatType.Date) ? this.txtDate : this.numFormatData[indexNFD].displayValue + ); + } } }, @@ -1738,6 +1746,13 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', !this.xfsFormat && (this.xfsFormat = new Asc.asc_CellXfs()); this.xfsFormat.asc_setNumFormatInfo(record.format); this.previewFormat(); + this.cmbNumberFormat.setRawValue( + (record.value === Asc.c_oAscNumFormatType.Date) ? this.txtDate : record.displayValue); + }, + + onNumberFormatShowBefore: function (){ + var rec = $('.selected', $(this.cmbNumberFormat.el)); + rec && rec.removeClass('selected');; }, previewFormat: function() { @@ -2179,6 +2194,8 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', txtCurrency: 'Currency', txtAccounting: 'Accounting', txtDate: 'Date', + txtDateShort: 'Short Date', + txtDateLong: 'Long Date', txtTime: 'Time', txtPercentage: 'Percentage', txtFraction: 'Fraction', diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 2b9578f5c0..07af40c093 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -167,7 +167,8 @@ define([ { 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.Date, format: 'MM-dd-yyyy', displayValue: this.txtDateShort, exampleval: '04-09-1900' }, + { value: Asc.c_oAscNumFormatType.Date, format: 'MMMM d yyyy', displayValue: this.txtDateLong, exampleval: 'April 9 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' }, @@ -3247,6 +3248,8 @@ define([ // txtFranc: 'CHF Swiss franc', txtAccounting: 'Accounting', txtDate: 'Date', + txtDateShort: 'Short Date', + txtDateLong: 'Long Date', txtTime: 'Time', txtDateTime: 'Date & Time', txtPercentage: 'Percentage', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 394ffb2890..a4f3b5e9dc 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2576,6 +2576,8 @@ "SSE.Views.FormatRulesEditDlg.txtAccounting": "Accounting", "SSE.Views.FormatRulesEditDlg.txtCurrency": "Currency", "SSE.Views.FormatRulesEditDlg.txtDate": "Date", + "SSE.Views.FormatRulesEditDlg.txtDateLong": "Long Date", + "SSE.Views.FormatRulesEditDlg.txtDateShort": "Short Date", "SSE.Views.FormatRulesEditDlg.txtEmpty": "This field is required", "SSE.Views.FormatRulesEditDlg.txtFraction": "Fraction", "SSE.Views.FormatRulesEditDlg.txtGeneral": "General", @@ -3846,6 +3848,8 @@ "SSE.Views.Toolbar.txtCurrency": "Currency", "SSE.Views.Toolbar.txtCustom": "Custom", "SSE.Views.Toolbar.txtDate": "Date", + "SSE.Views.Toolbar.txtDateLong": "Long Date", + "SSE.Views.Toolbar.txtDateShort": "Date Short", "SSE.Views.Toolbar.txtDateTime": "Date & Time", "SSE.Views.Toolbar.txtDescending": "Descending", "SSE.Views.Toolbar.txtDollar": "$ Dollar",