From 0d0f00b9a92b128e23e08cff88a466365a9e92d8 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 2 Apr 2019 13:17:26 +0300 Subject: [PATCH 01/14] [DE] Bug 40231: add document info --- apps/common/main/lib/component/CheckBox.js | 3 + apps/common/main/lib/component/RadioBox.js | 3 + .../main/app/view/FileMenuPanels.js | 287 ++++++++++++++---- .../main/resources/less/filemenu.less | 48 ++- 4 files changed, 261 insertions(+), 80 deletions(-) diff --git a/apps/common/main/lib/component/CheckBox.js b/apps/common/main/lib/component/CheckBox.js index fa353ba98..5aaa8a112 100644 --- a/apps/common/main/lib/component/CheckBox.js +++ b/apps/common/main/lib/component/CheckBox.js @@ -137,6 +137,9 @@ define([ }, setDisabled: function(disabled) { + if (!this.rendered) + return; + disabled = (disabled===true); if (disabled !== this.disabled) { this.$label.toggleClass('disabled', disabled); diff --git a/apps/common/main/lib/component/RadioBox.js b/apps/common/main/lib/component/RadioBox.js index 57348aa19..8b7ff4b6f 100644 --- a/apps/common/main/lib/component/RadioBox.js +++ b/apps/common/main/lib/component/RadioBox.js @@ -107,6 +107,9 @@ define([ }, setDisabled: function(disabled) { + if (!this.rendered) + return; + if (disabled !== this.disabled) { this.$radio.toggleClass('disabled', disabled); (disabled) ? this.$radio.attr({disabled: disabled}) : this.$radio.removeAttr('disabled'); diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 539eaa81b..16bea8c85 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -673,50 +673,82 @@ define([ this.template = _.template([ '', '', - '', - '', - '', - '', - '', - '', - '', - '', '', '', '', - '', - '', - '', - '', - '', - '', - '', - '', - '', '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', @@ -731,16 +763,84 @@ define([ render: function() { $(this.el).html(this.template()); - this.lblTitle = $('#id-info-title'); + var me = this; + + // server info this.lblPlacement = $('#id-info-placement'); - this.lblDate = $('#id-info-date'); - this.lblAuthor = $('#id-info-author'); - this.lblApplication = $('#id-info-appname'); + this.lblOwner = $('#id-info-owner'); + this.lblUploaded = $('#id-info-uploaded'); + + // statistic info this.lblStatPages = $('#id-info-pages'); this.lblStatWords = $('#id-info-words'); this.lblStatParagraphs = $('#id-info-paragraphs'); this.lblStatSymbols = $('#id-info-symbols'); this.lblStatSpaces = $('#id-info-spaces'); + this.lblEditTime = $('#id-info-edittime'); + + // edited info + this.inputTitle = new Common.UI.InputField({ + el : $('#id-info-title'), + style : 'width: 200px;', + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + }); + this.inputSubject = new Common.UI.InputField({ + el : $('#id-info-subject'), + style : 'width: 200px;', + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + }); + this.inputComment = new Common.UI.InputField({ + el : $('#id-info-comment'), + style : 'width: 200px;', + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + }); + + // modify info + this.lblModifyDate = $('#id-info-modify-date'); + this.lblModifyBy = $('#id-info-modify-by'); + + // creation info + this.lblDate = $('#id-info-date'); + this.lblApplication = $('#id-info-appname'); + this.tblAuthor = $('#id-info-author table'); + this.trAuthor = $('#id-info-add-author').closest('tr'); + this.authorTpl = ''; + + this.tblAuthor.on('click', function(e) { + var btn = $(e.target); + if (btn.hasClass('close')) { + var el = btn.closest('tr'), + idx = me.tblAuthor.find('tr').index(el); + el.remove(); + // remove idx author from info + } + }); + + this.inputAuthor = new Common.UI.InputField({ + el : $('#id-info-add-author'), + style : 'width: 200px;', + validateOnBlur: false, + placeHolder: this.txtAddAuthor + }).on('changed:after', function(input, newValue, oldValue) { + var val = newValue.trim(); + if (!!val && val !== oldValue.trim()) { + 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); + // add str author to info + } + }); + me.inputAuthor.setValue(''); + } + }); this.rendered = true; @@ -760,6 +860,7 @@ define([ Common.UI.BaseView.prototype.show.call(this,arguments); this.updateStatisticInfo(); + this.updateFileInfo(); }, hide: function() { @@ -773,37 +874,86 @@ define([ if (!this.rendered) return; + var visible = false; doc = doc || {}; - this.lblTitle.text((doc.title) ? doc.title : '-'); - if (doc.info) { - if (doc.info.author) - this.lblAuthor.text(doc.info.author); - this._ShowHideInfoItem('author', doc.info.author!==undefined && doc.info.author!==null); - if (doc.info.created ) - this.lblDate.text( doc.info.created ); - this._ShowHideInfoItem('date', doc.info.created!==undefined && doc.info.created!==null); + // server info if (doc.info.folder ) this.lblPlacement.text( doc.info.folder ); - this._ShowHideInfoItem('placement', doc.info.folder!==undefined && doc.info.folder!==null); + visible = visible || this._ShowHideInfoItem(this.lblPlacement, doc.info.folder!==undefined && doc.info.folder!==null); + if (doc.info.author) + this.lblOwner.text(doc.info.author); + visible = visible || this._ShowHideInfoItem(this.lblOwner, doc.info.author!==undefined && doc.info.author!==null); + if (doc.info.uploaded) + this.lblUploaded.text(doc.info.uploaded.toLocaleString()); + visible = visible || this._ShowHideInfoItem(this.lblUploaded, doc.info.uploaded!==undefined && doc.info.uploaded!==null); } else this._ShowHideDocInfo(false); + $('tr.divider.general', this.el)[visible?'show':'hide'](); + var appname = (this.api) ? this.api.asc_getAppProps() : null; if (appname) { appname = (appname.asc_getApplication() || '') + ' ' + (appname.asc_getAppVersion() || ''); this.lblApplication.text(appname); + this._ShowHideInfoItem(this.lblApplication, !!appname); + } + var props = (this.api) ? this.api.asc_getCoreProps() : null; + if (props) { + var value = props.asc_getCreated(); + if (value) + this.lblDate.text(value.toLocaleString()); + this._ShowHideInfoItem(this.lblDate, !!value); } - this._ShowHideInfoItem('appname', !!appname); }, - _ShowHideInfoItem: function(cls, visible) { - $('tr.'+cls, this.el)[visible?'show':'hide'](); + updateFileInfo: function() { + if (!this.rendered) + return; + + var me = this, + props = (this.api) ? this.api.asc_getCoreProps() : null; + if (props) { + var visible = false; + + var value = props.asc_getModified(); + if (value) + this.lblModifyDate.text(value.toLocaleString()); + visible = visible || this._ShowHideInfoItem(this.lblModifyDate, !!value); + value = props.asc_getLastModifiedBy(); + if (value) + this.lblModifyBy.text(value); + visible = visible || this._ShowHideInfoItem(this.lblModifyBy, !!value); + $('tr.divider.modify', this.el)[visible?'show':'hide'](); + + value = '';//props.asc_getEditingTime(); + if (value) + this.lblEditTime.text(value); + this._ShowHideInfoItem(this.lblEditTime, !!value); + value = props.asc_getTitle(); + this.inputTitle.setValue(value || ''); + value = props.asc_getSubject(); + this.inputSubject.setValue(value || ''); + value = props.asc_getDescription(); + this.inputComment.setValue(value || ''); + + this.tblAuthor.find('tr:not(:last-of-type)').remove(); + value = ['123"""<>', '456'];//props.asc_getAuthor(); + value && value.forEach(function(item) { + var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); + me.trAuthor.before(div); + }); + } + }, + + _ShowHideInfoItem: function(el, visible) { + el.closest('tr')[visible?'show':'hide'](); + return visible; }, _ShowHideDocInfo: function(visible) { - this._ShowHideInfoItem('date', visible); - this._ShowHideInfoItem('placement', visible); - this._ShowHideInfoItem('author', visible); + this._ShowHideInfoItem(this.lblPlacement, visible); + this._ShowHideInfoItem(this.lblOwner, visible); + this._ShowHideInfoItem(this.lblUploaded, visible); }, updateStatisticInfo: function() { @@ -824,7 +974,7 @@ define([ this.api.asc_registerCallback('asc_onGetDocInfoStop', _.bind(this._onGetDocInfoEnd, this)); this.api.asc_registerCallback('asc_onDocInfo', _.bind(this._onDocInfo, this)); this.api.asc_registerCallback('asc_onGetDocInfoEnd', _.bind(this._onGetDocInfoEnd, this)); - this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); + // this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); this.updateInfo(this.doc); return this; }, @@ -876,18 +1026,25 @@ define([ this.lblTitle.text((name) ? name : '-'); }, - txtTitle: 'Document Title', - txtAuthor: 'Author', - txtPlacement: 'Placement', - txtDate: 'Creation Date', - txtStatistics: 'Statistics', + txtPlacement: 'File Location', + txtOwner: 'Owner on cloud', + txtUploaded: 'Uploaded', txtPages: 'Pages', txtWords: 'Words', txtParagraphs: 'Paragraphs', txtSymbols: 'Symbols', txtSpaces: 'Symbols with spaces', txtLoading: 'Loading...', - txtAppName: 'Application' + txtAppName: 'Application', + txtEditTime: 'Total Editing time', + txtTitle: 'Title', + txtSubject: 'Subject', + txtComment: 'Comment', + txtModifyDate: 'Last Modified', + txtModifyBy: 'Last Modified By', + txtDate: 'Created', + txtAuthor: 'Author', + txtAddAuthor: 'Add Author' }, DE.Views.FileMenuPanels.DocumentInfo || {})); DE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({ diff --git a/apps/documenteditor/main/resources/less/filemenu.less b/apps/documenteditor/main/resources/less/filemenu.less index 67712c42c..657fb30f0 100644 --- a/apps/documenteditor/main/resources/less/filemenu.less +++ b/apps/documenteditor/main/resources/less/filemenu.less @@ -304,29 +304,31 @@ } table { - td { - padding: 0 20px 5px 0; + tr { + td { + padding: 0 20px 5px 0; - &.left { - padding: 5px 10px; - text-align: right; - width: 30%; + &.left { + padding: 5px 10px; + text-align: right; + width: 30%; - label { - font-weight: bold; + label { + font-weight: bold; + } + } + + &.right { + padding: 5px 10px; + width: 70%; } } - &.right { - padding: 5px 10px; - width: 70%; + &.divider { + height: 10px; } } - &.divider { - height: 10px; - } - &.main { width: 100%; margin: 30px 0; @@ -347,6 +349,22 @@ label, span { font-size: 12px; } + + .close { + width: 16px; + height: 16px; + cursor: pointer; + display: inline-block; + vertical-align: middle; + margin-left: 5px; + + background-position: @but-close-offset-x @but-close-offset-y; + + &.over, + &:hover { + background-position: @but-close-offset-x @but-close-offset-y - 16px; + } + } } #panel-protect { From e9391d30799db217ac18ebf0c8c9107f9678bf76 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 15 May 2019 14:17:29 +0300 Subject: [PATCH 02/14] [DE] Update document info --- apps/documenteditor/main/app/view/FileMenuPanels.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 16bea8c85..26180b49c 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -706,6 +706,8 @@ define([ '', '', '', + '', + '', '', '', '', @@ -782,6 +784,7 @@ define([ this.inputTitle = new Common.UI.InputField({ el : $('#id-info-title'), style : 'width: 200px;', + placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); @@ -789,6 +792,7 @@ define([ this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), style : 'width: 200px;', + placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); @@ -796,6 +800,7 @@ define([ this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), style : 'width: 200px;', + placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); @@ -1026,8 +1031,8 @@ define([ this.lblTitle.text((name) ? name : '-'); }, - txtPlacement: 'File Location', - txtOwner: 'Owner on cloud', + txtPlacement: 'Location', + txtOwner: 'Owner', txtUploaded: 'Uploaded', txtPages: 'Pages', txtWords: 'Words', @@ -1044,7 +1049,8 @@ define([ txtModifyBy: 'Last Modified By', txtDate: 'Created', txtAuthor: 'Author', - txtAddAuthor: 'Add Author' + txtAddAuthor: 'Add Author', + txtAddText: 'Add Text' }, DE.Views.FileMenuPanels.DocumentInfo || {})); DE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({ From 63762a25bd36e935ae575fcc845935ba6c1687d4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 15 May 2019 16:28:18 +0300 Subject: [PATCH 03/14] [DE] Doc info: get editing time and authors --- .../main/app/view/FileMenuPanels.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 26180b49c..45bd78631 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -916,11 +916,20 @@ define([ return; var me = this, - props = (this.api) ? this.api.asc_getCoreProps() : null; + props = (this.api) ? this.api.asc_getCoreProps() : null, + app = (this.api) ? this.api.asc_getAppProps() : null, + value; + + if (app) { + value = app.asc_getTotalTime(); + if (value) + this.lblEditTime.text(value + ' ' + this.txtMinutes); + } + this._ShowHideInfoItem(this.lblEditTime, !!value); + if (props) { var visible = false; - - var value = props.asc_getModified(); + value = props.asc_getModified(); if (value) this.lblModifyDate.text(value.toLocaleString()); visible = visible || this._ShowHideInfoItem(this.lblModifyDate, !!value); @@ -930,10 +939,6 @@ define([ visible = visible || this._ShowHideInfoItem(this.lblModifyBy, !!value); $('tr.divider.modify', this.el)[visible?'show':'hide'](); - value = '';//props.asc_getEditingTime(); - if (value) - this.lblEditTime.text(value); - this._ShowHideInfoItem(this.lblEditTime, !!value); value = props.asc_getTitle(); this.inputTitle.setValue(value || ''); value = props.asc_getSubject(); @@ -942,8 +947,8 @@ define([ this.inputComment.setValue(value || ''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); - value = ['123"""<>', '456'];//props.asc_getAuthor(); - value && value.forEach(function(item) { + value = props.asc_getCreator();//"123\"\"\"\<\>,456"; + value && value.split(/\s*[,;]\s*/).forEach(function(item) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); me.trAuthor.before(div); }); @@ -1050,7 +1055,8 @@ define([ txtDate: 'Created', txtAuthor: 'Author', txtAddAuthor: 'Add Author', - txtAddText: 'Add Text' + txtAddText: 'Add Text', + txtMinutes: 'min' }, DE.Views.FileMenuPanels.DocumentInfo || {})); DE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({ From bd8e1861edba37c777bee478a32eef72b8722d40 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 15 May 2019 16:49:11 +0300 Subject: [PATCH 04/14] [DE] Doc info: hide total editing time --- .../main/app/view/FileMenuPanels.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 45bd78631..8f66b889d 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -708,10 +708,10 @@ define([ '', '', '', - '', - '', - '', - '', + // '', + // '', + // '', + // '', '', '', '', @@ -778,7 +778,7 @@ define([ this.lblStatParagraphs = $('#id-info-paragraphs'); this.lblStatSymbols = $('#id-info-symbols'); this.lblStatSpaces = $('#id-info-spaces'); - this.lblEditTime = $('#id-info-edittime'); + // this.lblEditTime = $('#id-info-edittime'); // edited info this.inputTitle = new Common.UI.InputField({ @@ -917,15 +917,15 @@ define([ var me = this, props = (this.api) ? this.api.asc_getCoreProps() : null, - app = (this.api) ? this.api.asc_getAppProps() : null, value; - if (app) { - value = app.asc_getTotalTime(); - if (value) - this.lblEditTime.text(value + ' ' + this.txtMinutes); - } - this._ShowHideInfoItem(this.lblEditTime, !!value); + // var app = (this.api) ? this.api.asc_getAppProps() : null; + // if (app) { + // value = app.asc_getTotalTime(); + // if (value) + // this.lblEditTime.text(value + ' ' + this.txtMinutes); + // } + // this._ShowHideInfoItem(this.lblEditTime, !!value); if (props) { var visible = false; From 08bdb152a778747c879e854a02a4e0301e5cc27d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 16 May 2019 11:49:13 +0300 Subject: [PATCH 05/14] [DE] Fix loading document info, add translation --- .../documenteditor/main/app/view/FileMenuPanels.js | 14 +++++++------- apps/documenteditor/main/locale/en.json | 13 +++++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 3d448c87e..eb317991a 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -737,7 +737,7 @@ define([ '', '', '', - '', + '', '', '', '', @@ -885,13 +885,13 @@ define([ // server info if (doc.info.folder ) this.lblPlacement.text( doc.info.folder ); - visible = visible || this._ShowHideInfoItem(this.lblPlacement, doc.info.folder!==undefined && doc.info.folder!==null); + visible = this._ShowHideInfoItem(this.lblPlacement, doc.info.folder!==undefined && doc.info.folder!==null) || visible; if (doc.info.author) this.lblOwner.text(doc.info.author); - visible = visible || this._ShowHideInfoItem(this.lblOwner, doc.info.author!==undefined && doc.info.author!==null); + visible = this._ShowHideInfoItem(this.lblOwner, doc.info.author!==undefined && doc.info.author!==null) || visible; if (doc.info.uploaded) this.lblUploaded.text(doc.info.uploaded.toLocaleString()); - visible = visible || this._ShowHideInfoItem(this.lblUploaded, doc.info.uploaded!==undefined && doc.info.uploaded!==null); + visible = this._ShowHideInfoItem(this.lblUploaded, doc.info.uploaded!==undefined && doc.info.uploaded!==null) || visible; } else this._ShowHideDocInfo(false); $('tr.divider.general', this.el)[visible?'show':'hide'](); @@ -932,11 +932,11 @@ define([ value = props.asc_getModified(); if (value) this.lblModifyDate.text(value.toLocaleString()); - visible = visible || this._ShowHideInfoItem(this.lblModifyDate, !!value); + visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible; value = props.asc_getLastModifiedBy(); if (value) this.lblModifyBy.text(value); - visible = visible || this._ShowHideInfoItem(this.lblModifyBy, !!value); + visible = this._ShowHideInfoItem(this.lblModifyBy, !!value) || visible; $('tr.divider.modify', this.el)[visible?'show':'hide'](); value = props.asc_getTitle(); @@ -1052,7 +1052,7 @@ define([ txtComment: 'Comment', txtModifyDate: 'Last Modified', txtModifyBy: 'Last Modified By', - txtDate: 'Created', + txtCreated: 'Created', txtAuthor: 'Author', txtAddAuthor: 'Add Author', txtAddText: 'Add Text', diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 4d158c05b..6fa41b503 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1345,18 +1345,27 @@ "DE.Views.FileMenuPanels.CreateNew.newDocumentText": "New Text Document", "DE.Views.FileMenuPanels.CreateNew.noTemplatesText": "There are no templates", "DE.Views.FileMenuPanels.DocumentInfo.txtAppName": "Application", + "DE.Views.FileMenuPanels.DocumentInfo.txtAddAuthor": "Add Author", + "DE.Views.FileMenuPanels.DocumentInfo.txtAddText": "Add Text", "DE.Views.FileMenuPanels.DocumentInfo.txtAuthor": "Author", "DE.Views.FileMenuPanels.DocumentInfo.txtBtnAccessRights": "Change access rights", - "DE.Views.FileMenuPanels.DocumentInfo.txtDate": "Creation Date", + "DE.Views.FileMenuPanels.DocumentInfo.txtComment": "Comment", + "del_DE.Views.FileMenuPanels.DocumentInfo.txtDate": "Creation Date", + "DE.Views.FileMenuPanels.DocumentInfo.txtCreated": "Created", "DE.Views.FileMenuPanels.DocumentInfo.txtLoading": "Loading...", + "DE.Views.FileMenuPanels.DocumentInfo.txtModifyDate": "Last Modified", + "DE.Views.FileMenuPanels.DocumentInfo.txtModifyBy": "Last Modified By", + "DE.Views.FileMenuPanels.DocumentInfo.txtOwner": "Owner", "DE.Views.FileMenuPanels.DocumentInfo.txtPages": "Pages", "DE.Views.FileMenuPanels.DocumentInfo.txtParagraphs": "Paragraphs", "DE.Views.FileMenuPanels.DocumentInfo.txtPlacement": "Location", "DE.Views.FileMenuPanels.DocumentInfo.txtRights": "Persons who have rights", "DE.Views.FileMenuPanels.DocumentInfo.txtSpaces": "Symbols with spaces", "DE.Views.FileMenuPanels.DocumentInfo.txtStatistics": "Statistics", + "DE.Views.FileMenuPanels.DocumentInfo.txtSubject": "Subject", "DE.Views.FileMenuPanels.DocumentInfo.txtSymbols": "Symbols", - "DE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Document Title", + "DE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Title", + "DE.Views.FileMenuPanels.DocumentInfo.txtUploaded": "Uploaded", "DE.Views.FileMenuPanels.DocumentInfo.txtWords": "Words", "DE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights", "DE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights", From 59fb4182fbf1aee28ee26b019f1f723be4135c46 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 16 May 2019 11:52:49 +0300 Subject: [PATCH 06/14] [SSE] Add document info --- .../main/app/view/FileMenuPanels.js | 3 +- .../main/app/view/FileMenuPanels.js | 240 +++++++++++++++--- apps/spreadsheeteditor/main/locale/en.json | 14 +- .../main/resources/less/leftmenu.less | 16 ++ 4 files changed, 235 insertions(+), 38 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index eb317991a..d1833d4df 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -900,8 +900,9 @@ define([ if (appname) { appname = (appname.asc_getApplication() || '') + ' ' + (appname.asc_getAppVersion() || ''); this.lblApplication.text(appname); - this._ShowHideInfoItem(this.lblApplication, !!appname); } + this._ShowHideInfoItem(this.lblApplication, !!appname); + var props = (this.api) ? this.api.asc_getCoreProps() : null; if (props) { var value = props.asc_getCreated(); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 65731d5a8..07bd8f72b 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1050,26 +1050,61 @@ define([ this.template = _.template([ '
-
', + '
', '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', + '', + '', + '', '
', '
', '', - '', - '', - '', - '', - '', - '', - '', - '', '', '', '', - '', - '', - '', + '', + '', + '', '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', - '', '
-
', + '', + '', + '', + '', + '
', + '
' ].join('')); @@ -1079,11 +1114,79 @@ define([ render: function() { $(this.el).html(this.template()); - this.lblTitle = $('#id-info-title'); + var me = this; + + // server info this.lblPlacement = $('#id-info-placement'); + this.lblOwner = $('#id-info-owner'); + this.lblUploaded = $('#id-info-uploaded'); + + // edited info + this.inputTitle = new Common.UI.InputField({ + el : $('#id-info-title'), + style : 'width: 200px;', + placeHolder : this.txtAddText, + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + }); + this.inputSubject = new Common.UI.InputField({ + el : $('#id-info-subject'), + style : 'width: 200px;', + placeHolder : this.txtAddText, + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + }); + this.inputComment = new Common.UI.InputField({ + el : $('#id-info-comment'), + style : 'width: 200px;', + placeHolder : this.txtAddText, + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + }); + + // modify info + this.lblModifyDate = $('#id-info-modify-date'); + this.lblModifyBy = $('#id-info-modify-by'); + + // creation info this.lblDate = $('#id-info-date'); - this.lblAuthor = $('#id-info-author'); this.lblApplication = $('#id-info-appname'); + this.tblAuthor = $('#id-info-author table'); + this.trAuthor = $('#id-info-add-author').closest('tr'); + this.authorTpl = '
'; + + this.tblAuthor.on('click', function(e) { + var btn = $(e.target); + if (btn.hasClass('close')) { + var el = btn.closest('tr'), + idx = me.tblAuthor.find('tr').index(el); + el.remove(); + // remove idx author from info + } + }); + + this.inputAuthor = new Common.UI.InputField({ + el : $('#id-info-add-author'), + style : 'width: 200px;', + validateOnBlur: false, + placeHolder: this.txtAddAuthor + }).on('changed:after', function(input, newValue, oldValue) { + var val = newValue.trim(); + if (!!val && val !== oldValue.trim()) { + 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); + // add str author to info + } + }); + me.inputAuthor.setValue(''); + } + }); this.rendered = true; @@ -1101,6 +1204,8 @@ define([ show: function() { Common.UI.BaseView.prototype.show.call(this,arguments); + + this.updateFileInfo(); }, hide: function() { @@ -1112,37 +1217,92 @@ define([ if (!this.rendered) return; + var visible = false; doc = doc || {}; - this.lblTitle.text((doc.title) ? doc.title : '-'); - if (doc.info) { - if (doc.info.author) - this.lblAuthor.text(doc.info.author); - this._ShowHideInfoItem('author', doc.info.author!==undefined && doc.info.author!==null); - if (doc.info.created ) - this.lblDate.text( doc.info.created ); - this._ShowHideInfoItem('date', doc.info.created!==undefined && doc.info.created!==null); + // server info if (doc.info.folder ) this.lblPlacement.text( doc.info.folder ); - this._ShowHideInfoItem('placement', doc.info.folder!==undefined && doc.info.folder!==null); + visible = this._ShowHideInfoItem(this.lblPlacement, doc.info.folder!==undefined && doc.info.folder!==null) || visible; + if (doc.info.author) + this.lblOwner.text(doc.info.author); + visible = this._ShowHideInfoItem(this.lblOwner, doc.info.author!==undefined && doc.info.author!==null) || visible; + if (doc.info.uploaded) + this.lblUploaded.text(doc.info.uploaded.toLocaleString()); + visible = this._ShowHideInfoItem(this.lblUploaded, doc.info.uploaded!==undefined && doc.info.uploaded!==null) || visible; } else this._ShowHideDocInfo(false); + $('tr.divider.general', this.el)[visible?'show':'hide'](); + var appname = (this.api) ? this.api.asc_getAppProps() : null; if (appname) { appname = (appname.asc_getApplication() || '') + ' ' + (appname.asc_getAppVersion() || ''); this.lblApplication.text(appname); } - this._ShowHideInfoItem('appname', !!appname); + this._ShowHideInfoItem(this.lblApplication, !!appname); + + var props = (this.api) ? this.api.asc_getCoreProps() : null; + if (props) { + var value = props.asc_getCreated(); + if (value) + this.lblDate.text(value.toLocaleString()); + this._ShowHideInfoItem(this.lblDate, !!value); + } }, - _ShowHideInfoItem: function(cls, visible) { - $('tr.'+cls, this.el)[visible?'show':'hide'](); + updateFileInfo: function() { + if (!this.rendered) + return; + + var me = this, + props = (this.api) ? this.api.asc_getCoreProps() : null, + value; + + // var app = (this.api) ? this.api.asc_getAppProps() : null; + // if (app) { + // value = app.asc_getTotalTime(); + // if (value) + // this.lblEditTime.text(value + ' ' + this.txtMinutes); + // } + // this._ShowHideInfoItem(this.lblEditTime, !!value); + + if (props) { + var visible = false; + value = props.asc_getModified(); + if (value) + this.lblModifyDate.text(value.toLocaleString()); + visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible; + value = props.asc_getLastModifiedBy(); + if (value) + this.lblModifyBy.text(value); + visible = this._ShowHideInfoItem(this.lblModifyBy, !!value) || visible; + $('tr.divider.modify', this.el)[visible?'show':'hide'](); + + value = props.asc_getTitle(); + this.inputTitle.setValue(value || ''); + value = props.asc_getSubject(); + this.inputSubject.setValue(value || ''); + value = props.asc_getDescription(); + this.inputComment.setValue(value || ''); + + this.tblAuthor.find('tr:not(:last-of-type)').remove(); + value = props.asc_getCreator();//"123\"\"\"\<\>,456"; + value && value.split(/\s*[,;]\s*/).forEach(function(item) { + var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); + me.trAuthor.before(div); + }); + } + }, + + _ShowHideInfoItem: function(el, visible) { + el.closest('tr')[visible?'show':'hide'](); + return visible; }, _ShowHideDocInfo: function(visible) { - this._ShowHideInfoItem('date', visible); - this._ShowHideInfoItem('placement', visible); - this._ShowHideInfoItem('author', visible); + this._ShowHideInfoItem(this.lblPlacement, visible); + this._ShowHideInfoItem(this.lblOwner, visible); + this._ShowHideInfoItem(this.lblUploaded, visible); }, setMode: function(mode) { @@ -1155,11 +1315,21 @@ define([ return this; }, - txtTitle: 'Document Title', + txtPlacement: 'Location', + txtOwner: 'Owner', + txtUploaded: 'Uploaded', + txtLoading: 'Loading...', + txtAppName: 'Application', + txtTitle: 'Title', + txtSubject: 'Subject', + txtComment: 'Comment', + txtModifyDate: 'Last Modified', + txtModifyBy: 'Last Modified By', + txtDate: 'Created', txtAuthor: 'Author', - txtPlacement: 'Placement', - txtDate: 'Creation Date', - txtAppName: 'Application' + txtAddAuthor: 'Add Author', + txtAddText: 'Add Text', + txtMinutes: 'min' }, 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 832fc77c5..5b6ada2ea 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1482,12 +1482,22 @@ "SSE.Views.FileMenuPanels.CreateNew.newDescriptionText": "Create a new blank spreadsheet which you will be able to style and format after it is created during the editing. Or choose one of the templates to start a spreadsheet of a certain type or purpose where some styles have already been pre-applied.", "SSE.Views.FileMenuPanels.CreateNew.newDocumentText": "New Spreadsheet", "SSE.Views.FileMenuPanels.DocumentInfo.txtAppName": "Application", + "SSE.Views.FileMenuPanels.DocumentInfo.txtAddAuthor": "Add Author", + "SSE.Views.FileMenuPanels.DocumentInfo.txtAddText": "Add Text", "SSE.Views.FileMenuPanels.DocumentInfo.txtAuthor": "Author", "SSE.Views.FileMenuPanels.DocumentInfo.txtBtnAccessRights": "Change access rights", - "SSE.Views.FileMenuPanels.DocumentInfo.txtDate": "Creation Date", + "SSE.Views.FileMenuPanels.DocumentInfo.txtComment": "Comment", + "del_SSE.Views.FileMenuPanels.DocumentInfo.txtDate": "Creation Date", + "SSE.Views.FileMenuPanels.DocumentInfo.txtCreated": "Created", + "SSE.Views.FileMenuPanels.DocumentInfo.txtLoading": "Loading...", + "SSE.Views.FileMenuPanels.DocumentInfo.txtModifyDate": "Last Modified", + "SSE.Views.FileMenuPanels.DocumentInfo.txtModifyBy": "Last Modified By", + "SSE.Views.FileMenuPanels.DocumentInfo.txtOwner": "Owner", "SSE.Views.FileMenuPanels.DocumentInfo.txtPlacement": "Location", "SSE.Views.FileMenuPanels.DocumentInfo.txtRights": "Persons who have rights", - "SSE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Spreadsheet Title", + "SSE.Views.FileMenuPanels.DocumentInfo.txtSubject": "Subject", + "SSE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Title", + "SSE.Views.FileMenuPanels.DocumentInfo.txtUploaded": "Uploaded", "SSE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights", "SSE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights", "SSE.Views.FileMenuPanels.MainSettingsGeneral.okButtonText": "Apply", diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index 2e10d4039..c048950d8 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -500,6 +500,22 @@ label, span { font-size: 12px; } + + .close { + width: 16px; + height: 16px; + cursor: pointer; + display: inline-block; + vertical-align: middle; + margin-left: 5px; + + background-position: @but-close-offset-x @but-close-offset-y; + + &.over, + &:hover { + background-position: @but-close-offset-x @but-close-offset-y - 16px; + } + } } #panel-protect { From fceec132060953973e380f50eda25ccf948a6dc0 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 16 May 2019 15:59:39 +0300 Subject: [PATCH 07/14] [PE] Add document info --- .../main/app/view/FileMenuPanels.js | 2 +- .../main/app/view/FileMenuPanels.js | 244 +++++++++++++++--- apps/presentationeditor/main/locale/en.json | 13 +- .../main/resources/less/leftmenu.less | 16 ++ .../main/app/view/FileMenuPanels.js | 1 - apps/spreadsheeteditor/main/locale/en.json | 1 - 6 files changed, 237 insertions(+), 40 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index d1833d4df..d671c1583 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -1034,7 +1034,7 @@ define([ }, onDocumentName: function(name) { - this.lblTitle.text((name) ? name : '-'); + // this.lblTitle.text((name) ? name : '-'); }, txtPlacement: 'Location', diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 3a7d31bd7..808f55dae 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -595,26 +595,65 @@ define([ this.template = _.template([ '', '', - '', - '', - '', - '', - '', - '', - '', - '', '', '', '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + // '', + // '', + // '', + // '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', '', - '', + '', '', - '', - '', - '', + '', + '', + '', '', - '', '
-
', + '', + '', + '', + '', + '
', + '
' ].join('')); @@ -624,11 +663,79 @@ define([ render: function() { $(this.el).html(this.template()); - this.lblTitle = $('#id-info-title'); + var me = this; + + // server info this.lblPlacement = $('#id-info-placement'); + this.lblOwner = $('#id-info-owner'); + this.lblUploaded = $('#id-info-uploaded'); + + // edited info + this.inputTitle = new Common.UI.InputField({ + el : $('#id-info-title'), + style : 'width: 200px;', + placeHolder : this.txtAddText, + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + }); + this.inputSubject = new Common.UI.InputField({ + el : $('#id-info-subject'), + style : 'width: 200px;', + placeHolder : this.txtAddText, + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + }); + this.inputComment = new Common.UI.InputField({ + el : $('#id-info-comment'), + style : 'width: 200px;', + placeHolder : this.txtAddText, + validateOnBlur: false + }).on('changed:after', function() { + // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + }); + + // modify info + this.lblModifyDate = $('#id-info-modify-date'); + this.lblModifyBy = $('#id-info-modify-by'); + + // creation info this.lblDate = $('#id-info-date'); - this.lblAuthor = $('#id-info-author'); this.lblApplication = $('#id-info-appname'); + this.tblAuthor = $('#id-info-author table'); + this.trAuthor = $('#id-info-add-author').closest('tr'); + this.authorTpl = '
'; + + this.tblAuthor.on('click', function(e) { + var btn = $(e.target); + if (btn.hasClass('close')) { + var el = btn.closest('tr'), + idx = me.tblAuthor.find('tr').index(el); + el.remove(); + // remove idx author from info + } + }); + + this.inputAuthor = new Common.UI.InputField({ + el : $('#id-info-add-author'), + style : 'width: 200px;', + validateOnBlur: false, + placeHolder: this.txtAddAuthor + }).on('changed:after', function(input, newValue, oldValue) { + var val = newValue.trim(); + if (!!val && val !== oldValue.trim()) { + 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); + // add str author to info + } + }); + me.inputAuthor.setValue(''); + } + }); this.rendered = true; @@ -646,6 +753,8 @@ define([ show: function() { Common.UI.BaseView.prototype.show.call(this,arguments); + + this.updateFileInfo(); }, hide: function() { @@ -657,37 +766,92 @@ define([ if (!this.rendered) return; + var visible = false; doc = doc || {}; - this.lblTitle.text((doc.title) ? doc.title : '-'); - if (doc.info) { - if (doc.info.author) - this.lblAuthor.text(doc.info.author); - this._ShowHideInfoItem('author', doc.info.author!==undefined && doc.info.author!==null); - if (doc.info.created ) - this.lblDate.text( doc.info.created ); - this._ShowHideInfoItem('date', doc.info.created!==undefined && doc.info.created!==null); + // server info if (doc.info.folder ) this.lblPlacement.text( doc.info.folder ); - this._ShowHideInfoItem('placement', doc.info.folder!==undefined && doc.info.folder!==null); + visible = this._ShowHideInfoItem(this.lblPlacement, doc.info.folder!==undefined && doc.info.folder!==null) || visible; + if (doc.info.author) + this.lblOwner.text(doc.info.author); + visible = this._ShowHideInfoItem(this.lblOwner, doc.info.author!==undefined && doc.info.author!==null) || visible; + if (doc.info.uploaded) + this.lblUploaded.text(doc.info.uploaded.toLocaleString()); + visible = this._ShowHideInfoItem(this.lblUploaded, doc.info.uploaded!==undefined && doc.info.uploaded!==null) || visible; } else this._ShowHideDocInfo(false); + $('tr.divider.general', this.el)[visible?'show':'hide'](); + var appname = (this.api) ? this.api.asc_getAppProps() : null; if (appname) { appname = (appname.asc_getApplication() || '') + ' ' + (appname.asc_getAppVersion() || ''); this.lblApplication.text(appname); } - this._ShowHideInfoItem('appname', !!appname); + this._ShowHideInfoItem(this.lblApplication, !!appname); + + var props = (this.api) ? this.api.asc_getCoreProps() : null; + if (props) { + var value = props.asc_getCreated(); + if (value) + this.lblDate.text(value.toLocaleString()); + this._ShowHideInfoItem(this.lblDate, !!value); + } }, - _ShowHideInfoItem: function(cls, visible) { - $('tr.'+cls, this.el)[visible?'show':'hide'](); + updateFileInfo: function() { + if (!this.rendered) + return; + + var me = this, + props = (this.api) ? this.api.asc_getCoreProps() : null, + value; + + // var app = (this.api) ? this.api.asc_getAppProps() : null; + // if (app) { + // value = app.asc_getTotalTime(); + // if (value) + // this.lblEditTime.text(value + ' ' + this.txtMinutes); + // } + // this._ShowHideInfoItem(this.lblEditTime, !!value); + + if (props) { + var visible = false; + value = props.asc_getModified(); + if (value) + this.lblModifyDate.text(value.toLocaleString()); + visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible; + value = props.asc_getLastModifiedBy(); + if (value) + this.lblModifyBy.text(value); + visible = this._ShowHideInfoItem(this.lblModifyBy, !!value) || visible; + $('tr.divider.modify', this.el)[visible?'show':'hide'](); + + value = props.asc_getTitle(); + this.inputTitle.setValue(value || ''); + value = props.asc_getSubject(); + this.inputSubject.setValue(value || ''); + value = props.asc_getDescription(); + this.inputComment.setValue(value || ''); + + this.tblAuthor.find('tr:not(:last-of-type)').remove(); + value = props.asc_getCreator();//"123\"\"\"\<\>,456"; + value && value.split(/\s*[,;]\s*/).forEach(function(item) { + var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); + me.trAuthor.before(div); + }); + } + }, + + _ShowHideInfoItem: function(el, visible) { + el.closest('tr')[visible?'show':'hide'](); + return visible; }, _ShowHideDocInfo: function(visible) { - this._ShowHideInfoItem('date', visible); - this._ShowHideInfoItem('placement', visible); - this._ShowHideInfoItem('author', visible); + this._ShowHideInfoItem(this.lblPlacement, visible); + this._ShowHideInfoItem(this.lblOwner, visible); + this._ShowHideInfoItem(this.lblUploaded, visible); }, setMode: function(mode) { @@ -700,11 +864,21 @@ define([ return this; }, - txtTitle: 'Document Title', + txtPlacement: 'Location', + txtOwner: 'Owner', + txtUploaded: 'Uploaded', + txtAppName: 'Application', + txtEditTime: 'Total Editing time', + txtTitle: 'Title', + txtSubject: 'Subject', + txtComment: 'Comment', + txtModifyDate: 'Last Modified', + txtModifyBy: 'Last Modified By', + txtCreated: 'Created', txtAuthor: 'Author', - txtPlacement: 'Placement', - txtDate: 'Creation Date', - txtAppName: 'Application' + txtAddAuthor: 'Add Author', + txtAddText: 'Add Text', + txtMinutes: 'min' }, 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 59ac33b4a..65c47f68d 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -1152,12 +1152,21 @@ "PE.Views.FileMenuPanels.CreateNew.newDocumentText": "New Presentation", "PE.Views.FileMenuPanels.CreateNew.noTemplatesText": "There are no templates", "PE.Views.FileMenuPanels.DocumentInfo.txtAppName": "Application", + "PE.Views.FileMenuPanels.DocumentInfo.txtAddAuthor": "Add Author", + "PE.Views.FileMenuPanels.DocumentInfo.txtAddText": "Add Text", "PE.Views.FileMenuPanels.DocumentInfo.txtAuthor": "Author", "PE.Views.FileMenuPanels.DocumentInfo.txtBtnAccessRights": "Change access rights", - "PE.Views.FileMenuPanels.DocumentInfo.txtDate": "Creation Date", + "PE.Views.FileMenuPanels.DocumentInfo.txtComment": "Comment", + "del_PE.Views.FileMenuPanels.DocumentInfo.txtDate": "Creation Date", + "PE.Views.FileMenuPanels.DocumentInfo.txtCreated": "Created", + "PE.Views.FileMenuPanels.DocumentInfo.txtModifyDate": "Last Modified", + "PE.Views.FileMenuPanels.DocumentInfo.txtModifyBy": "Last Modified By", + "PE.Views.FileMenuPanels.DocumentInfo.txtOwner": "Owner", "PE.Views.FileMenuPanels.DocumentInfo.txtPlacement": "Location", "PE.Views.FileMenuPanels.DocumentInfo.txtRights": "Persons who have rights", - "PE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Presentation Title", + "PE.Views.FileMenuPanels.DocumentInfo.txtSubject": "Subject", + "PE.Views.FileMenuPanels.DocumentInfo.txtTitle": "Title", + "PE.Views.FileMenuPanels.DocumentInfo.txtUploaded": "Uploaded", "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/presentationeditor/main/resources/less/leftmenu.less b/apps/presentationeditor/main/resources/less/leftmenu.less index 206dbcc46..9c0244e73 100644 --- a/apps/presentationeditor/main/resources/less/leftmenu.less +++ b/apps/presentationeditor/main/resources/less/leftmenu.less @@ -433,6 +433,22 @@ label, span { font-size: 12px; } + + .close { + width: 16px; + height: 16px; + cursor: pointer; + display: inline-block; + vertical-align: middle; + margin-left: 5px; + + background-position: @but-close-offset-x @but-close-offset-y; + + &.over, + &:hover { + background-position: @but-close-offset-x @but-close-offset-y - 16px; + } + } } #panel-protect { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 07bd8f72b..3100b1d7a 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1318,7 +1318,6 @@ define([ txtPlacement: 'Location', txtOwner: 'Owner', txtUploaded: 'Uploaded', - txtLoading: 'Loading...', txtAppName: 'Application', txtTitle: 'Title', txtSubject: 'Subject', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 5b6ada2ea..203fd7a0d 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1489,7 +1489,6 @@ "SSE.Views.FileMenuPanels.DocumentInfo.txtComment": "Comment", "del_SSE.Views.FileMenuPanels.DocumentInfo.txtDate": "Creation Date", "SSE.Views.FileMenuPanels.DocumentInfo.txtCreated": "Created", - "SSE.Views.FileMenuPanels.DocumentInfo.txtLoading": "Loading...", "SSE.Views.FileMenuPanels.DocumentInfo.txtModifyDate": "Last Modified", "SSE.Views.FileMenuPanels.DocumentInfo.txtModifyBy": "Last Modified By", "SSE.Views.FileMenuPanels.DocumentInfo.txtOwner": "Owner", From aa9c0a2f5c6511ac10e9838867a6658c0a203384 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Jun 2019 14:34:40 +0300 Subject: [PATCH 08/14] Apply document info (subject, title, comment, authors) --- .../main/app/view/FileMenuPanels.js | 38 +++++++++++++++---- .../main/app/view/FileMenuPanels.js | 38 +++++++++++++++---- .../main/app/view/FileMenuPanels.js | 38 +++++++++++++++---- apps/spreadsheeteditor/main/locale/en.json | 2 +- 4 files changed, 91 insertions(+), 25 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index d671c1583..f85c3c306 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -760,6 +760,8 @@ define([ this.infoObj = {PageCount: 0, WordsCount: 0, ParagraphCount: 0, SymbolsCount: 0, SymbolsWSCount:0}; this.inProgress = false; this.menu = options.menu; + this.coreProps = null; + this.authors = []; }, render: function() { @@ -787,7 +789,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putTitle(me.inputTitle.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), @@ -795,7 +800,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putSubject(me.inputSubject.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), @@ -803,7 +811,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putDescription(me.inputComment.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); // modify info @@ -823,7 +834,11 @@ define([ var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); - // remove idx author from info + me.authors.splice(idx, 1); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -840,10 +855,14 @@ define([ if (str) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); me.trAuthor.before(div); - // add str author to info + me.authors.push(item); } }); me.inputAuthor.setValue(''); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -903,9 +922,9 @@ define([ } this._ShowHideInfoItem(this.lblApplication, !!appname); - var props = (this.api) ? this.api.asc_getCoreProps() : null; - if (props) { - var value = props.asc_getCreated(); + this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null; + if (this.coreProps) { + var value = this.coreProps.asc_getCreated(); if (value) this.lblDate.text(value.toLocaleString()); this._ShowHideInfoItem(this.lblDate, !!value); @@ -920,6 +939,7 @@ define([ props = (this.api) ? this.api.asc_getCoreProps() : null, value; + this.coreProps = props; // var app = (this.api) ? this.api.asc_getAppProps() : null; // if (app) { // value = app.asc_getTotalTime(); @@ -948,10 +968,12 @@ define([ this.inputComment.setValue(value || ''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); + this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value && value.split(/\s*[,;]\s*/).forEach(function(item) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); me.trAuthor.before(div); + me.authors.push(item); }); } }, diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 808f55dae..eb3340c67 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -658,6 +658,8 @@ define([ ].join('')); this.menu = options.menu; + this.coreProps = null; + this.authors = []; }, render: function() { @@ -677,7 +679,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putTitle(me.inputTitle.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), @@ -685,7 +690,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putSubject(me.inputSubject.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), @@ -693,7 +701,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putDescription(me.inputComment.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); // modify info @@ -713,7 +724,11 @@ define([ var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); - // remove idx author from info + me.authors.splice(idx, 1); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -730,10 +745,14 @@ define([ if (str) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); me.trAuthor.before(div); - // add str author to info + me.authors.push(item); } }); me.inputAuthor.setValue(''); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -790,9 +809,9 @@ define([ } this._ShowHideInfoItem(this.lblApplication, !!appname); - var props = (this.api) ? this.api.asc_getCoreProps() : null; - if (props) { - var value = props.asc_getCreated(); + this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null; + if (this.coreProps) { + var value = this.coreProps.asc_getCreated(); if (value) this.lblDate.text(value.toLocaleString()); this._ShowHideInfoItem(this.lblDate, !!value); @@ -807,6 +826,7 @@ define([ props = (this.api) ? this.api.asc_getCoreProps() : null, value; + this.coreProps = props; // var app = (this.api) ? this.api.asc_getAppProps() : null; // if (app) { // value = app.asc_getTotalTime(); @@ -835,10 +855,12 @@ define([ this.inputComment.setValue(value || ''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); + this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value && value.split(/\s*[,;]\s*/).forEach(function(item) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); me.trAuthor.before(div); + me.authors.push(item); }); } }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 3100b1d7a..7436675d8 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1109,6 +1109,8 @@ define([ ].join('')); this.menu = options.menu; + this.coreProps = null; + this.authors = []; }, render: function() { @@ -1128,7 +1130,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentTitle(me.inputTitle.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putTitle(me.inputTitle.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputSubject = new Common.UI.InputField({ el : $('#id-info-subject'), @@ -1136,7 +1141,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentSubject(me.inputSubject.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putSubject(me.inputSubject.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); this.inputComment = new Common.UI.InputField({ el : $('#id-info-comment'), @@ -1144,7 +1152,10 @@ define([ placeHolder : this.txtAddText, validateOnBlur: false }).on('changed:after', function() { - // me.api && me.api.asc_setDocumentComment(me.inputComment.getValue()); + if (me.coreProps && me.api) { + me.coreProps.asc_putDescription(me.inputComment.getValue()); + me.api.asc_setCoreProps(me.coreProps); + } }); // modify info @@ -1164,7 +1175,11 @@ define([ var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); - // remove idx author from info + me.authors.splice(idx, 1); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -1181,10 +1196,14 @@ define([ if (str) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str))); me.trAuthor.before(div); - // add str author to info + me.authors.push(item); } }); me.inputAuthor.setValue(''); + if (me.coreProps && me.api) { + me.coreProps.asc_putCreator(me.authors.join(';')); + me.api.asc_setCoreProps(me.coreProps); + } } }); @@ -1241,9 +1260,9 @@ define([ } this._ShowHideInfoItem(this.lblApplication, !!appname); - var props = (this.api) ? this.api.asc_getCoreProps() : null; - if (props) { - var value = props.asc_getCreated(); + this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null; + if (this.coreProps) { + var value = this.coreProps.asc_getCreated(); if (value) this.lblDate.text(value.toLocaleString()); this._ShowHideInfoItem(this.lblDate, !!value); @@ -1258,6 +1277,7 @@ define([ props = (this.api) ? this.api.asc_getCoreProps() : null, value; + this.coreProps = props; // var app = (this.api) ? this.api.asc_getAppProps() : null; // if (app) { // value = app.asc_getTotalTime(); @@ -1286,10 +1306,12 @@ define([ this.inputComment.setValue(value || ''); this.tblAuthor.find('tr:not(:last-of-type)').remove(); + this.authors = []; value = props.asc_getCreator();//"123\"\"\"\<\>,456"; value && value.split(/\s*[,;]\s*/).forEach(function(item) { var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item))); me.trAuthor.before(div); + me.authors.push(item); }); } }, diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 203fd7a0d..142c59a95 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -754,8 +754,8 @@ "SSE.Controllers.Toolbar.textOperator": "Operators", "SSE.Controllers.Toolbar.textPivot": "Pivot Table", "SSE.Controllers.Toolbar.textRadical": "Radicals", - "SSE.Controllers.Toolbar.textScript": "Scripts", "SSE.Controllers.Toolbar.textSymbols": "Symbols", + "SSE.Controllers.Toolbar.textScript": "Scripts", "SSE.Controllers.Toolbar.textWarning": "Warning", "SSE.Controllers.Toolbar.txtAccent_Accent": "Acute", "SSE.Controllers.Toolbar.txtAccent_ArrowD": "Right-left arrow above", From d7abed8f385804a7f5ffc45e6e4a63d7482b9c43 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Jun 2019 15:14:24 +0300 Subject: [PATCH 09/14] [DE] Lock document info settings --- apps/documenteditor/main/app/view/FileMenuPanels.js | 11 ++++++++++- apps/documenteditor/main/resources/less/filemenu.less | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index f85c3c306..041fc6fa8 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -830,7 +830,7 @@ define([ this.tblAuthor.on('click', function(e) { var btn = $(e.target); - if (btn.hasClass('close')) { + if (btn.hasClass('close') && !btn.hasClass('disabled')) { var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); @@ -1008,6 +1008,7 @@ define([ this.api.asc_registerCallback('asc_onDocInfo', _.bind(this._onDocInfo, this)); this.api.asc_registerCallback('asc_onGetDocInfoEnd', _.bind(this._onGetDocInfoEnd, this)); // this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); + this.api.asc_registerCallback('asc_onLockCore', _.bind(this.onLockCore, this)); this.updateInfo(this.doc); return this; }, @@ -1059,6 +1060,14 @@ define([ // this.lblTitle.text((name) ? name : '-'); }, + onLockCore: function(lock) { + this.inputTitle.setDisabled(lock); + this.inputSubject.setDisabled(lock); + this.inputComment.setDisabled(lock); + this.inputAuthor.setDisabled(lock); + this.tblAuthor.find('.close').toggleClass('disabled', lock); + }, + txtPlacement: 'Location', txtOwner: 'Owner', txtUploaded: 'Uploaded', diff --git a/apps/documenteditor/main/resources/less/filemenu.less b/apps/documenteditor/main/resources/less/filemenu.less index 657fb30f0..aad7cc050 100644 --- a/apps/documenteditor/main/resources/less/filemenu.less +++ b/apps/documenteditor/main/resources/less/filemenu.less @@ -364,6 +364,11 @@ &:hover { background-position: @but-close-offset-x @but-close-offset-y - 16px; } + + &.disabled { + background-position: @but-close-offset-x @but-close-offset-y - 32px; + cursor: default; + } } } From e07a6caca4c778abaa2bb240a0bf2a393ce21c34 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Jun 2019 15:19:56 +0300 Subject: [PATCH 10/14] [PE][SSE] Lock document info settings --- .../main/app/view/FileMenuPanels.js | 11 ++++++++++- .../main/resources/less/leftmenu.less | 5 +++++ .../spreadsheeteditor/main/app/view/FileMenuPanels.js | 11 ++++++++++- .../main/resources/less/leftmenu.less | 5 +++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index eb3340c67..476ed2a12 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -720,7 +720,7 @@ define([ this.tblAuthor.on('click', function(e) { var btn = $(e.target); - if (btn.hasClass('close')) { + if (btn.hasClass('close') && !btn.hasClass('disabled')) { var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); @@ -882,10 +882,19 @@ define([ setApi: function(o) { this.api = o; + this.api.asc_registerCallback('asc_onLockCore', _.bind(this.onLockCore, this)); this.updateInfo(this.doc); return this; }, + onLockCore: function(lock) { + this.inputTitle.setDisabled(lock); + this.inputSubject.setDisabled(lock); + this.inputComment.setDisabled(lock); + this.inputAuthor.setDisabled(lock); + this.tblAuthor.find('.close').toggleClass('disabled', lock); + }, + txtPlacement: 'Location', txtOwner: 'Owner', txtUploaded: 'Uploaded', diff --git a/apps/presentationeditor/main/resources/less/leftmenu.less b/apps/presentationeditor/main/resources/less/leftmenu.less index 9c0244e73..8b3682eaa 100644 --- a/apps/presentationeditor/main/resources/less/leftmenu.less +++ b/apps/presentationeditor/main/resources/less/leftmenu.less @@ -448,6 +448,11 @@ &:hover { background-position: @but-close-offset-x @but-close-offset-y - 16px; } + + &.disabled { + background-position: @but-close-offset-x @but-close-offset-y - 32px; + cursor: default; + } } } diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 7436675d8..a1299b7fc 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1171,7 +1171,7 @@ define([ this.tblAuthor.on('click', function(e) { var btn = $(e.target); - if (btn.hasClass('close')) { + if (btn.hasClass('close') && !btn.hasClass('disabled')) { var el = btn.closest('tr'), idx = me.tblAuthor.find('tr').index(el); el.remove(); @@ -1333,10 +1333,19 @@ define([ setApi: function(o) { this.api = o; + this.api.asc_registerCallback('asc_onLockCore', _.bind(this.onLockCore, this)); this.updateInfo(this.doc); return this; }, + onLockCore: function(lock) { + this.inputTitle.setDisabled(lock); + this.inputSubject.setDisabled(lock); + this.inputComment.setDisabled(lock); + this.inputAuthor.setDisabled(lock); + this.tblAuthor.find('.close').toggleClass('disabled', lock); + }, + txtPlacement: 'Location', txtOwner: 'Owner', txtUploaded: 'Uploaded', diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index c048950d8..021ce8f9f 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -515,6 +515,11 @@ &:hover { background-position: @but-close-offset-x @but-close-offset-y - 16px; } + + &.disabled { + background-position: @but-close-offset-x @but-close-offset-y - 32px; + cursor: default; + } } } From e6fb81e2056fd5c2141d5f5c85df8dead018968a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Jun 2019 15:37:11 +0300 Subject: [PATCH 11/14] Refactoring documnt info changing --- .../documenteditor/main/app/view/FileMenuPanels.js | 14 ++++++++------ .../main/app/view/FileMenuPanels.js | 14 ++++++++------ .../main/app/view/FileMenuPanels.js | 14 ++++++++------ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 041fc6fa8..b6564fa6a 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -788,8 +788,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -799,8 +799,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -810,8 +810,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -848,6 +848,8 @@ define([ validateOnBlur: false, placeHolder: this.txtAddAuthor }).on('changed:after', function(input, newValue, oldValue) { + if (newValue == oldValue) return; + var val = newValue.trim(); if (!!val && val !== oldValue.trim()) { val.split(/\s*[,;]\s*/).forEach(function(item){ diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 476ed2a12..25ea27280 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -678,8 +678,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -689,8 +689,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -700,8 +700,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -738,6 +738,8 @@ define([ validateOnBlur: false, placeHolder: this.txtAddAuthor }).on('changed:after', function(input, newValue, oldValue) { + if (newValue == oldValue) return; + var val = newValue.trim(); if (!!val && val !== oldValue.trim()) { val.split(/\s*[,;]\s*/).forEach(function(item){ diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index a1299b7fc..f1ab49c2d 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1129,8 +1129,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -1140,8 +1140,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -1151,8 +1151,8 @@ define([ style : 'width: 200px;', placeHolder : this.txtAddText, validateOnBlur: false - }).on('changed:after', function() { - if (me.coreProps && me.api) { + }).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); } @@ -1189,6 +1189,8 @@ define([ validateOnBlur: false, placeHolder: this.txtAddAuthor }).on('changed:after', function(input, newValue, oldValue) { + if (newValue == oldValue) return; + var val = newValue.trim(); if (!!val && val !== oldValue.trim()) { val.split(/\s*[,;]\s*/).forEach(function(item){ From 244edfe69a11f8a3f287e2ed8e5860333232a61c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Jun 2019 16:35:23 +0300 Subject: [PATCH 12/14] Document info: undo changes by Esc button --- apps/common/main/lib/component/InputField.js | 2 ++ .../main/app/view/FileMenuPanels.js | 19 +++++++++++++++---- .../main/app/view/FileMenuPanels.js | 19 +++++++++++++++---- .../main/app/view/FileMenuPanels.js | 19 +++++++++++++++---- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/apps/common/main/lib/component/InputField.js b/apps/common/main/lib/component/InputField.js index 199a2d9ab..054721355 100644 --- a/apps/common/main/lib/component/InputField.js +++ b/apps/common/main/lib/component/InputField.js @@ -239,6 +239,8 @@ define([ }, onKeyDown: function(e) { + this.trigger('keydown:before', this, e); + if (e.isDefaultPrevented()) return; diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index b6564fa6a..d231b889e 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -783,6 +783,17 @@ define([ // this.lblEditTime = $('#id-info-edittime'); // edited info + var keyDownBefore = function(input, e){ + if (e.keyCode === Common.UI.Keys.ESC) { + var newVal = input._input.val(), + oldVal = input.getValue(); + if (newVal !== oldVal) { + input.setValue(oldVal); + e.stopPropagation(); + } + } + }; + this.inputTitle = new Common.UI.InputField({ el : $('#id-info-title'), style : 'width: 200px;', @@ -793,7 +804,7 @@ define([ 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;', @@ -804,7 +815,7 @@ define([ 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;', @@ -815,7 +826,7 @@ define([ me.coreProps.asc_putDescription(me.inputComment.getValue()); me.api.asc_setCoreProps(me.coreProps); } - }); + }).on('keydown:before', keyDownBefore); // modify info this.lblModifyDate = $('#id-info-modify-date'); @@ -866,7 +877,7 @@ define([ me.api.asc_setCoreProps(me.coreProps); } } - }); + }).on('keydown:before', keyDownBefore); this.rendered = true; diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 25ea27280..ad7b59477 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -673,6 +673,17 @@ define([ this.lblUploaded = $('#id-info-uploaded'); // edited info + var keyDownBefore = function(input, e){ + if (e.keyCode === Common.UI.Keys.ESC) { + var newVal = input._input.val(), + oldVal = input.getValue(); + if (newVal !== oldVal) { + input.setValue(oldVal); + e.stopPropagation(); + } + } + }; + this.inputTitle = new Common.UI.InputField({ el : $('#id-info-title'), style : 'width: 200px;', @@ -683,7 +694,7 @@ define([ 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;', @@ -694,7 +705,7 @@ define([ 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;', @@ -705,7 +716,7 @@ define([ me.coreProps.asc_putDescription(me.inputComment.getValue()); me.api.asc_setCoreProps(me.coreProps); } - }); + }).on('keydown:before', keyDownBefore); // modify info this.lblModifyDate = $('#id-info-modify-date'); @@ -756,7 +767,7 @@ define([ me.api.asc_setCoreProps(me.coreProps); } } - }); + }).on('keydown:before', keyDownBefore); this.rendered = true; diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index f1ab49c2d..3c9cb7ffe 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1124,6 +1124,17 @@ define([ this.lblUploaded = $('#id-info-uploaded'); // edited info + var keyDownBefore = function(input, e){ + if (e.keyCode === Common.UI.Keys.ESC) { + var newVal = input._input.val(), + oldVal = input.getValue(); + if (newVal !== oldVal) { + input.setValue(oldVal); + e.stopPropagation(); + } + } + }; + this.inputTitle = new Common.UI.InputField({ el : $('#id-info-title'), style : 'width: 200px;', @@ -1134,7 +1145,7 @@ define([ 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;', @@ -1145,7 +1156,7 @@ define([ 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;', @@ -1156,7 +1167,7 @@ define([ me.coreProps.asc_putDescription(me.inputComment.getValue()); me.api.asc_setCoreProps(me.coreProps); } - }); + }).on('keydown:before', keyDownBefore); // modify info this.lblModifyDate = $('#id-info-modify-date'); @@ -1207,7 +1218,7 @@ define([ me.api.asc_setCoreProps(me.coreProps); } } - }); + }).on('keydown:before', keyDownBefore); this.rendered = true; From 1f315318168c134a42d66a4303a00a7c65f2d7ad Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Jun 2019 17:15:40 +0300 Subject: [PATCH 13/14] Bug fixed: text is entered into the canvas when the info field lost focus --- apps/documenteditor/main/app/controller/Main.js | 2 +- apps/presentationeditor/main/app/controller/Main.js | 2 +- apps/spreadsheeteditor/main/app/controller/Main.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 1c7ef82f2..b8ae5ee19 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -230,7 +230,7 @@ define([ }); $(document.body).on('blur', 'input, textarea', function(e) { - if (!me.isModalShowed) { + if (!me.isModalShowed && !me.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file').isVisible()) { if (/form-control/.test(e.target.className)) me.inFormControl = false; if (!e.relatedTarget || diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index cc65b5160..1602e4860 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -209,7 +209,7 @@ define([ }); $(document.body).on('blur', 'input, textarea', function(e) { - if (!me.isModalShowed) { + if (!me.isModalShowed && !me.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file').isVisible()) { if (/form-control/.test(e.target.className)) me.inFormControl = false; if (!e.relatedTarget || diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 688d4fd80..69cc5b111 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -208,7 +208,7 @@ define([ $(document.body).on('blur', 'input, textarea', function(e) { if (me.isAppDisabled === true || me.isFrameClosed) return; - if (!me.isModalShowed && !(me.loadMask && me.loadMask.isVisible())) { + if (!me.isModalShowed && !(me.loadMask && me.loadMask.isVisible()) && !me.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file').isVisible()) { if (/form-control/.test(e.target.className)) me.inFormControl = false; if (!e.relatedTarget || From 59edd743d2492bc0a4c3992b6ab5452eae0e306a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Jun 2019 17:17:02 +0300 Subject: [PATCH 14/14] Update document info when accept changes --- apps/documenteditor/main/app/view/FileMenuPanels.js | 1 + apps/presentationeditor/main/app/view/FileMenuPanels.js | 1 + apps/spreadsheeteditor/main/app/view/FileMenuPanels.js | 1 + 3 files changed, 3 insertions(+) diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index d231b889e..11191c455 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -1079,6 +1079,7 @@ define([ this.inputComment.setDisabled(lock); this.inputAuthor.setDisabled(lock); this.tblAuthor.find('.close').toggleClass('disabled', lock); + !lock && this.updateFileInfo(); }, txtPlacement: 'Location', diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index ad7b59477..c3dd93d24 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -906,6 +906,7 @@ define([ this.inputComment.setDisabled(lock); this.inputAuthor.setDisabled(lock); this.tblAuthor.find('.close').toggleClass('disabled', lock); + !lock && this.updateFileInfo(); }, txtPlacement: 'Location', diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 3c9cb7ffe..e5e83fbd8 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1357,6 +1357,7 @@ define([ this.inputComment.setDisabled(lock); this.inputAuthor.setDisabled(lock); this.tblAuthor.find('.close').toggleClass('disabled', lock); + !lock && this.updateFileInfo(); }, txtPlacement: 'Location',