From abbe7080d5e623b13baadd28cab56c2dcc78fe42 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 8 Feb 2022 00:04:34 +0300 Subject: [PATCH] [SSE] Fix print preview when there is nothing to print --- .../main/app/controller/Print.js | 12 +++++++++--- .../main/app/view/FileMenuPanels.js | 9 ++++++++- apps/spreadsheeteditor/main/locale/en.json | 1 + .../main/resources/less/leftmenu.less | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index 9b869fb01..71905d799 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -297,6 +297,7 @@ define([ onShowMainSettingsPrint: function() { this._changedProps = []; + this.printSettings.$previewBox.removeClass('hidden'); if (!this.isFillSheets) { this.isFillSheets = true; @@ -306,10 +307,15 @@ define([ this.fillPrintOptions(this.adjPrintParams, false); var pageCount = this.api.asc_initPrintPreview('print-preview'); - this.updateNavigationButtons(0, pageCount); - this.printSettings.txtNumberPage.checkValidate(); - this._isPreviewVisible = true; + this.printSettings.$previewBox.toggleClass('hidden', !pageCount); + this.printSettings.$previewEmpty.toggleClass('hidden', !!pageCount); + if (!!pageCount) { + this.updateNavigationButtons(0, pageCount); + this.printSettings.txtNumberPage.checkValidate(); + + this._isPreviewVisible = true; + } }, openPrintSettings: function(type, cmp, format, asUrl) { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 6dc6dfe06..3b4e313fd 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2349,6 +2349,9 @@ define([ '', '', '', + '', '' ].join('')), @@ -2648,6 +2651,9 @@ define([ this.$el.on('click', '#print-header-footer-settings', _.bind(this.openHeaderSettings, this)); this.$headerSettings = $('#print-header-footer-settings'); + this.$previewBox = $('#print-preview-box'); + this.$previewEmpty = $('#print-preview-empty'); + if (_.isUndefined(this.scroller)) { this.scroller = new Common.UI.Scroller({ el: this.pnlSettings, @@ -2828,7 +2834,8 @@ define([ txtPage: 'Page', txtOf: 'of {0}', txtSheet: 'Sheet: {0}', - txtPageNumInvalid: 'Page number invalid' + txtPageNumInvalid: 'Page number invalid', + txtEmptyTable: 'There is nothing to print because the table is empty' }, SSE.Views.PrintWithPreview || {})); }); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 816e3b44e..820634116 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2783,6 +2783,7 @@ "SSE.Views.PrintWithPreview.txtSettingsOfSheet": "Settings of sheet", "SSE.Views.PrintWithPreview.txtSheet": "Sheet: {0}", "SSE.Views.PrintWithPreview.txtTop": "Top", + "SSE.Views.PrintWithPreview.txtEmptyTable": "There is nothing to print because the table is empty", "SSE.Views.ProtectDialog.textExistName": "ERROR! Range with such a title already exists", "SSE.Views.ProtectDialog.textInvalidName": "The range title must begin with a letter and may only contain letters, numbers, and spaces.", "SSE.Views.ProtectDialog.textInvalidRange": "ERROR! Invalid cells range", diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index bbd690c39..67dafde38 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -520,6 +520,24 @@ #panel-print { padding: 0; + #print-preview-empty { + padding: 14px; + color: @text-tertiary-ie; + color: @text-tertiary; + + position: absolute; + left: 280px; + top: 0; + right: 0; + bottom: 0; + display: flex; + justify-content: center; + align-items: center; + + div { + text-align: center; + } + } #id-print-settings { position: absolute; width:280px;