From f61c7bbbb7c7ae547e61b1ea65ddb6ea851b8c6c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Sep 2020 16:48:45 +0300 Subject: [PATCH 01/13] [DE] Add cross-reference --- .../main/app/controller/Links.js | 21 +- .../main/app/template/Toolbar.template | 1 + .../main/app/view/CrossReferenceDialog.js | 317 ++++++++++++++++++ apps/documenteditor/main/app/view/Links.js | 18 +- 4 files changed, 354 insertions(+), 3 deletions(-) create mode 100644 apps/documenteditor/main/app/view/CrossReferenceDialog.js diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 5e52e1e461..343b797234 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -47,7 +47,8 @@ define([ 'documenteditor/main/app/view/TableOfContentsSettings', 'documenteditor/main/app/view/BookmarksDialog', 'documenteditor/main/app/view/CaptionDialog', - 'documenteditor/main/app/view/NotesRemoveDialog' + 'documenteditor/main/app/view/NotesRemoveDialog', + 'documenteditor/main/app/view/CrossReferenceDialog' ], function () { 'use strict'; @@ -69,7 +70,8 @@ define([ 'links:notes': this.onNotesClick, 'links:hyperlink': this.onHyperlinkClick, 'links:bookmarks': this.onBookmarksClick, - 'links:caption': this.onCaptionClick + 'links:caption': this.onCaptionClick, + 'links:crossref': this.onCrossRefClick }, 'DocumentHolder': { 'links:contents': this.onTableContents, @@ -171,6 +173,9 @@ define([ need_disable = in_header; this.view.btnCaption.setDisabled(need_disable); + + need_disable = paragraph_locked || header_locked || in_image; + this.view.btnCrossRef.setDisabled(need_disable); }, onApiCanAddHyperlink: function(value) { @@ -443,6 +448,18 @@ define([ onShowContentControlsActions: function(obj, x, y) { (obj.type == Asc.c_oAscContentControlSpecificType.TOC) && this.onShowTOCActions(obj, x, y); + }, + + onCrossRefClick: function(btn) { + var me = this; + (new DE.Views.CrossReferenceDialog({ + api: me.api, + handler: function (result, settings) { + if (result == 'ok') { + } + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + } + })).show(); } }, DE.Controllers.Links || {})); diff --git a/apps/documenteditor/main/app/template/Toolbar.template b/apps/documenteditor/main/app/template/Toolbar.template index 37f13e6187..ad2a425a71 100644 --- a/apps/documenteditor/main/app/template/Toolbar.template +++ b/apps/documenteditor/main/app/template/Toolbar.template @@ -158,6 +158,7 @@ + diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js new file mode 100644 index 0000000000..406e545448 --- /dev/null +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -0,0 +1,317 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2020 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +/** + * CrossReferenceDialog.js + * + * Created by Julia Radzhabova on 22.09.2020 + * Copyright (c) 2020 Ascensio System SIA. All rights reserved. + * + */ +define([ + 'common/main/lib/component/Window', + 'common/main/lib/component/ComboBox' +], function () { 'use strict'; + + DE.Views.CrossReferenceDialog = Common.UI.Window.extend(_.extend({ + options: { + width: 400, + height: 406, + style: 'min-width: 240px;', + cls: 'modal-dlg' + }, + + initialize : function(options) { + _.extend(this.options, { + title: this.txtTitle, + buttons: [{value: 'ok', caption: this.textInsert}, 'close'] + }, options || {}); + + this.template = [ + '
', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '
', + '', + '
', + '
', + '', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '', + '
', + '
', + '
' + ].join(''); + + this.props = options.props; + this.api = options.api; + this.options.tpl = _.template(this.template)(this.options); + + Common.UI.Window.prototype.initialize.call(this, this.options); + }, + + render: function() { + Common.UI.Window.prototype.render.call(this); + + var me = this, + $window = this.getChild(); + $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); + + this.cmbType = new Common.UI.ComboBox({ + el : $window.find('#id-dlg-cross-type'), + menuStyle : 'min-width: 100%;', + editable : false, + cls : 'input-group-nr', + data : [ + { value: 0, displayValue: this.textParagraph }, + { value: 1, displayValue: this.textHeading }, + { value: 2, displayValue: this.textBookmark }, + { value: 3, displayValue: this.textFootnote }, + { value: 4, displayValue: this.textEndnote }, + { value: 5, displayValue: this.textEquation }, + { value: 6, displayValue: this.textFigure }, + { value: 7, displayValue: this.textTable } + ] + }); + this.cmbType.on('selected', _.bind(this.onTypeSelected, this)); + + this.cmbReference = new Common.UI.ComboBox({ + el : $window.find('#id-dlg-cross-ref'), + menuStyle : 'min-width: 100%;max-height: 183px;', + editable : false, + cls : 'input-group-nr', + data : [] + }); + this.cmbReference.on('selected', _.bind(function (combo, record) { + if (this._changedProps) { + if (!this._changedProps.get_TextPr()) this._changedProps.put_TextPr(new AscCommonWord.CTextPr()); + this._changedProps.get_TextPr().put_FontSize((record.value>0) ? record.value : undefined); + } + if (this.api) { + this.api.SetDrawImagePreviewBullet('bulleted-list-preview', this.props, this.level, this.type==2); + } + }, this)); + + this.chInsertAs = new Common.UI.CheckBox({ + el: $window.find('#id-dlg-cross-insert-as'), + labelText: this.textInsertAs + }); + + this.chBelowAbove = new Common.UI.CheckBox({ + el: $window.find('#id-dlg-cross-below-above'), + labelText: this.textIncludeAbove + }); + + this.chSeparator = new Common.UI.CheckBox({ + el: $window.find('#id-dlg-cross-separate'), + labelText: this.textSeparate + }).on('change', _.bind(function(field, newValue, oldValue, eOpts){ + var checked = field.getValue() === 'checked'; + this.inputSeparator.setDisabled(checked); + }, this)); + + this.inputSeparator = new Common.UI.InputField({ + el: $window.findById('#id-dlg-cross-separator'), + style: 'width: 35px;', + validateOnBlur: false, + disabled: true + }); + + this.refList = new Common.UI.ListView({ + el: $window.find('#id-dlg-cross-list'), + store: new Common.UI.DataViewStore() + }); + this.refList.on('item:select', _.bind(this.onSelectReference, this)); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + _handleInput: function(state) { + if (this.options.handler) { + this.options.handler.call(this, state, {}); + } + if (state=='ok') { + return; + } + this.close(); + }, + + onBtnClick: function(event) { + this._handleInput(event.currentTarget.attributes['result'].value); + }, + + onPrimary: function(event) { + this._handleInput('ok'); + return false; + }, + + _setDefaults: function (props) { + this.cmbType.setValue(0); + this.onTypeSelected(this.cmbType, this.cmbType.getSelectedRecord()); + if (props) { + } + }, + + onSelectReference: function(listView, itemView, record) { + // record.get('value'); + }, + + onTypeSelected: function (combo, record) { + var arr = []; + switch (record.value) { + case 0: // paragraph + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }, + { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textText }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } + ]; + break; + case 1: // heading + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textHeadingText }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textHeadingNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textHeadingNumNo }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textHeadingNumFull }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } + ]; + break; + case 2: // bookmark + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textBookmarkText }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } + ]; + break; + case 3: // note + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textNoteNum }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }, + { value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textNoteNumForm } + ]; + break; + case 4: // end note + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textEndNoteNum }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }, + { value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textEndNoteNumForm } + ]; + break; + case 5: // Equation + case 6: // Shape + case 7: // Table + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.EntireCaption, displayValue: this.textCaption }, + { value: Asc.c_oAscDocumentRefenceToType.OnlyLabelAndNumber, displayValue: this.textLabelNum }, + { value: Asc.c_oAscDocumentRefenceToType.OnlyCaptionText, displayValue: this.textOnlyCaption }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } + ]; + break; + } + this.cmbReference.setData(arr); + this.cmbReference.setValue(arr[0].value); + }, + + txtTitle: 'Cross-reference', + txtType: 'Reference type', + txtReference: 'Insert reference to', + textInsertAs: 'Insert as hyperlink', + textSeparate: 'Separate numbers with', + textIncludeAbove: 'Include above/below', + textWhich: 'For which caption', + textPageNum: 'Page number', + textParaNum: 'Paragraph number', + textParaNumNo: 'Paragraph number (no context)', + textParaNumFull: 'Paragraph number (full context)', + textText: 'Paragraph text', + textAboveBelow: 'Above/below', + textHeadingText: 'Heading text', + textHeadingNum: 'Heading number', + textHeadingNumNo: 'Heading number (no context)', + textHeadingNumFull: 'Heading number (full context)', + textBookmarkText: 'Bookmark text', + textNoteNum: 'Footnote number', + textNoteNumForm: 'Footnote number (formatted)', + textEndNoteNum: 'Endnote number', + textEndNoteNumForm: 'Endnote number (formatted)', + textCaption: 'Entire caption', + textLabelNum: 'Only label and number', + textOnlyCaption: 'Only caption text', + textParagraph: 'Paragraph', + textHeading: 'Heading', + textBookmark: 'Bookmark', + textFootnote: 'Footnote', + textEndnote: 'Endnote', + textEquation: 'Equation', + textFigure: 'Figure', + textTable: 'Table', + textInsert: 'Insert' + + }, DE.Views.CrossReferenceDialog || {})) +}); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index f3fcf5c7ff..e16614ad0e 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -124,6 +124,10 @@ define([ this.btnCaption.on('click', function (b, e) { me.fireEvent('links:caption'); }); + + this.btnCrossRef.on('click', function (b, e) { + me.fireEvent('links:crossref'); + }); } return { @@ -177,6 +181,15 @@ define([ }); this.paragraphControls.push(this.btnCaption); + this.btnCrossRef = new Common.UI.Button({ + parentEl: $host.find('#slot-btn-crossref'), + cls: 'btn-toolbar x-huge icon-top', + iconCls: 'toolbar__icon btn-crossref', + caption: this.capBtnCrossRef, + disabled: true + }); + this.paragraphControls.push(this.btnCrossRef); + this._state = {disabled: false}; Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, @@ -308,6 +321,7 @@ define([ me.btnBookmarks.updateHint(me.tipBookmarks); me.btnCaption.updateHint(me.tipCaption); + me.btnCrossRef.updateHint(me.tipCrossRef); setEvents.call(me); }); @@ -357,7 +371,9 @@ define([ mniInsEndnote: 'Insert Endnote', textConvertToEndnotes: 'Convert All Footnotes to Endnotes', textConvertToFootnotes: 'Convert All Endnotes to Footnotes', - textSwapNotes: 'Swap Footnotes and Endnotes' + textSwapNotes: 'Swap Footnotes and Endnotes', + capBtnCrossRef: 'Cross-reference', + tipCrossRef: 'Insert cross-reference' } }()), DE.Views.Links || {})); }); \ No newline at end of file From 20954eedea8eb9a6606c1e9d83dd2d5cddfcc92a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Sep 2020 20:48:06 +0300 Subject: [PATCH 02/13] Refactoring --- apps/documenteditor/main/app/view/CrossReferenceDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index 406e545448..d0e611e846 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -160,7 +160,7 @@ define([ labelText: this.textSeparate }).on('change', _.bind(function(field, newValue, oldValue, eOpts){ var checked = field.getValue() === 'checked'; - this.inputSeparator.setDisabled(checked); + this.inputSeparator.setDisabled(!checked); }, this)); this.inputSeparator = new Common.UI.InputField({ From 770c62fb13bb360230c8d184d255d334ec38ebff Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Sep 2020 13:08:37 +0300 Subject: [PATCH 03/13] [DE] Cross-reference: add labels from caption dialog --- .../main/app/view/CrossReferenceDialog.js | 167 ++++++++++-------- 1 file changed, 98 insertions(+), 69 deletions(-) diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index d0e611e846..bf4f9871b3 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -88,7 +88,7 @@ define([ '', '', '', - '', + '', '
', '', '', @@ -110,9 +110,27 @@ define([ $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); + var arr = Common.Utils.InternalSettings.get("de-settings-captions"); + if (arr==null || arr==undefined) { + arr = Common.localStorage.getItem("de-settings-captions") || ''; + Common.Utils.InternalSettings.set("de-settings-captions", arr); + } + arr = arr ? JSON.parse(arr) : []; + + // 0 - not removable + arr = arr.concat([{ value: 5, displayValue: this.textEquation }, + { value: 6, displayValue: this.textFigure }, + { value: 7, displayValue: this.textTable } + ]); + arr.sort(function(a,b){ + var sa = a.displayValue.toLowerCase(), + sb = b.displayValue.toLowerCase(); + return sa>sb ? 1 : (sa 4) { + // custom labels from caption dialog and Equation, Figure, Table + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textCaption }, + { value: Asc.c_oAscDocumentRefenceToType.OnlyLabelAndNumber, displayValue: this.textLabelNum }, + { value: Asc.c_oAscDocumentRefenceToType.OnlyCaptionText, displayValue: this.textOnlyCaption }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } + ]; + } else { + switch (record.value) { + case 0: // paragraph + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }, + { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textText }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } + ]; + str = this.textWhichPara; + break; + case 1: // heading + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textHeadingText }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textHeadingNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textHeadingNumNo }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textHeadingNumFull }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } + ]; + str = this.textWhichHeading; + break; + case 2: // bookmark + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textBookmarkText }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo }, + { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } + ]; + str = this.textWhichBookmark; + break; + case 3: // note + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textNoteNum }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }, + { value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textNoteNumForm } + ]; + str = this.textWhichNote; + break; + case 4: // end note + arr = [ + { value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textEndNoteNum }, + { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, + { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }, + { value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textEndNoteNumForm } + ]; + str = this.textWhichEndnote; + break; + } } this.cmbReference.setData(arr); this.cmbReference.setValue(arr[0].value); + this.lblWhich.text(str); }, txtTitle: 'Cross-reference', @@ -284,7 +308,6 @@ define([ textInsertAs: 'Insert as hyperlink', textSeparate: 'Separate numbers with', textIncludeAbove: 'Include above/below', - textWhich: 'For which caption', textPageNum: 'Page number', textParaNum: 'Paragraph number', textParaNumNo: 'Paragraph number (no context)', @@ -311,7 +334,13 @@ define([ textEquation: 'Equation', textFigure: 'Figure', textTable: 'Table', - textInsert: 'Insert' + textInsert: 'Insert', + textWhich: 'For which caption', + textWhichHeading: 'For which heading', + textWhichBookmark: 'For which bookmark', + textWhichNote: 'For which footnote', + textWhichEndnote: 'For which endnote', + textWhichPara: 'For which numbered item' }, DE.Views.CrossReferenceDialog || {})) }); \ No newline at end of file From 27f857acc9d31c82306051dd6a374849f0f0e33e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Sep 2020 15:57:01 +0300 Subject: [PATCH 04/13] [DE] Insert references --- .../main/app/controller/Links.js | 2 +- .../main/app/view/CrossReferenceDialog.js | 112 +++++++++++++++--- 2 files changed, 97 insertions(+), 17 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 343b797234..2b51b8a5a7 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -174,7 +174,7 @@ define([ need_disable = in_header; this.view.btnCaption.setDisabled(need_disable); - need_disable = paragraph_locked || header_locked || in_image; + need_disable = paragraph_locked || header_locked; this.view.btnCrossRef.setDisabled(need_disable); }, diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index bf4f9871b3..1dea0b7a64 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -89,7 +89,7 @@ define([ '', '', '', - '
', + '
', '', '', '', @@ -150,15 +150,7 @@ define([ cls : 'input-group-nr', data : [] }); - this.cmbReference.on('selected', _.bind(function (combo, record) { - if (this._changedProps) { - if (!this._changedProps.get_TextPr()) this._changedProps.put_TextPr(new AscCommonWord.CTextPr()); - this._changedProps.get_TextPr().put_FontSize((record.value>0) ? record.value : undefined); - } - if (this.api) { - this.api.SetDrawImagePreviewBullet('bulleted-list-preview', this.props, this.level, this.type==2); - } - }, this)); + this.cmbReference.on('selected', _.bind(this.onReferenceSelected, this)); this.chInsertAs = new Common.UI.CheckBox({ el: $window.find('#id-dlg-cross-insert-as'), @@ -187,12 +179,17 @@ define([ this.refList = new Common.UI.ListView({ el: $window.find('#id-dlg-cross-list'), - store: new Common.UI.DataViewStore() + store: new Common.UI.DataViewStore(), + itemTemplate: _.template('
<%= value %>
') }); - this.refList.on('item:select', _.bind(this.onSelectReference, this)); this.lblWhich = $window.find('#id-dlg-cross-which'); + this.btnInsert = new Common.UI.Button({ + el: $window.find('.primary'), + disabled: true + }); + this.afterRender(); }, @@ -205,6 +202,7 @@ define([ this.options.handler.call(this, state, {}); } if (state=='ok') { + this.insertReference(); return; } this.close(); @@ -226,13 +224,41 @@ define([ } }, - onSelectReference: function(listView, itemView, record) { - // record.get('value'); + insertReference: function() { + var record = this.refList.getSelectedRec(), + typeRec = this.cmbType.getSelectedRecord(), + type = (typeRec.type==1 || typeRec.value>4) ? 5 : typeRec.value, + reftype = this.cmbReference.getValue(), + link = this.chInsertAs.getValue()=='checked', + below = this.chBelowAbove.getValue()=='checked', + separator = (this.chSeparator.getValue()=='checked') ? this.inputSeparator.getValue() : undefined; + + switch (type) { + case 0: // paragraph + case 1: // heading + this.api.asc_AddCrossRefToParagraph(record.get('para'), reftype, link, below, separator); + break; + case 2: // bookmark + this.api.asc_AddCrossRefToBookmark(record.get('value'), reftype, link, below, separator); + break; + case 3: // footnote + case 4: // endnote + this.api.asc_AddCrossRefToNote(record.get('para'), reftype, link, below); + break; + case 5: // caption + if (reftype==Asc.c_oAscDocumentRefenceToType.OnlyCaptionText && record.get('para').asc_canAddRefToCaptionText()===false) { + Common.UI.warning({ + msg : this.textEmpty + }); + } else + this.api.asc_AddCrossRefToCaption(record.get('value'), record.get('para'), reftype, link, below); + break; + } }, onTypeSelected: function (combo, record) { var arr = [], - str = this.textWhich; + str = this.textWhich, type = 5; if (record.type==1 || record.value > 4) { // custom labels from caption dialog and Equation, Figure, Table arr = [ @@ -243,6 +269,7 @@ define([ { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } ]; } else { + type = record.value; switch (record.value) { case 0: // paragraph arr = [ @@ -300,6 +327,58 @@ define([ this.cmbReference.setData(arr); this.cmbReference.setValue(arr[0].value); this.lblWhich.text(str); + this.refreshReferences(type); + }, + + refreshReferences: function(type) { + var store = this.refList.store, + arr = [], + props; + switch (type) { + case 0: // paragraph + props = this.api.asc_GetAllNumberedParagraphs(); + break; + case 1: // heading + props = this.api.asc_GetAllHeadingParagraphs(); + break; + case 2: // bookmark + props = this.api.asc_GetBookmarksManager(); + break; + case 3: // footnote + props = this.api.asc_GetAllFootNoteParagraphs(); + break; + case 4: // endnote + props = this.api.asc_GetAllEndNoteParagraphs(); + break; + case 5: // caption + props = this.api.asc_GetAllCaptionParagraphs(this.cmbType.getSelectedRecord().displayValue); + break; + } + if (type==2) { // bookmark + var count = props.asc_GetCount(); + for (var i=0; i0) { + var rec = store.at(0); + this.refList.selectRecord(rec); + this.refList.scrollToRecord(rec); + } + this.btnInsert.setDisabled(arr.length<1); + }, + + onReferenceSelected: function(combo, record) { + }, txtTitle: 'Cross-reference', @@ -340,7 +419,8 @@ define([ textWhichBookmark: 'For which bookmark', textWhichNote: 'For which footnote', textWhichEndnote: 'For which endnote', - textWhichPara: 'For which numbered item' + textWhichPara: 'For which numbered item', + textEmpty: 'The request reference is empty.' }, DE.Views.CrossReferenceDialog || {})) }); \ No newline at end of file From 60bc2aa98cee59ad76d2a1a645c930ec53cf5427 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Sep 2020 16:35:11 +0300 Subject: [PATCH 05/13] [DE] Cross-references refactoring --- .../main/app/view/CrossReferenceDialog.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index 1dea0b7a64..151f98cec0 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -154,7 +154,8 @@ define([ this.chInsertAs = new Common.UI.CheckBox({ el: $window.find('#id-dlg-cross-insert-as'), - labelText: this.textInsertAs + labelText: this.textInsertAs, + value: true }); this.chBelowAbove = new Common.UI.CheckBox({ @@ -180,7 +181,7 @@ define([ this.refList = new Common.UI.ListView({ el: $window.find('#id-dlg-cross-list'), store: new Common.UI.DataViewStore(), - itemTemplate: _.template('
<%= value %>
') + itemTemplate: _.template('
<%= value %>
') }); this.lblWhich = $window.find('#id-dlg-cross-which'); @@ -326,6 +327,7 @@ define([ } this.cmbReference.setData(arr); this.cmbReference.setValue(arr[0].value); + this.onReferenceSelected(this.cmbReference, this.cmbReference.getSelectedRecord()); this.lblWhich.text(str); this.refreshReferences(type); }, @@ -358,7 +360,7 @@ define([ var count = props.asc_GetCount(); for (var i=0; i4) ? 5 : typeRec.value; + var disable = (type==5 && refType!==Asc.c_oAscDocumentRefenceToType.PageNum) || (type<5) && (refType==Asc.c_oAscDocumentRefenceToType.Text || refType==Asc.c_oAscDocumentRefenceToType.AboveBelow); + this.chBelowAbove.setDisabled(disable); + disable = !(type==0 || type==2) || (refType!==Asc.c_oAscDocumentRefenceToType.ParaNumFullContex); + this.chSeparator.setDisabled(disable); + this.inputSeparator.setDisabled(disable || this.chSeparator.getValue()!=='checked'); }, txtTitle: 'Cross-reference', @@ -405,7 +414,7 @@ define([ textCaption: 'Entire caption', textLabelNum: 'Only label and number', textOnlyCaption: 'Only caption text', - textParagraph: 'Paragraph', + textParagraph: 'Numbered item', textHeading: 'Heading', textBookmark: 'Bookmark', textFootnote: 'Footnote', From 68dc9a79186041b512bd578ada505ce67916a23a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Sep 2020 17:36:27 +0300 Subject: [PATCH 06/13] [DE] Add locking for cross-reference button --- .../main/app/controller/Links.js | 20 ++++++++++++------- .../main/app/view/CrossReferenceDialog.js | 11 ++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 2b51b8a5a7..1a47619718 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -156,12 +156,15 @@ define([ this._state.in_object = in_image || in_table || in_equation; var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null, - control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false; + control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false, + lock_type = control_props ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked, + content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked; var rich_del_lock = (frame_pr) ? !frame_pr.can_DeleteBlockContentControl() : false, rich_edit_lock = (frame_pr) ? !frame_pr.can_EditBlockContentControl() : false, plain_del_lock = (frame_pr) ? !frame_pr.can_DeleteInlineContentControl() : false, plain_edit_lock = (frame_pr) ? !frame_pr.can_EditInlineContentControl() : false; + var need_disable = paragraph_locked || in_equation || in_image || in_header || control_plain || rich_edit_lock || plain_edit_lock; this.view.btnsNotes.setDisabled(need_disable); @@ -174,8 +177,9 @@ define([ need_disable = in_header; this.view.btnCaption.setDisabled(need_disable); - need_disable = paragraph_locked || header_locked; + need_disable = paragraph_locked || header_locked || control_plain || rich_edit_lock || plain_edit_lock || content_locked; this.view.btnCrossRef.setDisabled(need_disable); + this.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible() && this.dlgCrossRefDialog.setLocked(need_disable); }, onApiCanAddHyperlink: function(value) { @@ -451,15 +455,17 @@ define([ }, onCrossRefClick: function(btn) { + if (this.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible()) return; + var me = this; - (new DE.Views.CrossReferenceDialog({ + me.dlgCrossRefDialog = new DE.Views.CrossReferenceDialog({ api: me.api, handler: function (result, settings) { - if (result == 'ok') { - } - Common.NotificationCenter.trigger('edit:complete', me.toolbar); + if (result != 'ok') + Common.NotificationCenter.trigger('edit:complete', me.toolbar); } - })).show(); + }); + me.dlgCrossRefDialog.show(); } }, DE.Controllers.Links || {})); diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index 151f98cec0..3dd2df1f92 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -48,7 +48,8 @@ define([ width: 400, height: 406, style: 'min-width: 240px;', - cls: 'modal-dlg' + cls: 'modal-dlg', + modal: false }, initialize : function(options) { @@ -99,6 +100,7 @@ define([ this.props = options.props; this.api = options.api; this.options.tpl = _.template(this.template)(this.options); + this._locked = false; Common.UI.Window.prototype.initialize.call(this, this.options); }, @@ -376,7 +378,7 @@ define([ this.refList.selectRecord(rec); this.refList.scrollToRecord(rec); } - this.btnInsert.setDisabled(arr.length<1); + this.btnInsert.setDisabled(arr.length<1 || this._locked); }, onReferenceSelected: function(combo, record) { @@ -390,6 +392,11 @@ define([ this.inputSeparator.setDisabled(disable || this.chSeparator.getValue()!=='checked'); }, + setLocked: function(locked){ + this._locked = locked; + this.btnInsert.setDisabled(this.refList.store.length<1 || this._locked); + }, + txtTitle: 'Cross-reference', txtType: 'Reference type', txtReference: 'Insert reference to', From 39b45d0c6f42cde22051cf7fc123e6c61403a7fa Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Sep 2020 17:45:44 +0300 Subject: [PATCH 07/13] [DE] Add translation --- .../main/app/view/CrossReferenceDialog.js | 2 +- apps/documenteditor/main/locale/en.json | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index 3dd2df1f92..fe8f9e271d 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -46,7 +46,7 @@ define([ DE.Views.CrossReferenceDialog = Common.UI.Window.extend(_.extend({ options: { width: 400, - height: 406, + height: 407, style: 'min-width: 240px;', cls: 'modal-dlg', modal: false diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index d693c7ce79..c31af1caf5 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1222,6 +1222,46 @@ "DE.Views.ControlSettingsDialog.tipChange": "Change symbol", "DE.Views.ControlSettingsDialog.txtLockDelete": "Content control cannot be deleted", "DE.Views.ControlSettingsDialog.txtLockEdit": "Contents cannot be edited", + "DE.Views.CrossReferenceDialog.txtTitle": "Cross-reference", + "DE.Views.CrossReferenceDialog.txtType": "Reference type", + "DE.Views.CrossReferenceDialog.txtReference": "Insert reference to", + "DE.Views.CrossReferenceDialog.textInsertAs": "Insert as hyperlink", + "DE.Views.CrossReferenceDialog.textSeparate": "Separate numbers with", + "DE.Views.CrossReferenceDialog.textIncludeAbove": "Include above/below", + "DE.Views.CrossReferenceDialog.textPageNum": "Page number", + "DE.Views.CrossReferenceDialog.textParaNum": "Paragraph number", + "DE.Views.CrossReferenceDialog.textParaNumNo": "Paragraph number (no context)", + "DE.Views.CrossReferenceDialog.textParaNumFull": "Paragraph number (full context)", + "DE.Views.CrossReferenceDialog.textText": "Paragraph text", + "DE.Views.CrossReferenceDialog.textAboveBelow": "Above/below", + "DE.Views.CrossReferenceDialog.textHeadingText": "Heading text", + "DE.Views.CrossReferenceDialog.textHeadingNum": "Heading number", + "DE.Views.CrossReferenceDialog.textHeadingNumNo": "Heading number (no context)", + "DE.Views.CrossReferenceDialog.textHeadingNumFull": "Heading number (full context)", + "DE.Views.CrossReferenceDialog.textBookmarkText": "Bookmark text", + "DE.Views.CrossReferenceDialog.textNoteNum": "Footnote number", + "DE.Views.CrossReferenceDialog.textNoteNumForm": "Footnote number (formatted)", + "DE.Views.CrossReferenceDialog.textEndNoteNum": "Endnote number", + "DE.Views.CrossReferenceDialog.textEndNoteNumForm": "Endnote number (formatted)", + "DE.Views.CrossReferenceDialog.textCaption": "Entire caption", + "DE.Views.CrossReferenceDialog.textLabelNum": "Only label and number", + "DE.Views.CrossReferenceDialog.textOnlyCaption": "Only caption text", + "DE.Views.CrossReferenceDialog.textParagraph": "Numbered item", + "DE.Views.CrossReferenceDialog.textHeading": "Heading", + "DE.Views.CrossReferenceDialog.textBookmark": "Bookmark", + "DE.Views.CrossReferenceDialog.textFootnote": "Footnote", + "DE.Views.CrossReferenceDialog.textEndnote": "Endnote", + "DE.Views.CrossReferenceDialog.textEquation": "Equation", + "DE.Views.CrossReferenceDialog.textFigure": "Figure", + "DE.Views.CrossReferenceDialog.textTable": "Table", + "DE.Views.CrossReferenceDialog.textInsert": "Insert", + "DE.Views.CrossReferenceDialog.textWhich": "For which caption", + "DE.Views.CrossReferenceDialog.textWhichHeading": "For which heading", + "DE.Views.CrossReferenceDialog.textWhichBookmark": "For which bookmark", + "DE.Views.CrossReferenceDialog.textWhichNote": "For which footnote", + "DE.Views.CrossReferenceDialog.textWhichEndnote": "For which endnote", + "DE.Views.CrossReferenceDialog.textWhichPara": "For which numbered item", + "DE.Views.CrossReferenceDialog.textEmpty": "The request reference is empty.", "DE.Views.CustomColumnsDialog.textColumns": "Number of columns", "DE.Views.CustomColumnsDialog.textSeparator": "Column divider", "DE.Views.CustomColumnsDialog.textSpacing": "Spacing between columns", @@ -1782,6 +1822,8 @@ "DE.Views.Links.textConvertToEndnotes": "Convert All Footnotes to Endnotes", "DE.Views.Links.textConvertToFootnotes": "Convert All Endnotes to Footnotes", "DE.Views.Links.textSwapNotes": "Swap Footnotes and Endnotes", + "DE.Views.Links.capBtnCrossRef": "Cross-reference", + "DE.Views.Links.tipCrossRef": "Insert cross-reference", "DE.Views.ListSettingsDialog.textAuto": "Automatic", "DE.Views.ListSettingsDialog.textCenter": "Center", "DE.Views.ListSettingsDialog.textLeft": "Left", From f0e84b5005c35fbda643fdae8a6455d2384b0188 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 24 Sep 2020 12:47:58 +0300 Subject: [PATCH 08/13] [DE] Refactoring --- apps/documenteditor/main/app/view/CrossReferenceDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index fe8f9e271d..75d4136b07 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -249,7 +249,7 @@ define([ this.api.asc_AddCrossRefToNote(record.get('para'), reftype, link, below); break; case 5: // caption - if (reftype==Asc.c_oAscDocumentRefenceToType.OnlyCaptionText && record.get('para').asc_canAddRefToCaptionText()===false) { + if (reftype==Asc.c_oAscDocumentRefenceToType.OnlyCaptionText && record.get('para').asc_canAddRefToCaptionText(record.get('value'))===false) { Common.UI.warning({ msg : this.textEmpty }); From 1e9d6650a9923bbcb9a515171c9cb4c4d0c07204 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 24 Sep 2020 16:04:48 +0300 Subject: [PATCH 09/13] [DE] Refactoring --- apps/documenteditor/main/app/view/CrossReferenceDialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index 75d4136b07..b644c87762 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -249,12 +249,12 @@ define([ this.api.asc_AddCrossRefToNote(record.get('para'), reftype, link, below); break; case 5: // caption - if (reftype==Asc.c_oAscDocumentRefenceToType.OnlyCaptionText && record.get('para').asc_canAddRefToCaptionText(record.get('value'))===false) { + if (reftype==Asc.c_oAscDocumentRefenceToType.OnlyCaptionText && record.get('para').asc_canAddRefToCaptionText(typeRec.displayValue)===false) { Common.UI.warning({ msg : this.textEmpty }); } else - this.api.asc_AddCrossRefToCaption(record.get('value'), record.get('para'), reftype, link, below); + this.api.asc_AddCrossRefToCaption(typeRec.displayValue, record.get('para'), reftype, link, below); break; } }, From aa9c3e3c02d294ecf1282db694d1632df5c48989 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 24 Sep 2020 17:03:46 +0300 Subject: [PATCH 10/13] [DE] Cross-references: save last used settings --- .../main/app/controller/Links.js | 4 +++ .../main/app/view/CrossReferenceDialog.js | 28 +++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 1a47619718..661e67e2ee 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -460,11 +460,15 @@ define([ var me = this; me.dlgCrossRefDialog = new DE.Views.CrossReferenceDialog({ api: me.api, + crossRefProps: me.crossRefProps, handler: function (result, settings) { if (result != 'ok') Common.NotificationCenter.trigger('edit:complete', me.toolbar); } }); + me.dlgCrossRefDialog.on('close', function(obj){ + me.crossRefProps = me.dlgCrossRefDialog.getSettings(); + }); me.dlgCrossRefDialog.show(); } diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index b644c87762..ba689ea6ad 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -97,7 +97,7 @@ define([ '' ].join(''); - this.props = options.props; + this.crossRefProps = options.crossRefProps; this.api = options.api; this.options.tpl = _.template(this.template)(this.options); this._locked = false; @@ -197,12 +197,12 @@ define([ }, afterRender: function() { - this._setDefaults(this.props); + this._setDefaults(); }, _handleInput: function(state) { if (this.options.handler) { - this.options.handler.call(this, state, {}); + this.options.handler.call(this, state); } if (state=='ok') { this.insertReference(); @@ -220,11 +220,19 @@ define([ return false; }, - _setDefaults: function (props) { - this.cmbType.setValue(0); - this.onTypeSelected(this.cmbType, this.cmbType.getSelectedRecord()); - if (props) { + getSettings: function() { + return {type: this.cmbType.getValue(), refType: this.cmbReference.getValue()}; + }, + + _setDefaults: function () { + var rec, + currentRef; + if (this.crossRefProps) { + rec = this.cmbType.store.findWhere({value: this.crossRefProps.type}); + rec && (currentRef = this.crossRefProps.refType); } + rec ? this.cmbType.selectRecord(rec) : this.cmbType.setValue(0); + this.refreshReferenceTypes(this.cmbType.getSelectedRecord(), currentRef); }, insertReference: function() { @@ -260,6 +268,10 @@ define([ }, onTypeSelected: function (combo, record) { + this.refreshReferenceTypes(record); + }, + + refreshReferenceTypes: function(record, currentRef) { var arr = [], str = this.textWhich, type = 5; if (record.type==1 || record.value > 4) { @@ -328,7 +340,7 @@ define([ } } this.cmbReference.setData(arr); - this.cmbReference.setValue(arr[0].value); + this.cmbReference.setValue(currentRef ? currentRef : arr[0].value); this.onReferenceSelected(this.cmbReference, this.cmbReference.getSelectedRecord()); this.lblWhich.text(str); this.refreshReferences(type); From ccac16c69c39897c3637894a50cbbbd2ec482f48 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 25 Sep 2020 18:17:54 +0300 Subject: [PATCH 11/13] [DE] Refactoring keydown in cross-reference dialog --- apps/documenteditor/main/app/view/CrossReferenceDialog.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index ba689ea6ad..094a906e34 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -185,6 +185,7 @@ define([ store: new Common.UI.DataViewStore(), itemTemplate: _.template('
<%= value %>
') }); + this.refList.on('entervalue', _.bind(this.onPrimary, this)); this.lblWhich = $window.find('#id-dlg-cross-which'); @@ -205,7 +206,10 @@ define([ this.options.handler.call(this, state); } if (state=='ok') { - this.insertReference(); + if(document.activeElement && document.activeElement.localName == 'textarea' && /area_id/.test(document.activeElement.id)){ + return; + } + !this.btnInsert.isDisabled() && this.insertReference(); return; } this.close(); From 8992318be7c0df3f6396988bd25b97b31d6d0633 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 25 Sep 2020 21:13:17 +0300 Subject: [PATCH 12/13] [DE] Add icons --- apps/documenteditor/main/app/view/Links.js | 2 +- .../img/toolbar/1.25x/big/btn-cross-reference.png | Bin 0 -> 319 bytes .../img/toolbar/1.5x/big/btn-cross-reference.png | Bin 0 -> 358 bytes .../img/toolbar/1.75x/big/btn-cross-reference.png | Bin 0 -> 358 bytes .../img/toolbar/1x/big/btn-cross-reference.png | Bin 0 -> 276 bytes .../img/toolbar/2x/big/btn-cross-reference.png | Bin 0 -> 554 bytes 6 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.25x/big/btn-cross-reference.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.5x/big/btn-cross-reference.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.75x/big/btn-cross-reference.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1x/big/btn-cross-reference.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/2x/big/btn-cross-reference.png diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index e16614ad0e..5477712e00 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -184,7 +184,7 @@ define([ this.btnCrossRef = new Common.UI.Button({ parentEl: $host.find('#slot-btn-crossref'), cls: 'btn-toolbar x-huge icon-top', - iconCls: 'toolbar__icon btn-crossref', + iconCls: 'toolbar__icon btn-cross-reference', caption: this.capBtnCrossRef, disabled: true }); diff --git a/apps/documenteditor/main/resources/img/toolbar/1.25x/big/btn-cross-reference.png b/apps/documenteditor/main/resources/img/toolbar/1.25x/big/btn-cross-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..627bfeea4a9f21252eeaf74c1b4674a60e3ab254 GIT binary patch literal 319 zcmV-F0l@x=P)Rs1XF}gC@`y0|viPtI(i%PCSTG zF%=`k^h`L9o--z8gc@gH2%+1;BPW4^k!#FheWq_$gxR+Vop@z*`x(h6abhdeVuTNI zveHDB+zn~6aAJ%ZNR#gsjUvnd4G)D;gwe_{p=Yf`7zGBvP{K56Wfn@b*ss#0R?4B+ zi%XkOj0yI<6|?>32r%1LF%@$s#ss$zhBGknEkr6N9y4kNXKpHv|8QQwd6?}Z3FLIE zJ960=?5-VJbZ{b!`K`THfLUjO6<|_FvR~9cp4T(qW)N1v3%`8uT!zo7inEqe~`12RH;b6gV<(MT@#& zbScCYEpPyiLM=~H^vo-#mv^8DO)-a&I83u!0O}=+vBNQvpE9AZdET~SBktFLxgigpv$e3tQ{ajqT zkf4iu;zELMnX$PV1T>%xX>9~u>HK+?u#*HdpaCW23n!kv(`dWHumAu607*qoM6N<$ Ef;3)}N&o-= literal 0 HcmV?d00001 diff --git a/apps/documenteditor/main/resources/img/toolbar/1.75x/big/btn-cross-reference.png b/apps/documenteditor/main/resources/img/toolbar/1.75x/big/btn-cross-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..8c3ea3ab944509fcdd847e662920d330f93d2492 GIT binary patch literal 358 zcmV-s0h#`ZP)9cp4T(qW)N1v3%`8uT!zo7inEqe~`12RH;b6gV<(MT@#& zbScCYEpPyiLM=~H^vo-#mv^8DO)-a&I83u!0O}=+vBNQvpE9AZdET~SBktFLxgigpv$e3tQ{ajqT zkf4iu;zELMnX$PV1T>%xX>9~u>HK+?u#*HdpaCW23n!kv(`dWHumAu607*qoM6N<$ Ef;3)}N&o-= literal 0 HcmV?d00001 diff --git a/apps/documenteditor/main/resources/img/toolbar/1x/big/btn-cross-reference.png b/apps/documenteditor/main/resources/img/toolbar/1x/big/btn-cross-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..bd8ff7f2340221deefa71588b35c432c4f4a535b GIT binary patch literal 276 zcmV+v0qg#WP)RDghNyV{h50e@XWpPxssw~pd9@zuwJzSaP-SD aHL4dLD5WX#7X=6a0000gx z4zyUkB*-tAA^!dU`yhNi{=9-hz6j;LH)rLgE*Sf58-^*x1UrQzz$Q?8kp6|9WA zeNbZe8vm-d8}FsmT#{D1_pD*V$BNmEho-&M<8G<0Il=gF;=D}PpkH_$whp+by$DF zG@e&;tvhBkJ)X_u<-_F{EcT+G!9Ab7l0o7IUzy@Pr*zh8@%(k$o8F&nX8q$K*P-|O te-h)=+^Lthhx*+Qv#gE&@4NJp`fYxxClcn79>B0?@O1TaS?83{1OVgA{yYEx literal 0 HcmV?d00001 From be82d31de117813fe5f7e95557b8ca70c93a5d0e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 25 Sep 2020 23:01:19 +0300 Subject: [PATCH 13/13] [DE] Fix insert cross-reference --- .../documenteditor/main/app/view/CrossReferenceDialog.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/documenteditor/main/app/view/CrossReferenceDialog.js b/apps/documenteditor/main/app/view/CrossReferenceDialog.js index 094a906e34..cfc5b6f61c 100644 --- a/apps/documenteditor/main/app/view/CrossReferenceDialog.js +++ b/apps/documenteditor/main/app/view/CrossReferenceDialog.js @@ -185,7 +185,8 @@ define([ store: new Common.UI.DataViewStore(), itemTemplate: _.template('
<%= value %>
') }); - this.refList.on('entervalue', _.bind(this.onPrimary, this)); + this.refList.on('entervalue', _.bind(this.onPrimary, this)) + .on('item:dblclick', _.bind(this.onPrimary, this)); this.lblWhich = $window.find('#id-dlg-cross-which'); @@ -201,12 +202,12 @@ define([ this._setDefaults(); }, - _handleInput: function(state) { + _handleInput: function(state, fromButton) { if (this.options.handler) { this.options.handler.call(this, state); } if (state=='ok') { - if(document.activeElement && document.activeElement.localName == 'textarea' && /area_id/.test(document.activeElement.id)){ + if(!fromButton && document.activeElement && document.activeElement.localName == 'textarea' && /area_id/.test(document.activeElement.id)){ return; } !this.btnInsert.isDisabled() && this.insertReference(); @@ -216,7 +217,7 @@ define([ }, onBtnClick: function(event) { - this._handleInput(event.currentTarget.attributes['result'].value); + this._handleInput(event.currentTarget.attributes['result'].value, true); }, onPrimary: function(event) {