From 493a464076139514852f37987030c6033f52983f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Nov 2017 16:29:05 +0300 Subject: [PATCH] Refactoring signatures: enable adding invisible signature when document is signed. --- apps/common/main/lib/controller/Protection.js | 17 +++++++++-------- .../common/main/lib/controller/ReviewChanges.js | 8 ++++++-- apps/common/main/lib/view/Protection.js | 12 ++++++++---- .../main/app/controller/RightMenu.js | 3 --- .../main/app/controller/RightMenu.js | 2 -- .../main/app/controller/RightMenu.js | 3 --- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/apps/common/main/lib/controller/Protection.js b/apps/common/main/lib/controller/Protection.js index 0bde39832..99e8ac821 100644 --- a/apps/common/main/lib/controller/Protection.js +++ b/apps/common/main/lib/controller/Protection.js @@ -74,7 +74,7 @@ define([ this._state = {}; Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); - Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); }, setConfig: function (data, api) { this.setApi(api); @@ -96,7 +96,7 @@ define([ this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onApiUpdateSignatures, this)); } } - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.SetDisabled, this)); + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } }, @@ -114,8 +114,8 @@ define([ this.view && this.view.onDocumentPassword(hasPassword); }, - SetDisabled: function(state) { - this.view && this.view.SetDisabled(state); + SetDisabled: function(state, canProtect) { + this.view && this.view.SetDisabled(state, canProtect); }, onPasswordClick: function(btn, opts){ @@ -148,9 +148,6 @@ define([ }, onAppReady: function (config) { - var me = this; - // this.onApiUpdateSignatures([{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}], [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]); - // this.onDocumentPassword(true); }, addPassword: function() { @@ -244,7 +241,11 @@ define([ }, onApiUpdateSignatures: function(valid, requested){ - this.SetDisabled(valid && valid.length>0); + this.SetDisabled(valid && valid.length>0, true);// can add invisible signature + }, + + onCoAuthoringDisconnect: function() { + this.SetDisabled(true); } }, Common.Controllers.Protection || {})); diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index ee80b3982..958226c4b 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -95,7 +95,7 @@ define([ Common.NotificationCenter.on('reviewchanges:turn', this.onTurnPreview.bind(this)); Common.NotificationCenter.on('spelling:turn', this.onTurnSpelling.bind(this)); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); - Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); }, setConfig: function (data, api) { this.setApi(api); @@ -112,7 +112,7 @@ define([ this.api.asc_registerCallback('asc_onShowRevisionsChange', _.bind(this.onApiShowChange, this)); this.api.asc_registerCallback('asc_onUpdateRevisionsChangesPosition', _.bind(this.onApiUpdateChangePosition, this)); } - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.SetDisabled, this)); + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); } }, @@ -679,6 +679,10 @@ define([ this.view && this.view.onLostEditRights(); }, + onCoAuthoringDisconnect: function() { + this.SetDisabled(true); + }, + textInserted: 'Inserted:', textDeleted: 'Deleted:', textParaInserted: 'Paragraph Inserted ', diff --git a/apps/common/main/lib/view/Protection.js b/apps/common/main/lib/view/Protection.js index f7859644d..16f55fb20 100644 --- a/apps/common/main/lib/view/Protection.js +++ b/apps/common/main/lib/view/Protection.js @@ -189,7 +189,8 @@ define([ }, { caption: me.txtSignatureLine, - value: 'visible' + value: 'visible', + disabled: me._state.disabled } ] }) @@ -265,14 +266,17 @@ define([ } }, - SetDisabled: function (state) { + SetDisabled: function (state, canProtect) { this._state.disabled = state; this.btnsInvisibleSignature && this.btnsInvisibleSignature.forEach(function(button) { if ( button ) { - button.setDisabled(state); + button.setDisabled(state && !canProtect); } }, this); - this.btnSignature && this.btnSignature.setDisabled(state); + if (this.btnSignature && this.btnSignature.menu) { + this.btnSignature.menu.items && this.btnSignature.menu.items[1].setDisabled(state); // disable adding signature line + this.btnSignature.setDisabled(state && !canProtect); // disable adding any signature + } this.btnsAddPwd.concat(this.btnsDelPwd, this.btnsChangePwd).forEach(function(button) { if ( button ) { button.setDisabled(state); diff --git a/apps/documenteditor/main/app/controller/RightMenu.js b/apps/documenteditor/main/app/controller/RightMenu.js index 0019a658e..e8f72db52 100644 --- a/apps/documenteditor/main/app/controller/RightMenu.js +++ b/apps/documenteditor/main/app/controller/RightMenu.js @@ -281,9 +281,6 @@ define([ this.onFocusObject(selectedElements, !Common.localStorage.getBool("de-hide-right-settings")); } } - - //remove after sdk send event - // this.onApiUpdateSignatures([{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]); }, onDoubleClickOnObject: function(obj) { diff --git a/apps/presentationeditor/main/app/controller/RightMenu.js b/apps/presentationeditor/main/app/controller/RightMenu.js index c65425414..6b7c8e5d2 100644 --- a/apps/presentationeditor/main/app/controller/RightMenu.js +++ b/apps/presentationeditor/main/app/controller/RightMenu.js @@ -289,8 +289,6 @@ define([ this.onFocusObject(selectedElements, !Common.localStorage.getBool("pe-hide-right-settings")); } } - //remove after sdk send event - // this.onApiUpdateSignatures([{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]); }, onDoubleClickOnObject: function(obj) { diff --git a/apps/spreadsheeteditor/main/app/controller/RightMenu.js b/apps/spreadsheeteditor/main/app/controller/RightMenu.js index ca8b3efe0..e6724c6e4 100644 --- a/apps/spreadsheeteditor/main/app/controller/RightMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/RightMenu.js @@ -300,9 +300,6 @@ define([ this.rightmenu.shapeSettings.createDelayedElements(); this.onSelectionChanged(this.api.asc_getCellInfo()); } - - //remove after sdk send event - // this.onApiUpdateSignatures([{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]); }, onDoubleClickOnObject: function(obj) {