[SSE] Show tooltip and disable editing when document is signed.

This commit is contained in:
Julia Radzhabova 2017-11-28 14:25:08 +03:00
parent c2561b8d18
commit 4a5d78f36e
9 changed files with 108 additions and 35 deletions

View file

@ -180,6 +180,7 @@ require([
'spreadsheeteditor/main/app/view/ChartSettings',
'spreadsheeteditor/main/app/view/ShapeSettings',
'spreadsheeteditor/main/app/view/TextArtSettings',
'spreadsheeteditor/main/app/view/SignatureSettings',
'common/main/lib/util/utils',
'common/main/lib/util/LocalStorage',
'common/main/lib/controller/Fonts',

View file

@ -82,6 +82,7 @@ define([
me.namedrange_locked = false;
me._currentMathObj = undefined;
me._currentParaObjDisabled = false;
me._isDisabled = false;
/** coauthoring begin **/
this.wrapEvents = {
@ -1224,14 +1225,14 @@ define([
showObjectMenu: function(event){
if (this.api && !this.mouse.isLeftButtonDown && !this.rangeSelectionMode){
(this.permissions.isEdit) ? this.fillMenuProps(this.api.asc_getCellInfo(), true, event) : this.fillViewMenuProps(this.api.asc_getCellInfo(), true, event);
(this.permissions.isEdit && !this._isDisabled) ? this.fillMenuProps(this.api.asc_getCellInfo(), true, event) : this.fillViewMenuProps(this.api.asc_getCellInfo(), true, event);
}
},
onSelectionChanged: function(info){
if (!this.mouse.isLeftButtonDown && !this.rangeSelectionMode &&
this.currentMenu && this.currentMenu.isVisible()){
(this.permissions.isEdit) ? this.fillMenuProps(info, true) : this.fillViewMenuProps(info, true);
(this.permissions.isEdit && !this._isDisabled) ? this.fillMenuProps(info, true) : this.fillViewMenuProps(info, true);
}
},
@ -1494,12 +1495,15 @@ define([
iscellmenu = (seltype==Asc.c_oAscSelectionType.RangeCells) && !this.permissions.isEditMailMerge && !this.permissions.isEditDiagram,
iscelledit = this.api.isCellEdited;
if (!documentHolder.viewModeMenu)
documentHolder.createDelayedElementsViewer();
if (!showMenu && !documentHolder.viewModeMenu.isVisible()) return;
documentHolder.menuViewUndo.setVisible(this.permissions.canCoAuthoring && this.permissions.canComments);
documentHolder.menuViewUndo.setDisabled(!this.api.asc_getCanUndo());
documentHolder.menuViewCopySeparator.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
documentHolder.menuViewAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
documentHolder.menuViewUndo.setVisible(this.permissions.canCoAuthoring && this.permissions.canComments && !this._isDisabled);
documentHolder.menuViewUndo.setDisabled(!this.api.asc_getCanUndo() && !this._isDisabled);
documentHolder.menuViewCopySeparator.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && !this._isDisabled);
documentHolder.menuViewAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments && !this._isDisabled);
documentHolder.setMenuItemCommentCaptionMode(documentHolder.menuViewAddComment, cellinfo.asc_getComments().length < 1, this.permissions.canEditComments);
commentsController && commentsController.blockPopover(true);
documentHolder.menuViewAddComment.setDisabled(isCellLocked || isTableLocked);
@ -2467,6 +2471,10 @@ define([
win.show();
},
SetDisabled: function(state) {
this._isDisabled = state;
},
guestText : 'Guest',
textCtrlClick : 'Press CTRL and click link',
txtHeight : 'Height',

View file

@ -705,14 +705,12 @@ define([
if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
Common.NotificationCenter.trigger('document:ready', 'main');
}
}, 50);
} else {
documentHolderView.createDelayedElementsViewer();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
Common.NotificationCenter.trigger('document:ready', 'main');
}
if (me.appOptions.canAnalytics && false)

View file

@ -122,7 +122,8 @@ define([
SelectedObjects = this.api.asc_getGraphicObjectProps();
}
if (SelectedObjects.length<=0 && !formatTableInfo && !sparkLineInfo && !this.rightmenu.minimizedMode) {
if (SelectedObjects.length<=0 && !formatTableInfo && !sparkLineInfo && !this.rightmenu.minimizedMode &&
this.rightmenu.GetActivePane() !== 'id-signature-settings') {
this.rightmenu.clearSelection();
this._openRightMenu = true;
}
@ -323,7 +324,8 @@ define([
}
},
SetDisabled: function(disabled) {
SetDisabled: function(disabled, allowSignature) {
this.setMode({isEdit: !disabled});
if (this.rightmenu) {
this.rightmenu.paragraphSettings.disableControls(disabled);
this.rightmenu.shapeSettings.disableControls(disabled);
@ -331,7 +333,7 @@ define([
this.rightmenu.chartSettings.disableControls(disabled);
this.rightmenu.tableSettings.disableControls(disabled);
if (this.rightmenu.signatureSettings) {
if (!allowSignature && this.rightmenu.signatureSettings) {
this.rightmenu.signatureSettings.disableControls(disabled);
this.rightmenu.btnSignature.setDisabled(disabled);
}

View file

@ -138,7 +138,11 @@ define([
},
onApiDisconnect: function() {
this.statusbar.setMode({isDisconnected: true});
this.SetDisabled(true);
},
SetDisabled: function(state) {
this.statusbar.setMode({isDisconnected: state});
this.statusbar.update();
},

View file

@ -2868,7 +2868,10 @@ define([
this._state.namedrange_locked = (state == Asc.c_oAscDefinedNameReason.LockDefNameManager);
},
DisableToolbar: function(disable) {
DisableToolbar: function(disable, viewMode) {
if (viewMode!==undefined) this.editMode = !viewMode;
disable = disable || !this.editMode;
var mask = $('.toolbar-mask');
if (disable && mask.length>0 || !disable && mask.length==0) return;

View file

@ -1447,12 +1447,17 @@ define([
var sign = {name: item.asc_getSigner1(), date: '18/05/2017'};
(item.asc_getValid()==0) ? valid_arr.push(sign) : invalid_arr.push(sign);
});
// requested_arr = ['Hammish Mitchell', 'Someone Somewhere', 'Mary White', 'John Black'];
// valid_arr = [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}];
// invalid_arr = [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}];
this.cntRequestedSign.html(this.templateRequested({signatures: requested_arr, header: this.strRequested}));
this.cntValidSign.html(this.templateValid({signatures: valid_arr, header: this.strValid}));
this.cntInvalidSign.html(this.templateValid({signatures: invalid_arr, header: this.strInvalid}));
// this.cntRequestedSign.html(this.templateRequested({signatures: ['Hammish Mitchell', 'Someone Somewhere', 'Mary White', 'John Black'], header: this.strRequested}));
// this.cntValidSign.html(this.templateValid({signatures: [{name: 'Hammish Mitchell', date: '18/05/2017'}, {name: 'Someone Somewhere', date: '18/05/2017'}], header: this.strValid}));
// this.cntInvalidSign.html(this.templateValid({signatures: [{name: 'Mary White', date: '18/05/2017'}, {name: 'John Black', date: '18/05/2017'}], header: this.strInvalid}));
this.btnAddInvisibleSign.setDisabled(valid_arr.length>0 || invalid_arr.length>0);
this.btnAddVisibleSign.setDisabled(valid_arr.length>0 || invalid_arr.length>0);
},
strProtect: 'Protect Document',

View file

@ -66,10 +66,9 @@ define([
initialize: function () {
var me = this;
this._initSettings = true;
this._state = {
DisabledControls: false,
DisabledInsertControls: false,
requestedSignatures: undefined,
validSignatures: undefined,
invalidSignatures: undefined
@ -142,17 +141,11 @@ define([
if (this.api) {
this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onUpdateSignatures, this));
}
Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this));
return this;
},
createDelayedControls: function() {
this._initSettings = false;
},
ChangeSettings: function(props) {
if (this._initSettings)
this.createDelayedControls();
if (!this._state.requestedSignatures || !this._state.validSignatures || !this._state.invalidSignatures) {
this.onUpdateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
}
@ -165,15 +158,20 @@ define([
},
disableControls: function(disable) {
if (this._initSettings) return;
if (this._state.DisabledControls!==disable) {
this._state.DisabledControls = disable;
this.$linksSign && this.$linksSign.toggleClass('disabled', disable);
this.$linksView && this.$linksView.toggleClass('disabled', disable);
}
this.disableInsertControls(disable);
},
disableInsertControls: function(disable) {
if (this._state.DisabledInsertControls!==disable) {
this._state.DisabledInsertControls = disable;
_.each(this.lockedControls, function(item) {
item.setDisabled(disable);
});
this.$linksSign.toggleClass('disabled', disable);
this.$linksView.toggleClass('disabled', disable);
}
},
@ -194,12 +192,14 @@ define([
var sign = {name: item.asc_getSigner1(), guid: item.asc_getId(), date: '18/05/2017'};
(item.asc_getValid()==0) ? me._state.validSignatures.push(sign) : me._state.invalidSignatures.push(sign);
});
// me._state.requestedSignatures = [{name: 'Hammish Mitchell', guid: '123'}, {name: 'Someone Somewhere', guid: '123'}, {name: 'Mary White', guid: '123'}, {name: 'John Black', guid: '123'}];
// me._state.validSignatures = [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}];
// me._state.invalidSignatures = [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}];
this.cntRequestedSign.html(this.templateRequested({signatures: me._state.requestedSignatures, header: this.strRequested}));
this.cntValidSign.html(this.templateValid({signatures: me._state.validSignatures, header: this.strValid}));
this.cntInvalidSign.html(this.templateValid({signatures: me._state.invalidSignatures, header: this.strInvalid}));
// this.cntRequestedSign.html(this.templateRequested({signatures: [{name: 'Hammish Mitchell', guid: '123'}, {name: 'Someone Somewhere', guid: '123'}, {name: 'Mary White', guid: '123'}, {name: 'John Black', guid: '123'}], header: this.strRequested}));
// this.cntValidSign.html(this.templateValid({signatures: [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}], header: this.strValid}));
// this.cntInvalidSign.html(this.templateValid({signatures: [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}], header: this.strInvalid}));
this.$linksSign = $('.signature-sign-link', this.$el);
var width = this.$linksSign.width();
@ -282,6 +282,54 @@ define([
this.api.asc_ViewCertificate(target.attr('data-value'));
},
onDocumentReady: function() {
this.ChangeSettings();
var me = this,
hasSigned = (me._state.validSignatures.length>0 || me._state.invalidSignatures.length>0),
hasRequested = (me._state.requestedSignatures.length>0);
hasSigned && this.disableEditing(hasSigned);
if (!this._state.tip && (hasSigned || hasRequested)) {
this._state.tip = new Common.UI.SynchronizeTip({
target : SSE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl,
text : (hasSigned) ? this.txtSignedDocument : this.txtRequestedSignatures,
showLink: hasSigned,
textLink: this.txtContinueEditing,
placement: 'left'
});
this._state.tip.on({
'dontshowclick': function() {
me._state.tip.hide();
// me.api.editSingedDoc();
me.disableEditing(false);
},
'closeclick': function() {
me._state.tip.hide();
}
});
this._state.tip.show();
}
},
disableEditing: function(disable) {
disable && SSE.getController('RightMenu').getView('RightMenu').clearSelection();
SSE.getController('Toolbar').DisableToolbar(disable, disable);
SSE.getController('RightMenu').SetDisabled(disable, true);
SSE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
SSE.getController('DocumentHolder').SetDisabled(disable);
SSE.getController('Statusbar').SetDisabled(disable);
var leftMenu = SSE.getController('LeftMenu').leftMenu;
leftMenu.btnComments.setDisabled(disable);
var comments = SSE.getController('Common.Controllers.Comments');
if (comments)
comments.setPreviewMode(disable);
this.disableInsertControls(disable);
},
strSignature: 'Signature',
strInvisibleSign: 'Add invisible digital signature',
strVisibleSign: 'Add visible signature',
@ -289,7 +337,10 @@ define([
strValid: 'Valid signatures',
strInvalid: 'Invalid signatures',
strSign: 'Sign',
strView: 'View'
strView: 'View',
txtSignedDocument: 'This document has been signed. It should not be edited.',
txtRequestedSignatures: 'This document has requested signatures.',
txtContinueEditing: 'Edit anyway'
}, SSE.Views.SignatureSettings || {}));
});

View file

@ -170,6 +170,7 @@ require([
'spreadsheeteditor/main/app/view/ChartSettings',
'spreadsheeteditor/main/app/view/ShapeSettings',
'spreadsheeteditor/main/app/view/TextArtSettings',
'spreadsheeteditor/main/app/view/SignatureSettings',
'common/main/lib/util/utils',
'common/main/lib/util/LocalStorage',
'common/main/lib/controller/Fonts',