From 5031a3d9b06f88270e62c56834396db03c5733c3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 6 Sep 2019 17:38:29 +0300 Subject: [PATCH] Fix Bug 42728 --- .../main/app/view/FileMenuPanels.js | 63 ++++++++++--------- apps/documenteditor/main/locale/en.json | 1 + .../main/app/view/FileMenuPanels.js | 63 ++++++++++--------- apps/presentationeditor/main/locale/en.json | 1 + .../main/app/view/FileMenuPanels.js | 63 ++++++++++--------- apps/spreadsheeteditor/main/locale/en.json | 1 + 6 files changed, 105 insertions(+), 87 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 6f44e1424..c36eb3b0c 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -768,6 +768,11 @@ define([ '', '', '', + '', + '', + '', + '', + '', '' ].join('')); @@ -780,7 +785,7 @@ define([ }, render: function() { - $(this.el).html(this.template()); + $(this.el).html(this.template({scope: this})); var me = this; @@ -814,33 +819,18 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putTitle(me.inputTitle.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putSubject(me.inputSubject.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putDescription(me.inputComment.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); // modify info @@ -861,10 +851,6 @@ define([ idx = me.tblAuthor.find('tr').index(el); el.remove(); me.authors.splice(idx, 1); - if (me.coreProps && me.api) { - me.coreProps.asc_putCreator(me.authors.join(';')); - me.api.asc_setCoreProps(me.coreProps); - } } }); @@ -873,27 +859,31 @@ define([ style : 'width: 200px;', validateOnBlur: false, placeHolder: this.txtAddAuthor - }).on('changed:after', function(input, newValue, oldValue) { + }).on('changed:after', function(input, newValue, oldValue, e) { if (newValue == oldValue) return; var val = newValue.trim(); if (!!val && val !== oldValue.trim()) { + var isFromApply = e && e.relatedTarget && (e.relatedTarget.id == 'fminfo-btn-apply'); val.split(/\s*[,;]\s*/).forEach(function(item){ var str = item.trim(); if (str) { - var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); - me.trAuthor.before(div); me.authors.push(item); + if (!isFromApply) { + var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); + me.trAuthor.before(div); + } } }); - me.inputAuthor.setValue(''); - if (me.coreProps && me.api) { - me.coreProps.asc_putCreator(me.authors.join(';')); - me.api.asc_setCoreProps(me.coreProps); - } + !isFromApply && me.inputAuthor.setValue(''); } }).on('keydown:before', keyDownBefore); + this.btnApply = new Common.UI.Button({ + el: '#fminfo-btn-apply' + }); + this.btnApply.on('click', _.bind(this.applySettings, this)); + this.rendered = true; this.updateInfo(this.doc); @@ -1002,6 +992,7 @@ define([ value = props.asc_getDescription(); this.inputComment.setValue(value || ''); + this.inputAuthor.setValue(''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; @@ -1053,6 +1044,7 @@ define([ setMode: function(mode) { this.mode = mode; this.inputAuthor.setVisible(mode.isEdit); + this.btnApply.setVisible(mode.isEdit); this.tblAuthor.find('.close').toggleClass('hidden', !mode.isEdit); this.SetDisabled(); return this; @@ -1114,6 +1106,18 @@ define([ this.inputAuthor.setDisabled(disable); this.tblAuthor.find('.close').toggleClass('disabled', this._locked); this.tblAuthor.toggleClass('disabled', disable); + this.btnApply.setDisabled(this._locked); + }, + + applySettings: function() { + if (this.coreProps && this.api) { + this.coreProps.asc_putTitle(this.inputTitle.getValue()); + this.coreProps.asc_putSubject(this.inputSubject.getValue()); + this.coreProps.asc_putDescription(this.inputComment.getValue()); + this.coreProps.asc_putCreator(this.authors.join(';')); + this.api.asc_setCoreProps(this.coreProps); + } + this.menu.hide(); }, txtPlacement: 'Location', @@ -1136,7 +1140,8 @@ define([ txtAuthor: 'Author', txtAddAuthor: 'Add Author', txtAddText: 'Add Text', - txtMinutes: 'min' + txtMinutes: 'min', + okButtonText: 'Apply' }, DE.Views.FileMenuPanels.DocumentInfo || {})); DE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({ diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index f8c3b6e84..54c1de625 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1386,6 +1386,7 @@ "DE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Title", "DE.Views.FileMenuPanels.DocumentInfo.txtUploaded": "Uploaded", "DE.Views.FileMenuPanels.DocumentInfo.txtWords": "Words", + "DE.Views.FileMenuPanels.DocumentInfo.okButtonText": "Apply", "DE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights", "DE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights", "DE.Views.FileMenuPanels.ProtectDoc.notcriticalErrorTitle": "Warning", diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 656ce32e7..f225db3eb 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -654,6 +654,11 @@ define([ '', '', '', + '', + '', + '', + '', + '', '' ].join('')); @@ -664,7 +669,7 @@ define([ }, render: function() { - $(this.el).html(this.template()); + $(this.el).html(this.template({scope: this})); var me = this; @@ -690,33 +695,18 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putTitle(me.inputTitle.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putSubject(me.inputSubject.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putDescription(me.inputComment.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); // modify info @@ -737,10 +727,6 @@ define([ idx = me.tblAuthor.find('tr').index(el); el.remove(); me.authors.splice(idx, 1); - if (me.coreProps && me.api) { - me.coreProps.asc_putCreator(me.authors.join(';')); - me.api.asc_setCoreProps(me.coreProps); - } } }); @@ -749,27 +735,31 @@ define([ style : 'width: 200px;', validateOnBlur: false, placeHolder: this.txtAddAuthor - }).on('changed:after', function(input, newValue, oldValue) { + }).on('changed:after', function(input, newValue, oldValue, e) { if (newValue == oldValue) return; var val = newValue.trim(); if (!!val && val !== oldValue.trim()) { + var isFromApply = e && e.relatedTarget && (e.relatedTarget.id == 'fminfo-btn-apply'); val.split(/\s*[,;]\s*/).forEach(function(item){ var str = item.trim(); if (str) { - var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); - me.trAuthor.before(div); me.authors.push(item); + if (!isFromApply) { + var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); + me.trAuthor.before(div); + } } }); - me.inputAuthor.setValue(''); - if (me.coreProps && me.api) { - me.coreProps.asc_putCreator(me.authors.join(';')); - me.api.asc_setCoreProps(me.coreProps); - } + !isFromApply && me.inputAuthor.setValue(''); } }).on('keydown:before', keyDownBefore); + this.btnApply = new Common.UI.Button({ + el: '#fminfo-btn-apply' + }); + this.btnApply.on('click', _.bind(this.applySettings, this)); + this.rendered = true; this.updateInfo(this.doc); @@ -875,6 +865,7 @@ define([ value = props.asc_getDescription(); this.inputComment.setValue(value || ''); + this.inputAuthor.setValue(''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; @@ -902,6 +893,7 @@ define([ setMode: function(mode) { this.mode = mode; this.inputAuthor.setVisible(mode.isEdit); + this.btnApply.setVisible(mode.isEdit); this.tblAuthor.find('.close').toggleClass('hidden', !mode.isEdit); this.SetDisabled(); return this; @@ -927,6 +919,18 @@ define([ this.inputAuthor.setDisabled(disable); this.tblAuthor.find('.close').toggleClass('disabled', this._locked); this.tblAuthor.toggleClass('disabled', disable); + this.btnApply.setDisabled(this._locked); + }, + + applySettings: function() { + if (this.coreProps && this.api) { + this.coreProps.asc_putTitle(this.inputTitle.getValue()); + this.coreProps.asc_putSubject(this.inputSubject.getValue()); + this.coreProps.asc_putDescription(this.inputComment.getValue()); + this.coreProps.asc_putCreator(this.authors.join(';')); + this.api.asc_setCoreProps(this.coreProps); + } + this.menu.hide(); }, txtPlacement: 'Location', @@ -943,7 +947,8 @@ define([ txtAuthor: 'Author', txtAddAuthor: 'Add Author', txtAddText: 'Add Text', - txtMinutes: 'min' + txtMinutes: 'min', + okButtonText: 'Apply' }, PE.Views.FileMenuPanels.DocumentInfo || {})); PE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({ diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 686018f0f..93422947e 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -1176,6 +1176,7 @@ "PE.Views.FileMenuPanels.DocumentInfo.txtSubject": "Subject", "PE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Title", "PE.Views.FileMenuPanels.DocumentInfo.txtUploaded": "Uploaded", + "PE.Views.FileMenuPanels.DocumentInfo.okButtonText": "Apply", "PE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights", "PE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights", "PE.Views.FileMenuPanels.ProtectDoc.notcriticalErrorTitle": "Warning", diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 531603031..ceb9d7ede 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1103,6 +1103,11 @@ define([ '', '', '', + '', + '', + '', + '', + '', '' ].join('')); @@ -1113,7 +1118,7 @@ define([ }, render: function() { - $(this.el).html(this.template()); + $(this.el).html(this.template({scope: this})); var me = this; @@ -1139,33 +1144,18 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putTitle(me.inputTitle.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putSubject(me.inputSubject.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function(input, newValue, oldValue) { - if (newValue !== oldValue && me.coreProps && me.api) { - me.coreProps.asc_putDescription(me.inputComment.getValue()); - me.api.asc_setCoreProps(me.coreProps); - } }).on('keydown:before', keyDownBefore); // modify info @@ -1186,10 +1176,6 @@ define([ idx = me.tblAuthor.find('tr').index(el); el.remove(); me.authors.splice(idx, 1); - if (me.coreProps && me.api) { - me.coreProps.asc_putCreator(me.authors.join(';')); - me.api.asc_setCoreProps(me.coreProps); - } } }); @@ -1198,27 +1184,31 @@ define([ style : 'width: 200px;', validateOnBlur: false, placeHolder: this.txtAddAuthor - }).on('changed:after', function(input, newValue, oldValue) { + }).on('changed:after', function(input, newValue, oldValue, e) { if (newValue == oldValue) return; var val = newValue.trim(); if (!!val && val !== oldValue.trim()) { + var isFromApply = e && e.relatedTarget && (e.relatedTarget.id == 'fminfo-btn-apply'); val.split(/\s*[,;]\s*/).forEach(function(item){ var str = item.trim(); if (str) { - var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); - me.trAuthor.before(div); me.authors.push(item); + if (!isFromApply) { + var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); + me.trAuthor.before(div); + } } }); - me.inputAuthor.setValue(''); - if (me.coreProps && me.api) { - me.coreProps.asc_putCreator(me.authors.join(';')); - me.api.asc_setCoreProps(me.coreProps); - } + !isFromApply && me.inputAuthor.setValue(''); } }).on('keydown:before', keyDownBefore); + this.btnApply = new Common.UI.Button({ + el: '#fminfo-btn-apply' + }); + this.btnApply.on('click', _.bind(this.applySettings, this)); + this.rendered = true; this.updateInfo(this.doc); @@ -1324,6 +1314,7 @@ define([ value = props.asc_getDescription(); this.inputComment.setValue(value || ''); + this.inputAuthor.setValue(''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; @@ -1351,6 +1342,7 @@ define([ setMode: function(mode) { this.mode = mode; this.inputAuthor.setVisible(mode.isEdit); + this.btnApply.setVisible(mode.isEdit); this.tblAuthor.find('.close').toggleClass('hidden', !mode.isEdit); this.SetDisabled(); return this; @@ -1376,6 +1368,18 @@ define([ this.inputAuthor.setDisabled(disable); this.tblAuthor.find('.close').toggleClass('disabled', this._locked); this.tblAuthor.toggleClass('disabled', disable); + this.btnApply.setDisabled(this._locked); + }, + + applySettings: function() { + if (this.coreProps && this.api) { + this.coreProps.asc_putTitle(this.inputTitle.getValue()); + this.coreProps.asc_putSubject(this.inputSubject.getValue()); + this.coreProps.asc_putDescription(this.inputComment.getValue()); + this.coreProps.asc_putCreator(this.authors.join(';')); + this.api.asc_setCoreProps(this.coreProps); + } + this.menu.hide(); }, txtPlacement: 'Location', @@ -1391,7 +1395,8 @@ define([ txtAuthor: 'Author', txtAddAuthor: 'Add Author', txtAddText: 'Add Text', - txtMinutes: 'min' + txtMinutes: 'min', + okButtonText: 'Apply' }, SSE.Views.FileMenuPanels.DocumentInfo || {})); SSE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({ diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index ecec32f3e..a82f58820 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1533,6 +1533,7 @@ "SSE.Views.FileMenuPanels.DocumentInfo.txtSubject": "Subject", "SSE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Title", "SSE.Views.FileMenuPanels.DocumentInfo.txtUploaded": "Uploaded", + "SSE.Views.FileMenuPanels.DocumentInfo.okButtonText": "Apply", "SSE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights", "SSE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights", "SSE.Views.FileMenuPanels.MainSettingsGeneral.okButtonText": "Apply",