From 68dc9a79186041b512bd578ada505ce67916a23a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Sep 2020 17:36:27 +0300 Subject: [PATCH] [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 2b51b8a5a..1a4761971 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 151f98cec..3dd2df1f9 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',