From d8e79bded782fc50b3eec8a24ccb498250a2948a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 18 Mar 2020 13:06:18 +0300 Subject: [PATCH] [SSE] Print titles: check frozen areas, check print ranges --- .../main/app/controller/Print.js | 36 ++++++++++------ .../main/app/view/FileMenuPanels.js | 28 ++++++------- .../main/app/view/PrintSettings.js | 8 ++-- .../main/app/view/PrintTitlesDialog.js | 41 +++++++++++++------ 4 files changed, 70 insertions(+), 43 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 3a3231343..ac0876c32 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -111,10 +111,10 @@ define([ }, comboSheetsChange: function(panel, combo, record) { - this.fillPageOptions(panel, this._changedProps[record.value] ? this._changedProps[record.value] : this.api.asc_getPageOptions(record.value)); + this.fillPageOptions(panel, this._changedProps[record.value] ? this._changedProps[record.value] : this.api.asc_getPageOptions(record.value), record.value); }, - fillPageOptions: function(panel, props) { + fillPageOptions: function(panel, props, sheet) { var opt = props.asc_getPageSetup(); this._originalPageSettings = opt; @@ -159,13 +159,18 @@ 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; + var value = props.asc_getPrintTitlesWidth(); + panel.txtRangeTop.setValue((value) ? value : ''); + panel.txtRangeTop.checkValidate(); + panel.dataRangeTop = value; + + value = props.asc_getPrintTitlesHeight(); + panel.txtRangeLeft.setValue((value) ? value : ''); + panel.txtRangeLeft.checkValidate(); + panel.dataRangeLeft = value; + + panel.btnPresetsTop.menu.items[panel.btnPresetsTop.menu.items[0].value == 'frozen' ? 0 : 1].setDisabled(!this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, false, sheet)); + panel.btnPresetsLeft.menu.items[panel.btnPresetsLeft.menu.items[0].value == 'frozen' ? 0 : 1].setDisabled(!this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, true, sheet)); }, fillPrintOptions: function(props) { @@ -223,8 +228,11 @@ define([ props.asc_setPageMargins(opt); - props.asc_setPrintTitlesWidth(panel.txtRangeTop.getValue()); - props.asc_setPrintTitlesHeight(panel.txtRangeLeft.getValue()); + var check = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.None, panel.txtRangeTop.getValue(), false) !== Asc.c_oAscError.ID.DataRangeError; + props.asc_setPrintTitlesWidth(check ? panel.txtRangeTop.getValue() : panel.dataRangeTop); + + check = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.None, panel.txtRangeLeft.getValue(), false) !== Asc.c_oAscError.ID.DataRangeError; + props.asc_setPrintTitlesHeight(check ? panel.txtRangeLeft.getValue() : panel.dataRangeLeft); return props; }, @@ -366,6 +374,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.txtRangeTop.on('changing', _.bind(this.propertyChange, this, panel)); + panel.txtRangeLeft.on('changing', _.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')); }, @@ -425,6 +435,7 @@ define([ fillComponents: function(panel, selectdata) { var me = this; panel.txtRangeTop.validation = function(value) { + me.propertyChange(panel); if (_.isEmpty(value)) { return true; } @@ -432,6 +443,7 @@ define([ return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true; }; panel.txtRangeLeft.validation = function(value) { + me.propertyChange(panel); if (_.isEmpty(value)) { return true; } @@ -491,7 +503,7 @@ define([ win.setSettings({ api : me.api, range : (!_.isEmpty(txtRange.getValue()) && (txtRange.checkValidate()==true)) ? txtRange.getValue() : ((type=='top') ? panel.dataRangeTop : panel.dataRangeLeft), - type : Asc.c_oAscSelectionDialogType.None + type : Asc.c_oAscSelectionDialogType.Chart }); } } else { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index f7cdbfcb9..6280bba42 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -275,21 +275,21 @@ define([ '','', '', '', - '
', + '
', '', '', '', - '', - '', - '', - '', '', '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', '
', '
', @@ -466,7 +466,7 @@ define([ this.txtRangeTop = new Common.UI.InputField({ el : $markup.findById('#advsettings-txt-top'), - style : 'width: 100%;', + style : 'width: 147px', allowBlank : true, validateOnChange: true }); @@ -474,14 +474,14 @@ define([ this.btnPresetsTop = new Common.UI.Button({ cls: 'btn-text-menu-default', caption: this.textRepeat, - style: 'width: 95px;', + style: 'width: 85px;', 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%;', + style : 'width: 147px', allowBlank : true, validateOnChange: true }); @@ -489,7 +489,7 @@ define([ this.btnPresetsLeft = new Common.UI.Button({ cls: 'btn-text-menu-default', caption: this.textRepeat, - style: 'width: 95px;', + style: 'width: 85px;', menu: true }); this.btnPresetsLeft.render( $markup.findById('#advsettings-presets-left')) ; diff --git a/apps/spreadsheeteditor/main/app/view/PrintSettings.js b/apps/spreadsheeteditor/main/app/view/PrintSettings.js index 01b73bbd2..dcc094692 100644 --- a/apps/spreadsheeteditor/main/app/view/PrintSettings.js +++ b/apps/spreadsheeteditor/main/app/view/PrintSettings.js @@ -231,7 +231,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', this.txtRangeTop = new Common.UI.InputField({ el : $('#printadv-dlg-txt-top'), - style : 'width: 100%;', + style : 'width: 147px;', allowBlank : true, validateOnChange: true }); @@ -239,14 +239,14 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', this.btnPresetsTop = new Common.UI.Button({ cls: 'btn-text-menu-default', caption: this.textRepeat, - style: 'width: 95px;', + style: 'width: 85px;', menu: true }); this.btnPresetsTop.render( $('#printadv-dlg-presets-top')) ; this.txtRangeLeft = new Common.UI.InputField({ el : $('#printadv-dlg-txt-left'), - style : 'width: 100%;', + style : 'width: 147px;', allowBlank : true, validateOnChange: true }); @@ -254,7 +254,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', this.btnPresetsLeft = new Common.UI.Button({ cls: 'btn-text-menu-default', caption: this.textRepeat, - style: 'width: 95px;', + style: 'width: 85px;', menu: true }); this.btnPresetsLeft.render( $('#printadv-dlg-presets-left')) ; diff --git a/apps/spreadsheeteditor/main/app/view/PrintTitlesDialog.js b/apps/spreadsheeteditor/main/app/view/PrintTitlesDialog.js index ccc5034f9..d779139f3 100644 --- a/apps/spreadsheeteditor/main/app/view/PrintTitlesDialog.js +++ b/apps/spreadsheeteditor/main/app/view/PrintTitlesDialog.js @@ -134,6 +134,7 @@ define([ } }); + var frozen = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, false, this.sheet); this.btnPresetsTop = new Common.UI.Button({ cls: 'btn-text-menu-default', caption: this.textRepeat, @@ -144,10 +145,10 @@ define([ additionalAlign: this.menuAddAlign, items: [ {caption: this.textSelectRange, value: 'select'}, - {caption: this.textFrozenRows, value: 'frozen'}, - {caption: this.textFirstRow, value: 'first'}, + {caption: this.textFrozenRows, value: 'frozen', range: frozen, disabled: !frozen}, + {caption: this.textFirstRow, value: 'first', range: this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.first, false, this.sheet)}, {caption: '--'}, - {caption: this.textNoRepeat, value: 'empty'} + {caption: this.textNoRepeat, value: 'empty', range: ''} ] }) }); @@ -168,6 +169,7 @@ define([ } }); + frozen = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, true, this.sheet); this.btnPresetsLeft = new Common.UI.Button({ cls: 'btn-text-menu-default', caption: this.textRepeat, @@ -178,10 +180,10 @@ define([ additionalAlign: this.menuAddAlign, items: [ {caption: this.textSelectRange, value: 'select'}, - {caption: this.textFrozenCols, value: 'frozen'}, - {caption: this.textFirstCol, value: 'first'}, + {caption: this.textFrozenCols, value: 'frozen', range: frozen, disabled: !frozen}, + {caption: this.textFirstCol, value: 'first', range: this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.first, true, this.sheet)}, {caption: '--'}, - {caption: this.textNoRepeat, value: 'empty'} + {caption: this.textNoRepeat, value: 'empty', range: ''} ] }) }); @@ -195,9 +197,26 @@ define([ this.setSettings(); }, + isRangeValid: function() { + if (this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.None, this.txtRangeTop.getValue(), false) == Asc.c_oAscError.ID.DataRangeError) { + this.txtRangeTop.cmpEl.find('input').focus(); + return false; + } + if (this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.None, this.txtRangeLeft.getValue(), false) == Asc.c_oAscError.ID.DataRangeError) { + this.txtRangeLeft.cmpEl.find('input').focus(); + return false; + } + return true; + }, + _handleInput: function(state) { - if (this.options.handler) + if (this.options.handler) { + if (state == 'ok') { + if (!this.isRangeValid()) + return; + } this.options.handler.call(this, this, state); + } this.close(); }, @@ -257,15 +276,11 @@ define([ win.setSettings({ api : me.api, range : (!_.isEmpty(txtRange.getValue()) && (txtRange.checkValidate()==true)) ? txtRange.getValue() : ((type=='top') ? me.dataRangeTop : me.dataRangeLeft), - type : Asc.c_oAscSelectionDialogType.None + type : Asc.c_oAscSelectionDialogType.Chart }); } } else { - var value = ''; - if (item.value == 'frozen') - value = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, type=='left', this.sheet); - else if (item.value == 'first') - value = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.first, type=='left', this.sheet); + var value = item.options.range || ''; txtRange.setValue(value); txtRange.checkValidate(); if (type=='top')