[PE] Show tooltip and disable editing when document is signed.
This commit is contained in:
parent
4a5d78f36e
commit
580903591a
|
@ -175,6 +175,7 @@ require([
|
|||
'presentationeditor/main/app/view/SlideSettings',
|
||||
'presentationeditor/main/app/view/TableSettings',
|
||||
'presentationeditor/main/app/view/TextArtSettings',
|
||||
'presentationeditor/main/app/view/SignatureSettings',
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/util/LocalStorage',
|
||||
'common/main/lib/controller/Fonts'
|
||||
|
|
|
@ -693,13 +693,11 @@ define([
|
|||
toolbarController.onApiCoAuthoringDisconnect();
|
||||
me.api.UpdateInterfaceState();
|
||||
|
||||
if (me.appOptions.canBrandingExt)
|
||||
Common.NotificationCenter.trigger('document:ready', 'main');
|
||||
}
|
||||
}, 50);
|
||||
} else {
|
||||
documentHolderController.getView('DocumentHolder').createDelayedElementsViewer();
|
||||
if (me.appOptions.canBrandingExt)
|
||||
Common.NotificationCenter.trigger('document:ready', 'main');
|
||||
}
|
||||
|
||||
|
|
|
@ -211,6 +211,11 @@ define([
|
|||
this.setMode({isEdit: false});
|
||||
},
|
||||
|
||||
SetDisabled: function(disabled, allowSignature) {
|
||||
this.setMode({isEdit: !disabled});
|
||||
this.rightmenu.SetDisabled('', disabled, true, allowSignature);
|
||||
},
|
||||
|
||||
onInsertTable: function() {
|
||||
this._settings[Common.Utils.documentSettingsType.Table].needShow = true;
|
||||
},
|
||||
|
|
|
@ -2041,7 +2041,10 @@ define([
|
|||
this._state.activated = true;
|
||||
},
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ define([
|
|||
me._currentSpellObj = undefined;
|
||||
me._currLang = {};
|
||||
me._state = {};
|
||||
me._isDisabled = false;
|
||||
|
||||
/** coauthoring begin **/
|
||||
var usersStore = PE.getCollection('Common.Collections.Users');
|
||||
|
@ -187,6 +188,9 @@ define([
|
|||
var fillViewMenuProps = function(selectedElements) {
|
||||
if (!selectedElements || !_.isArray(selectedElements)) return;
|
||||
|
||||
if (!me.viewModeMenu)
|
||||
me.createDelayedElementsViewer();
|
||||
|
||||
var menu_props = {},
|
||||
menu_to_show = null;
|
||||
_.each(selectedElements, function(element, index) {
|
||||
|
@ -210,7 +214,7 @@ define([
|
|||
|
||||
var showObjectMenu = function(event, docElement, eOpts){
|
||||
if (me.api){
|
||||
var obj = (me.mode.isEdit) ? fillMenuProps(me.api.getSelectedElements()) : fillViewMenuProps(me.api.getSelectedElements());
|
||||
var obj = (me.mode.isEdit && !me._isDisabled) ? fillMenuProps(me.api.getSelectedElements()) : fillViewMenuProps(me.api.getSelectedElements());
|
||||
if (obj) showPopupMenu(obj.menu_to_show, obj.menu_props, event, docElement, eOpts);
|
||||
}
|
||||
};
|
||||
|
@ -218,7 +222,7 @@ define([
|
|||
var onContextMenu = function(event){
|
||||
_.delay(function(){
|
||||
if (event.get_Type() == Asc.c_oAscContextMenuTypes.Thumbnails) {
|
||||
showPopupMenu.call(me, me.slideMenu, {isSlideSelect: event.get_IsSlideSelect(), isSlideHidden: event.get_IsSlideHidden(), fromThumbs: true}, event);
|
||||
!me._isDisabled && showPopupMenu.call(me, me.slideMenu, {isSlideSelect: event.get_IsSlideSelect(), isSlideHidden: event.get_IsSlideHidden(), fromThumbs: true}, event);
|
||||
} else {
|
||||
showObjectMenu.call(me, event);
|
||||
}
|
||||
|
@ -228,7 +232,7 @@ define([
|
|||
var onFocusObject = function(selectedElements) {
|
||||
if (me.currentMenu && me.currentMenu.isVisible()){
|
||||
if (me.api.asc_getCurrentFocusObject() === 0 ){ // thumbnails
|
||||
if (me.slideMenu===me.currentMenu) {
|
||||
if (me.slideMenu===me.currentMenu && !me._isDisabled) {
|
||||
var isHidden = false;
|
||||
_.each(selectedElements, function(element, index) {
|
||||
if (Asc.c_oAscTypeSelectElement.Slide == element.get_ObjectType()) {
|
||||
|
@ -240,7 +244,7 @@ define([
|
|||
me.currentMenu.alignPosition();
|
||||
}
|
||||
} else {
|
||||
var obj = (me.mode.isEdit) ? fillMenuProps(selectedElements) : fillViewMenuProps(selectedElements);
|
||||
var obj = (me.mode.isEdit && !me._isDisabled) ? fillMenuProps(selectedElements) : fillViewMenuProps(selectedElements);
|
||||
if (obj) {
|
||||
if (obj.menu_to_show===me.currentMenu) {
|
||||
me.currentMenu.options.initMenu(obj.menu_props);
|
||||
|
@ -575,7 +579,7 @@ define([
|
|||
|
||||
var onDialogAddHyperlink = function() {
|
||||
var win, props, text;
|
||||
if (me.api && me.mode.isEdit){
|
||||
if (me.api && me.mode.isEdit && !me._isDisabled){
|
||||
var handlerDlg = function(dlg, result) {
|
||||
if (result == 'ok') {
|
||||
props = dlg.getSettings();
|
||||
|
@ -668,7 +672,7 @@ define([
|
|||
};
|
||||
|
||||
var onDoubleClickOnChart = function(chart) {
|
||||
if (me.mode.isEdit) {
|
||||
if (me.mode.isEdit && !me._isDisabled) {
|
||||
var diagramEditor = PE.getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor');
|
||||
|
||||
if (diagramEditor && chart) {
|
||||
|
@ -1739,10 +1743,10 @@ define([
|
|||
|
||||
this.viewModeMenu = new Common.UI.Menu({
|
||||
initMenu: function (value) {
|
||||
menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments);
|
||||
menuViewUndo.setDisabled(!me.api.asc_getCanUndo());
|
||||
menuViewCopySeparator.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments);
|
||||
menuViewAddComment.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments);
|
||||
menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled);
|
||||
menuViewUndo.setDisabled(!me.api.asc_getCanUndo() && !me._isDisabled);
|
||||
menuViewCopySeparator.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled);
|
||||
menuViewAddComment.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled);
|
||||
menuViewAddComment.setDisabled(value.locked);
|
||||
},
|
||||
items: [
|
||||
|
@ -3159,6 +3163,10 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
SetDisabled: function(state) {
|
||||
this._isDisabled = state;
|
||||
},
|
||||
|
||||
insertRowAboveText : 'Row Above',
|
||||
insertRowBelowText : 'Row Below',
|
||||
insertColumnLeftText : 'Column Left',
|
||||
|
|
|
@ -950,10 +950,14 @@ define([
|
|||
var sign = {name: item.asc_getSigner1(), date: '18/05/2017'};
|
||||
(item.asc_getValid()==0) ? valid_arr.push(sign) : invalid_arr.push(sign);
|
||||
});
|
||||
|
||||
// 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.cntValidSign.html(this.templateValid({signatures: valid_arr, header: this.strValid}));
|
||||
this.cntInvalidSign.html(this.templateValid({signatures: invalid_arr, header: this.strInvalid}));
|
||||
// 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);
|
||||
},
|
||||
|
||||
strProtect: 'Protect Document',
|
||||
|
|
|
@ -280,7 +280,7 @@ define([
|
|||
return (this.minimizedMode) ? null : this.$el.find(".settings-panel.active")[0].id;
|
||||
},
|
||||
|
||||
SetDisabled: function(id, disabled, all) {
|
||||
SetDisabled: function(id, disabled, all, allowSignature) {
|
||||
if (all) {
|
||||
this.slideSettings.SetSlideDisabled(disabled, disabled, disabled);
|
||||
this.paragraphSettings.disableControls(disabled);
|
||||
|
@ -288,6 +288,12 @@ define([
|
|||
this.tableSettings.disableControls(disabled);
|
||||
this.imageSettings.disableControls(disabled);
|
||||
this.chartSettings.disableControls(disabled);
|
||||
|
||||
if (!allowSignature && this.signatureSettings) {
|
||||
this.signatureSettings.disableControls(disabled);
|
||||
this.btnSignature.setDisabled(disabled);
|
||||
}
|
||||
|
||||
} else {
|
||||
var cmp = $("#" + id);
|
||||
if (disabled !== cmp.hasClass('disabled')) {
|
||||
|
|
|
@ -65,10 +65,9 @@ define([
|
|||
initialize: function () {
|
||||
var me = this;
|
||||
|
||||
this._initSettings = true;
|
||||
|
||||
this._state = {
|
||||
DisabledControls: false,
|
||||
DisabledInsertControls: false,
|
||||
validSignatures: undefined,
|
||||
invalidSignatures: undefined
|
||||
};
|
||||
|
@ -118,17 +117,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.validSignatures || !this._state.invalidSignatures) {
|
||||
this.onUpdateSignatures(this.api.asc_getSignatures());
|
||||
}
|
||||
|
@ -141,15 +134,19 @@ define([
|
|||
},
|
||||
|
||||
disableControls: function(disable) {
|
||||
if (this._initSettings) return;
|
||||
|
||||
if (this._state.DisabledControls!==disable) {
|
||||
this._state.DisabledControls = 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);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -166,10 +163,12 @@ 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.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.cntValidSign.html(this.templateValid({signatures: me._state.validSignatures, header: this.strValid}));
|
||||
this.cntInvalidSign.html(this.templateValid({signatures: me._state.invalidSignatures, header: this.strInvalid}));
|
||||
// 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.$linksView = $('.signature-view-link', this.$el);
|
||||
var width = this.$linksView.width();
|
||||
|
@ -201,11 +200,60 @@ 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);
|
||||
|
||||
hasSigned && this.disableEditing(hasSigned);
|
||||
|
||||
if (!this._state.tip && hasSigned) {
|
||||
this._state.tip = new Common.UI.SynchronizeTip({
|
||||
target : PE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl,
|
||||
text : this.txtSignedDocument,
|
||||
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 && PE.getController('RightMenu').getView('RightMenu').clearSelection();
|
||||
PE.getController('RightMenu').SetDisabled(disable, true);
|
||||
PE.getController('Toolbar').DisableToolbar(disable, disable);
|
||||
PE.getController('Statusbar').getView('Statusbar').SetDisabled(disable);
|
||||
PE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
|
||||
PE.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable);
|
||||
|
||||
var leftMenu = PE.getController('LeftMenu').leftMenu;
|
||||
leftMenu.btnComments.setDisabled(disable);
|
||||
var comments = PE.getController('Common.Controllers.Comments');
|
||||
if (comments)
|
||||
comments.setPreviewMode(disable);
|
||||
|
||||
this.disableInsertControls(disable);
|
||||
},
|
||||
|
||||
strSignature: 'Signature',
|
||||
strInvisibleSign: 'Add invisible digital signature',
|
||||
strValid: 'Valid signatures',
|
||||
strInvalid: 'Invalid signatures',
|
||||
strView: 'View'
|
||||
strView: 'View',
|
||||
txtSignedDocument: 'This document has been signed. It should not be edited.',
|
||||
txtContinueEditing: 'Edit anyway'
|
||||
|
||||
}, PE.Views.SignatureSettings || {}));
|
||||
});
|
|
@ -369,6 +369,7 @@ define([
|
|||
var langs = this.langMenu.items.length>0;
|
||||
this.btnLanguage.setDisabled(disable || !langs || this._state.no_paragraph);
|
||||
this.btnDocLanguage.setDisabled(disable || !langs);
|
||||
this.mode.isEdit = !disable;
|
||||
},
|
||||
|
||||
onApiFocusObject: function(selectedObjects) {
|
||||
|
|
|
@ -166,6 +166,7 @@ require([
|
|||
'presentationeditor/main/app/view/SlideSettings',
|
||||
'presentationeditor/main/app/view/TableSettings',
|
||||
'presentationeditor/main/app/view/TextArtSettings',
|
||||
'presentationeditor/main/app/view/SignatureSettings',
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/util/LocalStorage',
|
||||
'common/main/lib/controller/Fonts'
|
||||
|
|
Loading…
Reference in a new issue