From 02a400d75c4aef962113479ce345bb12a0bf5899 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 19 Oct 2021 19:03:31 +0300 Subject: [PATCH] [SSE] Make print with preview in file menu --- .../main/app/controller/Main.js | 3 +- .../main/app/controller/Print.js | 14 +++- .../main/app/view/FileMenu.js | 4 +- .../main/app/view/FileMenuPanels.js | 80 ++++++++++++++++--- 4 files changed, 83 insertions(+), 18 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 717d5a325..b72806304 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2509,7 +2509,8 @@ define([ this.getApplication().getController('RightMenu').updateMetricUnit(); this.getApplication().getController('Toolbar').getView('Toolbar').updateMetricUnit(); } - this.getApplication().getController('Print').getView('MainSettingsPrint').updateMetricUnit(); + //this.getApplication().getController('Print').getView('MainSettingsPrint').updateMetricUnit(); + this.getApplication().getController('Print').getView('PrintWithPreview').updateMetricUnit(); }, _compareActionStrong: function(obj1, obj2){ diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 6f22a4959..8bdb5e4bf 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -39,7 +39,8 @@ define([ SSE.Controllers.Print = Backbone.Controller.extend(_.extend({ views: [ - 'MainSettingsPrint' + 'MainSettingsPrint', + 'PrintWithPreview' ], initialize: function() { @@ -53,7 +54,11 @@ define([ this._originalPageSettings = null; this.addListeners({ - 'MainSettingsPrint': { + /*'MainSettingsPrint': { + 'show': _.bind(this.onShowMainSettingsPrint, this), + 'render:after': _.bind(this.onAfterRender, this) + },*/ + 'PrintWithPreview': { 'show': _.bind(this.onShowMainSettingsPrint, this), 'render:after': _.bind(this.onAfterRender, this) }, @@ -66,12 +71,13 @@ define([ }, onLaunch: function() { - this.printSettings = this.createView('MainSettingsPrint'); + //this.printSettings = this.createView('MainSettingsPrint'); + this.printSettings = this.createView('PrintWithPreview'); }, onAfterRender: function(view) { this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings)); - this.printSettings.btnOk.on('click', _.bind(this.querySavePrintSettings, this)); + this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this)); this.fillComponents(this.printSettings); this.registerControlEvents(this.printSettings); }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index 3352738ae..8e5b5f6d8 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -420,7 +420,9 @@ define([ } if (this.mode.canPrint) { - this.panels['print-with-preview'] = ((new SSE.Views.FileMenuPanels.PrintWithPreview({menu:this})).render(this.$el.find('#panel-print'))); + var printPanel = SSE.getController('Print').getView('PrintWithPreview'); + printPanel.menu = this; + this.panels['print-with-preview'] = printPanel.render(this.$el.find('#panel-print')); } }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index a82071b93..0754efbe4 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -210,9 +210,9 @@ define([ this.generalSettings.options = {alias:'MainSettingsGeneral'}; this.generalSettings.render($markup.findById('#panel-settings-general')); - this.printSettings = SSE.getController('Print').getView('MainSettingsPrint'); - this.printSettings.menu = this.menu; - this.printSettings.render($markup.findById('#panel-settings-print')); + //this.printSettings = SSE.getController('Print').getView('MainSettingsPrint'); + //this.printSettings.menu = this.menu; + //this.printSettings.render($markup.findById('#panel-settings-print')); this.spellcheckSettings = new SSE.Views.FileMenuPanels.MainSpellCheckSettings({menu: this.menu}); this.spellcheckSettings.render($markup.findById('#panel-settings-spellcheck')); @@ -221,7 +221,7 @@ define([ el: $markup.findById('#id-settings-menu'), store: new Common.UI.DataViewStore([ {name: this.txtGeneral, panel: this.generalSettings, iconCls:'toolbar__icon btn-settings', contentTarget: 'panel-settings-general', selected: true}, - {name: this.txtPageSettings, panel: this.printSettings, iconCls:'toolbar__icon btn-print', contentTarget: 'panel-settings-print'}, + //{name: this.txtPageSettings, panel: this.printSettings, iconCls:'toolbar__icon btn-print', contentTarget: 'panel-settings-print'}, {name: this.txtSpellChecking, panel: this.spellcheckSettings, iconCls:'toolbar__icon btn-ic-docspell', contentTarget: 'panel-settings-spellcheck'} ]), itemTemplate: _.template([ @@ -2678,7 +2678,7 @@ define([ }, SSE.Views.FileMenuPanels.ProtectDoc || {})); - SSE.Views.FileMenuPanels.PrintWithPreview = Common.UI.BaseView.extend(_.extend({ + SSE.Views.PrintWithPreview = Common.UI.BaseView.extend(_.extend({ el: '#panel-print', menu: undefined, @@ -2746,7 +2746,7 @@ define([ '', '', '', '', @@ -2755,7 +2755,7 @@ define([ '', '', @@ -2773,6 +2773,7 @@ define([ this.menu = options.menu; this.spinners = []; + this._initSettings = true; }, render: function(node) { @@ -2792,7 +2793,6 @@ define([ { value: Asc.c_oAscPrintType.Selection, displayValue: this.txtSelection } ] }); - this.cmbRange.on('selected', _.bind(this.onChangeComboRange, this)); this.chIgnorePrintArea = new Common.UI.CheckBox({ el: $markup.findById('#print-chb-ignore'), @@ -2952,13 +2952,16 @@ define([ this.btnApplyAll = new Common.UI.Button({ el: $markup.findById('#print-apply-all') }); - this.btnApplyAll.on('click', _.bind(this.onApplyToAll, this)); this.pnlSettings = $markup.find('.flex-settings').addBack().filter('.flex-settings'); this.pnlApply = $markup.find('.fms-flex-apply').addBack().filter('.fms-flex-apply'); this.pnlTable = $(this.pnlSettings.find('table')[0]); this.trApply = $markup.find('.fms-btn-apply'); + this.btnSave = new Common.UI.Button({ + el: $markup.findById('#print-button-save') + }); + this.$el = $(node).html($markup); if (_.isUndefined(this.scroller)) { @@ -2975,13 +2978,21 @@ define([ } }); + this.updateMetricUnit(); + + this.fireEvent('render:after', this); + return this; }, show: function() { Common.UI.BaseView.prototype.show.call(this,arguments); - + if (this._initSettings) { + this.updateMetricUnit(); + this._initSettings = false; + } this.updateScroller(); + this.fireEvent('show', this); }, updateScroller: function() { @@ -3004,12 +3015,56 @@ define([ }, - onChangeComboRange: function () { + updateMetricUnit: function() { + if (this.spinners) { + for (var i=0; i