[Wopi] Show file extension when save copy

This commit is contained in:
Julia Radzhabova
2024-09-10 22:28:37 +03:00
parent b27b56cc07
commit 409223d726
9 changed files with 57 additions and 34 deletions

View File

@ -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);

View File

@ -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 () {

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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);
}
}

View File

@ -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);
}
}