From a882b4530cbbcc7d10b68316b8d1611cd6143413 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 17 Mar 2020 17:55:37 +0300 Subject: [PATCH] [SSE] Add "Print titles" option to print dialog and page options --- .../main/app/controller/Print.js | 112 +++++++++++++++++- .../main/app/template/PrintSettings.template | 18 +++ .../main/app/view/FileMenuPanels.js | 57 ++++++++- .../main/app/view/PrintSettings.js | 41 ++++++- 4 files changed, 223 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 532047783..d4d40886a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -72,6 +72,7 @@ define([ onAfterRender: function(view) { this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings)); this.printSettings.btnOk.on('click', _.bind(this.querySavePrintSettings, this)); + this.fillComponents(this.printSettings); this.registerControlEvents(this.printSettings); }, @@ -157,6 +158,14 @@ define([ panel.chPrintGrid.setValue(props.asc_getGridLines(), true); panel.chPrintRows.setValue(props.asc_getHeadings(), true); + + // var value = props.asc_getPrintTitlesWidth(); + // panel.txtRangeTop.setValue((value) ? value : ''); + // panel.dataRangeTop = value; + // + // value = props.asc_getPrintTitlesHeight(); + // panel.txtRangeLeft.setValue((value) ? value : ''); + // panel.dataRangeLeft = value; }, fillPrintOptions: function(props) { @@ -214,6 +223,9 @@ define([ props.asc_setPageMargins(opt); + props.asc_setPrintTitlesWidth(panel.txtRangeTop.getValue()); + props.asc_setPrintTitlesHeight(panel.txtRangeLeft.getValue()); + return props; }, @@ -253,6 +265,7 @@ define([ this._changedProps = []; this.updateSettings(this.printSettingsDlg); this.printSettingsDlg.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettingsDlg)); + this.fillComponents(this.printSettingsDlg, true); this.fillPrintOptions(this.adjPrintParams); this.registerControlEvents(this.printSettingsDlg); },this) @@ -353,6 +366,8 @@ define([ panel.spnMarginRight.on('change', _.bind(this.propertyChange, this, panel)); panel.chPrintGrid.on('change', _.bind(this.propertyChange, this, panel)); panel.chPrintRows.on('change', _.bind(this.propertyChange, this, panel)); + panel.btnPresetsTop.menu.on('item:click', _.bind(this.onPresetSelect, this, panel, 'top')); + panel.btnPresetsLeft.menu.on('item:click', _.bind(this.onPresetSelect, this, panel, 'left')); }, propertyChange: function(panel, scale, combo, record) { @@ -407,9 +422,104 @@ define([ panel.cmbLayout.setValue(value, true); }, + fillComponents: function(panel, selectdata) { + var me = this; + panel.txtRangeTop.validation = function(value) { + if (_.isEmpty(value)) { + return true; + } + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); + return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true; + }; + panel.txtRangeLeft.validation = function(value) { + if (_.isEmpty(value)) { + return true; + } + var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); + return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true; + }; + var data = ((selectdata) ? [{caption: this.textSelectRange, value: 'select'}] : []).concat([ + {caption: this.textFrozenRows, value: 'frozen'}, + {caption: this.textFirstRow, value: 'first'}, + {caption: '--'}, + {caption: this.textNoRepeat, value: 'empty'} + ]); + panel.btnPresetsTop.setMenu(new Common.UI.Menu({ + style: 'min-width: 100px;', + maxHeight: 200, + items: data + })); + data = ((selectdata) ? [{caption: this.textSelectRange, value: 'select'}] : []).concat([ + {caption: this.textFrozenCols, value: 'frozen'}, + {caption: this.textFirstCol, value: 'first'}, + {caption: '--'}, + {caption: this.textNoRepeat, value: 'empty'} + ]); + panel.btnPresetsLeft.setMenu(new Common.UI.Menu({ + style: 'min-width: 100px;', + maxHeight: 200, + items: data + })); + }, + + onPresetSelect: function(panel, type, menu, item) { + var txtRange = (type=='top') ? panel.txtRangeTop : panel.txtRangeLeft; + if (item.value == 'select') { + var me = this; + if (me.api) { + var handlerDlg = function(dlg, result) { + if (result == 'ok') { + var valid = dlg.getSettings(); + if (type=='top') + panel.dataRangeTop = valid; + else + panel.dataRangeLeft = valid; + txtRange.setValue(valid); + txtRange.checkValidate(); + } + }; + + var win = new SSE.Views.CellRangeDialog({ + handler: handlerDlg + }).on('close', function() { + panel.show(); + }); + + var xy = panel.$window.offset(); + panel.hide(); + win.show(xy.left + 160, xy.top + 125); + win.setSettings({ + api : me.api, + range : (!_.isEmpty(txtRange.getValue()) && (txtRange.checkValidate()==true)) ? txtRange.getValue() : ((type=='top') ? panel.dataRangeTop : panel.dataRangeLeft), + type : Asc.c_oAscSelectionDialogType.Chart + }); + } + } else { + var value = ''; + if (item.value == 'frozen') + value = this.api.asc_getFrozen(type=='top'); + else if (item.value == 'first') + value = this.api.asc_getFirst(type=='top'); + txtRange.setValue(value); + txtRange.checkValidate(); + if (type=='top') + panel.dataRangeTop = value; + else + panel.dataRangeLeft = value; + } + }, + warnCheckMargings: 'Margins are incorrect', strAllSheets: 'All Sheets', textWarning: 'Warning', - txtCustom: 'Custom' + txtCustom: 'Custom', + textInvalidRange: 'ERROR! Invalid cells range', + textRepeat: 'Repeat...', + textNoRepeat: 'Not repeat', + textSelectRange: 'Select range...', + textFrozenRows: 'Frozen rows', + textFrozenCols: 'Frozen columns', + textFirstRow: 'First row', + textFirstCol: 'First column' }, SSE.Controllers.Print || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/template/PrintSettings.template b/apps/spreadsheeteditor/main/app/template/PrintSettings.template index fb527a994..370f4af71 100644 --- a/apps/spreadsheeteditor/main/app/template/PrintSettings.template +++ b/apps/spreadsheeteditor/main/app/template/PrintSettings.template @@ -17,6 +17,24 @@
+
+ + + + + + + + + + + + + + + +
+
diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index d5060d933..f7cdbfcb9 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -273,6 +273,27 @@ define([ '', '', '','', + '', + '', + '', + '','', '', '', '
', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '
', + '
', @@ -443,6 +464,36 @@ define([ }); this.spinners.push(this.spnMarginRight); + this.txtRangeTop = new Common.UI.InputField({ + el : $markup.findById('#advsettings-txt-top'), + style : 'width: 100%;', + allowBlank : true, + validateOnChange: true + }); + + this.btnPresetsTop = new Common.UI.Button({ + cls: 'btn-text-menu-default', + caption: this.textRepeat, + style: 'width: 95px;', + menu: true + }); + this.btnPresetsTop.render( $markup.findById('#advsettings-presets-top')) ; + + this.txtRangeLeft = new Common.UI.InputField({ + el : $markup.findById('#advsettings-txt-left'), + style : 'width: 100%;', + allowBlank : true, + validateOnChange: true + }); + + this.btnPresetsLeft = new Common.UI.Button({ + cls: 'btn-text-menu-default', + caption: this.textRepeat, + style: 'width: 95px;', + menu: true + }); + this.btnPresetsLeft.render( $markup.findById('#advsettings-presets-left')) ; + this.btnOk = new Common.UI.Button({ el: $markup.findById('#advsettings-print-button-save') }); @@ -539,7 +590,11 @@ define([ textFitCols: 'Fit All Columns on One Page', textFitRows: 'Fit All Rows on One Page', textCustomOptions: 'Custom Options', - textCustom: 'Custom' + textCustom: 'Custom', + strPrintTitles: 'Print Titles', + textRepeatTop: 'Repeat rows at top', + textRepeatLeft: 'Repeat columns at left', + textRepeat: 'Repeat...' }, SSE.Views.MainSettingsPrint || {})); SSE.Views.FileMenuPanels.MainSettingsGeneral = Common.UI.BaseView.extend(_.extend({ diff --git a/apps/spreadsheeteditor/main/app/view/PrintSettings.js b/apps/spreadsheeteditor/main/app/view/PrintSettings.js index cc635dece..01b73bbd2 100644 --- a/apps/spreadsheeteditor/main/app/view/PrintSettings.js +++ b/apps/spreadsheeteditor/main/app/view/PrintSettings.js @@ -51,7 +51,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', options: { alias: 'PrintSettings', contentWidth: 280, - height: 475, + height: 575, buttons: null }, @@ -67,6 +67,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', '
' + this.textPageSize + '
', '
' + this.textPageOrientation + '
', '
' + this.textPageScaling + '
', + '
' + this.strPrintTitles + '
', '
' + this.strMargins + '
', '
' + ((this.type == 'print') ? this.strPrint : this.strShow) + '
', '
', @@ -228,6 +229,36 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', itemsTemplate: itemsTemplate }); + this.txtRangeTop = new Common.UI.InputField({ + el : $('#printadv-dlg-txt-top'), + style : 'width: 100%;', + allowBlank : true, + validateOnChange: true + }); + + this.btnPresetsTop = new Common.UI.Button({ + cls: 'btn-text-menu-default', + caption: this.textRepeat, + style: 'width: 95px;', + menu: true + }); + this.btnPresetsTop.render( $('#printadv-dlg-presets-top')) ; + + this.txtRangeLeft = new Common.UI.InputField({ + el : $('#printadv-dlg-txt-left'), + style : 'width: 100%;', + allowBlank : true, + validateOnChange: true + }); + + this.btnPresetsLeft = new Common.UI.Button({ + cls: 'btn-text-menu-default', + caption: this.textRepeat, + style: 'width: 95px;', + menu: true + }); + this.btnPresetsLeft.render( $('#printadv-dlg-presets-left')) ; + this.btnHide = new Common.UI.Button({ el: $('#printadv-dlg-btn-hide') }); @@ -314,7 +345,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', } else { this.extended = false; this.panelDetails.css({'display': 'block'}); - this.setHeight(475); + this.setHeight(585); btn.setCaption(this.textHideDetails); Common.localStorage.setItem("sse-hide-print-settings", 0); } @@ -355,7 +386,11 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', textRange: 'Range', textIgnore: 'Ignore Print Area', textCustomOptions: 'Custom Options', - textCustom: 'Custom' + textCustom: 'Custom', + strPrintTitles: 'Print Titles', + textRepeatTop: 'Repeat rows at top', + textRepeatLeft: 'Repeat columns at left', + textRepeat: 'Repeat...' }, SSE.Views.PrintSettings || {})); }); \ No newline at end of file