From 409223d72607caeba5d33f519c130509037d2bdf Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 10 Sep 2024 22:28:37 +0300 Subject: [PATCH] [Wopi] Show file extension when save copy --- apps/common/main/lib/component/InputField.js | 10 ++++++++++ apps/common/main/lib/view/TextInputDialog.js | 20 +++++++++++++++++-- apps/common/main/resources/less/input.less | 15 +++----------- .../main/app/controller/LeftMenu.js | 11 +++++----- apps/documenteditor/main/app/view/FormsTab.js | 1 + .../pdfeditor/main/app/controller/LeftMenu.js | 11 +++++----- apps/pdfeditor/main/app/view/Toolbar.js | 1 + .../main/app/controller/LeftMenu.js | 11 +++++----- .../main/app/controller/LeftMenu.js | 11 +++++----- 9 files changed, 57 insertions(+), 34 deletions(-) diff --git a/apps/common/main/lib/component/InputField.js b/apps/common/main/lib/component/InputField.js index a46b2345f4..59b2ded54f 100644 --- a/apps/common/main/lib/component/InputField.js +++ b/apps/common/main/lib/component/InputField.js @@ -751,6 +751,8 @@ define([ style : '', value : '', fixedValue : '', + fixedWidth : '', + fixedCls : '', type : 'text', name : '', validation : null, @@ -786,6 +788,8 @@ define([ initialize : function(options) { this.fixedValue = options.fixedValue; + this.fixedWidth = options.fixedWidth || 'calc(50% + 4px)'; + this.fixedCls = options.fixedCls || ''; Common.UI.InputField.prototype.initialize.call(this, options); }, @@ -793,6 +797,12 @@ define([ render : function(parentEl) { Common.UI.InputField.prototype.render.call(this, parentEl); + this._input.css({ + 'padding-left': Common.UI.isRTL() ? this.fixedWidth : 0, + 'padding-right': Common.UI.isRTL() ? 0: this.fixedWidth, + }); + this.cmpEl.find('input.fixed-text').css({'width': this.fixedWidth}).addClass(this.fixedCls); + if (this.fixedValue) this.setFixedValue(this.fixedValue); diff --git a/apps/common/main/lib/view/TextInputDialog.js b/apps/common/main/lib/view/TextInputDialog.js index ed0e0c4e6d..bbd4b5cb60 100644 --- a/apps/common/main/lib/view/TextInputDialog.js +++ b/apps/common/main/lib/view/TextInputDialog.js @@ -68,6 +68,8 @@ define([], function () { 'use strict'; allowBlank: true }, options.inputConfig || {}); + this.inputFixedConfig = options.inputFixedConfig; + _options.tpl = _.template(this.template)(_options); Common.UI.Window.prototype.initialize.call(this, _options); }, @@ -76,13 +78,27 @@ define([], function () { 'use strict'; Common.UI.Window.prototype.render.call(this); var me = this; - me.inputLabel = new Common.UI.InputField({ + me.inputLabel = !this.inputFixedConfig ? new Common.UI.InputField({ el : $('#id-dlg-label-custom-input'), allowBlank : me.inputConfig.allowBlank, blankError : me.inputConfig.blankError, style : 'width: 100%;', validateOnBlur: false, validation : me.inputConfig.validation + }) : new Common.UI.InputFieldFixed({ + el : $('#id-dlg-label-custom-input'), + allowBlank : me.inputConfig.allowBlank, + blankError : me.inputConfig.blankError, + style : 'width: 100%;', + validateOnBlur: false, + validation : me.inputConfig.validation, + cls : 'text-align-left', + fixedValue : me.inputFixedConfig.fixedValue, + fixedCls : 'light', + fixedWidth : me.inputFixedConfig.fixedWidth + }); + me.inputLabel.cmpEl.on('focus', 'input.fixed-text', function() { + setTimeout(function(){me.inputLabel._input && me.inputLabel._input.focus();}, 1); }); me.inputLabel.setValue(me.options.value || ''); var $window = this.getChild(); @@ -90,7 +106,7 @@ define([], function () { 'use strict'; }, getFocusedComponents: function() { - return [this.inputLabel].concat(this.getFooterButtons()); + return [{cmp: this.inputLabel, selector: 'input:not(.fixed-text)'}].concat(this.getFooterButtons()); }, getDefaultFocusableComponent: function () { diff --git a/apps/common/main/resources/less/input.less b/apps/common/main/resources/less/input.less index ad89f1459f..eeda789017 100644 --- a/apps/common/main/resources/less/input.less +++ b/apps/common/main/resources/less/input.less @@ -186,22 +186,10 @@ textarea.form-control:focus { .input-field-fixed { position: relative; - input:not(.fixed-text) { - .text-align-right(); - padding-right: 50%; - padding-right: calc(50% + 4px); - .rtl & { - padding-left: 50%; - padding-right: 0; - } - } - .fixed-text { position: absolute; right: 0; top: 0; - width: 50%; - width: calc(50% + 4px); border-color: transparent; background: transparent; .text-align-left(); @@ -215,6 +203,9 @@ textarea.form-control:focus { left: 0; } } + .fixed-text.light { + opacity: 0.8; + } &.disabled .fixed-text { opacity: @component-disabled-opacity-ie; opacity: @component-disabled-opacity; diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 13880c0679..03b6460882 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -448,16 +448,17 @@ define([ var me = this, defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption(); !defFileName && (defFileName = me.txtUntitled); - if (typeof ext === 'string') { - var idx = defFileName.lastIndexOf('.'); - if (idx>0) - defFileName = defFileName.substring(0, idx) + ext; - } + var idx = defFileName.lastIndexOf('.'); + if (idx>0) + defFileName = defFileName.substring(0, idx); (new Common.Views.TextInputDialog({ label: me.textSelectPath, value: defFileName || '', + inputFixedConfig: {fixedValue: ext, fixedWidth: 40}, handler: function(result, value) { if (result == 'ok') { + if (typeof ext === 'string') + value = value + ext; me.clickSaveAsFormat(menu, format, ext, value); } } diff --git a/apps/documenteditor/main/app/view/FormsTab.js b/apps/documenteditor/main/app/view/FormsTab.js index 33811f9305..324961d8bc 100644 --- a/apps/documenteditor/main/app/view/FormsTab.js +++ b/apps/documenteditor/main/app/view/FormsTab.js @@ -276,6 +276,7 @@ define([ this.fieldPages = new Common.UI.InputFieldFixed({ id: 'id-toolbar-txt-pages', style : 'width: 100%;', + cls : 'text-align-right', maskExp : /[0-9]/, allowBlank : true, validateOnChange: false, diff --git a/apps/pdfeditor/main/app/controller/LeftMenu.js b/apps/pdfeditor/main/app/controller/LeftMenu.js index 72df41d1e2..79ab14e3a7 100644 --- a/apps/pdfeditor/main/app/controller/LeftMenu.js +++ b/apps/pdfeditor/main/app/controller/LeftMenu.js @@ -362,16 +362,17 @@ define([ var me = this, defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption(); !defFileName && (defFileName = me.txtUntitled); - if (typeof ext === 'string') { - var idx = defFileName.lastIndexOf('.'); - if (idx>0) - defFileName = defFileName.substring(0, idx) + ext; - } + var idx = defFileName.lastIndexOf('.'); + if (idx>0) + defFileName = defFileName.substring(0, idx); (new Common.Views.TextInputDialog({ label: me.textSelectPath, value: defFileName || '', + inputFixedConfig: {fixedValue: ext, fixedWidth: 40}, handler: function(result, value) { if (result == 'ok') { + if (typeof ext === 'string') + value = value + ext; me.clickSaveAsFormat(menu, format, ext, value); } } diff --git a/apps/pdfeditor/main/app/view/Toolbar.js b/apps/pdfeditor/main/app/view/Toolbar.js index 2f1c98aa9a..fb789f2c8a 100644 --- a/apps/pdfeditor/main/app/view/Toolbar.js +++ b/apps/pdfeditor/main/app/view/Toolbar.js @@ -1089,6 +1089,7 @@ define([ this.fieldPages = new Common.UI.InputFieldFixed({ id: 'id-toolbar-txt-pages', style : 'width: 100%;', + cls : 'text-align-right', maskExp : /[0-9]/, allowBlank : true, validateOnChange: false, diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 4a9b8b158f..bc84a7181b 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -305,16 +305,17 @@ define([ var me = this, defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption(); !defFileName && (defFileName = me.txtUntitled); - if (typeof ext === 'string') { - var idx = defFileName.lastIndexOf('.'); - if (idx>0) - defFileName = defFileName.substring(0, idx) + ext; - } + var idx = defFileName.lastIndexOf('.'); + if (idx>0) + defFileName = defFileName.substring(0, idx); (new Common.Views.TextInputDialog({ label: me.textSelectPath, value: defFileName || '', + inputFixedConfig: {fixedValue: ext, fixedWidth: 40}, handler: function(result, value) { if (result == 'ok') { + if (typeof ext === 'string') + value = value + ext; me.clickSaveCopyAsFormat(menu, format, ext, value); } } diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index ba4e8844b4..e51dad40d0 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -427,16 +427,17 @@ define([ var me = this, defFileName = this.getApplication().getController('Viewport').getView('Common.Views.Header').getDocumentCaption(); !defFileName && (defFileName = me.txtUntitled); - if (typeof ext === 'string') { - var idx = defFileName.lastIndexOf('.'); - if (idx>0) - defFileName = defFileName.substring(0, idx) + ext; - } + var idx = defFileName.lastIndexOf('.'); + if (idx>0) + defFileName = defFileName.substring(0, idx); (new Common.Views.TextInputDialog({ label: me.textSelectPath, value: defFileName || '', + inputFixedConfig: {fixedValue: ext, fixedWidth: 40}, handler: function(result, value) { if (result == 'ok') { + if (typeof ext === 'string') + value = value + ext; me.clickSaveCopyAsFormat(menu, format, ext, value); } }