[Desktop] Show/hide protect settings depending on sdk settings (use isSignatureSupport, isProtectionSupport)

This commit is contained in:
Julia Radzhabova 2018-08-01 19:08:24 +03:00
parent 33f7e7cbc5
commit 2a254a88d0
16 changed files with 95 additions and 86 deletions

View file

@ -87,14 +87,13 @@ define([
if (api) {
this.api = api;
if (this.appConfig.isDesktopApp && this.appConfig.isOffline) {
if (this.appConfig.isPasswordSupport)
this.api.asc_registerCallback('asc_onDocumentPassword', _.bind(this.onDocumentPassword, this));
if (this.appConfig.canProtect) {
Common.NotificationCenter.on('protect:sign', _.bind(this.onSignatureRequest, this));
Common.NotificationCenter.on('protect:signature', _.bind(this.onSignatureClick, this));
this.api.asc_registerCallback('asc_onSignatureClick', _.bind(this.onSignatureSign, this));
this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onApiUpdateSignatures, this));
}
if (this.appConfig.isSignatureSupport) {
Common.NotificationCenter.on('protect:sign', _.bind(this.onSignatureRequest, this));
Common.NotificationCenter.on('protect:signature', _.bind(this.onSignatureClick, this));
this.api.asc_registerCallback('asc_onSignatureClick', _.bind(this.onSignatureSign, this));
this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onApiUpdateSignatures, this));
}
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
}

View file

@ -65,7 +65,7 @@ define([
function setEvents() {
var me = this;
if ( me.appConfig.isDesktopApp && me.appConfig.isOffline ) {
if (me.appConfig.isPasswordSupport) {
this.btnsAddPwd.concat(this.btnsChangePwd).forEach(function(button) {
button.on('click', function (b, e) {
me.fireEvent('protect:password', [b, 'add']);
@ -81,19 +81,19 @@ define([
this.btnPwd.menu.on('item:click', function (menu, item, e) {
me.fireEvent('protect:password', [menu, item.value]);
});
}
if (me.appConfig.canProtect) {
if (this.btnSignature.menu)
this.btnSignature.menu.on('item:click', function (menu, item, e) {
me.fireEvent('protect:signature', [item.value, false]);
});
this.btnsInvisibleSignature.forEach(function(button) {
button.on('click', function (b, e) {
me.fireEvent('protect:signature', ['invisible']);
});
if (me.appConfig.isSignatureSupport) {
if (this.btnSignature.menu)
this.btnSignature.menu.on('item:click', function (menu, item, e) {
me.fireEvent('protect:signature', [item.value, false]);
});
}
this.btnsInvisibleSignature.forEach(function(button) {
button.on('click', function (b, e) {
me.fireEvent('protect:signature', ['invisible']);
});
});
}
}
@ -116,7 +116,7 @@ define([
var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
if ( this.appConfig.isDesktopApp && this.appConfig.isOffline ) {
if ( this.appConfig.isPasswordSupport ) {
this.btnAddPwd = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-ic-protect',
@ -131,18 +131,18 @@ define([
menu: true,
visible: false
});
if (this.appConfig.canProtect) {
this.btnSignature = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-ic-signature',
caption: this.txtSignature,
menu: (this.appPrefix !== 'pe-')
});
if (!this.btnSignature.menu)
this.btnsInvisibleSignature.push(this.btnSignature);
}
}
if (this.appConfig.isSignatureSupport) {
this.btnSignature = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-ic-signature',
caption: this.txtSignature,
menu: (this.appPrefix !== 'pe-')
});
if (!this.btnSignature.menu)
this.btnsInvisibleSignature.push(this.btnSignature);
}
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
@ -159,25 +159,26 @@ define([
(new Promise(function (accept, reject) {
accept();
})).then(function(){
if ( config.isDesktopApp && config.isOffline) {
me.btnAddPwd.updateHint(me.hintAddPwd);
me.btnPwd.updateHint(me.hintPwd);
me.btnPwd.setMenu(
new Common.UI.Menu({
items: [
{
caption: me.txtChangePwd,
value: 'add'
},
{
caption: me.txtDeletePwd,
value: 'delete'
}
]
})
);
if ( config.canProtect) {
if ( config.isPasswordSupport) {
me.btnAddPwd.updateHint(me.hintAddPwd);
me.btnPwd.updateHint(me.hintPwd);
me.btnPwd.setMenu(
new Common.UI.Menu({
items: [
{
caption: me.txtChangePwd,
value: 'add'
},
{
caption: me.txtDeletePwd,
value: 'delete'
}
]
})
);
}
if (me.btnSignature) {
me.btnSignature.updateHint((me.btnSignature.menu) ? me.hintSignature : me.txtInvisibleSignature);
me.btnSignature.menu && me.btnSignature.setMenu(
@ -206,9 +207,9 @@ define([
getPanel: function () {
this.$el = $(_.template(template)( {} ));
if ( this.appConfig.isDesktopApp && this.appConfig.isOffline ) {
this.btnAddPwd.render(this.$el.find('#slot-btn-add-password'));
this.btnPwd.render(this.$el.find('#slot-btn-change-password'));
if ( this.appConfig.canProtect ) {
this.btnAddPwd && this.btnAddPwd.render(this.$el.find('#slot-btn-add-password'));
this.btnPwd && this.btnPwd.render(this.$el.find('#slot-btn-change-password'));
this.btnSignature && this.btnSignature.render(this.$el.find('#slot-btn-signature'));
}
return this.$el;

View file

@ -1096,8 +1096,9 @@ define([
this.appOptions.forcesave = this.appOptions.canForcesave;
this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly);
this.appOptions.trialMode = params.asc_getLicenseMode();
this.appOptions.isProtectSupport = true; // remove in 5.2
this.appOptions.canProtect = this.appOptions.isProtectSupport && this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport();
this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport();
this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isProtectionSupport();
this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport);
this.appOptions.canEditContentControl = (this.permissions.modifyContentControl!==false);
this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false);
this.appOptions.canFillForms = (this.permissions.fillForms===undefined) ? this.appOptions.isEdit : this.permissions.fillForms;
@ -1197,7 +1198,7 @@ define([
reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
if (this.appOptions.isDesktopApp && this.appOptions.isOffline)
if (this.appOptions.canProtect)
application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
var viewport = this.getApplication().getController('Viewport').getView('Viewport');

View file

@ -2728,7 +2728,7 @@ define([
me.toolbar.btnPaste.$el.detach().appendTo($box);
me.toolbar.btnCopy.$el.removeClass('split');
if ( config.isProtectSupport && config.isOffline ) {
if ( config.canProtect ) {
tab = {action: 'protect', caption: me.toolbar.textTabProtect};
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();

View file

@ -1946,7 +1946,7 @@ define([
this.viewModeMenu = new Common.UI.Menu({
initMenu: function (value) {
var isInChart = (value.imgProps && value.imgProps.value && !_.isNull(value.imgProps.value.get_ChartProperties())),
signGuid = (value.imgProps && value.imgProps.value && me.mode.canProtect) ? value.imgProps.value.asc_getSignatureId() : undefined,
signGuid = (value.imgProps && value.imgProps.value && me.mode.isSignatureSupport) ? value.imgProps.value.asc_getSignatureId() : undefined,
signProps = (signGuid) ? me.api.asc_getSignatureSetup(signGuid) : null,
isInSign = !!signProps && me._canProtect,
canComment = !isInChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled;
@ -2432,7 +2432,7 @@ define([
menuImgCut.setDisabled(islocked || !cancopy);
menuImgPaste.setDisabled(islocked);
var signGuid = (value.imgProps && value.imgProps.value && me.mode.canProtect) ? value.imgProps.value.asc_getSignatureId() : undefined,
var signGuid = (value.imgProps && value.imgProps.value && me.mode.isSignatureSupport) ? value.imgProps.value.asc_getSignatureId() : undefined,
isInSign = !!signGuid;
menuSignatureEditSign.setVisible(isInSign);
menuSignatureEditSetup.setVisible(isInSign);

View file

@ -244,7 +244,7 @@ define([
applyMode: function() {
this.miPrint[this.mode.canPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[(this.mode.isEdit && this.mode.isDesktopApp && this.mode.isOffline) ?'show':'hide']();
this.miProtect[this.mode.canProtect ?'show':'hide']();
this.miProtect.$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide']();
this.miRecent[this.mode.canOpenRecent?'show':'hide']();
this.miNew[this.mode.canCreateNew?'show':'hide']();
@ -284,7 +284,7 @@ define([
}
}
if (this.mode.isEdit && this.mode.isDesktopApp && this.mode.isOffline) {
if (this.mode.canProtect) {
// this.$el.find('#fm-btn-back').hide();
this.panels['protect'] = (new DE.Views.FileMenuPanels.ProtectDoc({menu:this})).render();
this.panels['protect'].setMode(this.mode);

View file

@ -1179,7 +1179,8 @@ define([
this.btnDeletePwd.render(this.$el.find('#fms-btn-delete-pwd'));
this.btnDeletePwd.on('click', _.bind(this.closeMenu, this));
this.cntPassword = $('#id-fms-view-pwd');
this.cntPassword = $('#id-fms-password');
this.cntPasswordView = $('#id-fms-view-pwd');
this.btnAddInvisibleSign = protection.getButton('signature');
this.btnAddInvisibleSign.render(this.$el.find('#fms-btn-invisible-sign'));
@ -1208,7 +1209,8 @@ define([
setMode: function(mode) {
this.mode = mode;
this.cntSignature.toggleClass('hidden', !this.mode.canProtect);
this.cntSignature.toggleClass('hidden', !this.mode.isSignatureSupport);
this.cntPassword.toggleClass('hidden', !this.mode.isPasswordSupport);
},
setApi: function(o) {
@ -1269,7 +1271,7 @@ define([
},
updateEncrypt: function() {
this.cntPassword.toggleClass('hidden', this.btnAddPwd.isVisible());
this.cntPasswordView.toggleClass('hidden', this.btnAddPwd.isVisible());
},
strProtect: 'Protect Document',

View file

@ -195,7 +195,7 @@ define([
this.mergeSettings = new DE.Views.MailMergeSettings();
}
if (mode && mode.canProtect) {
if (mode && mode.isSignatureSupport) {
this.btnSignature = new Common.UI.Button({
hint: this.txtSignatureSettings,
asctype: Common.Utils.documentSettingsType.Signature,

View file

@ -860,8 +860,9 @@ define([
this.appOptions.forcesave = this.appOptions.canForcesave;
this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly);
this.appOptions.trialMode = params.asc_getLicenseMode();
this.appOptions.isProtectSupport = true; // remove in 5.2
this.appOptions.canProtect = this.appOptions.isProtectSupport && this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport();
this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport();
this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isProtectionSupport();
this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport);
this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false);
this.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof this.editorConfig.customization == 'object');
@ -940,7 +941,7 @@ define([
reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
if (me.appOptions.isDesktopApp && me.appOptions.isOffline)
if (me.appOptions.canProtect)
application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
var viewport = this.getApplication().getController('Viewport').getView('Viewport');

View file

@ -2018,7 +2018,7 @@ define([
me.toolbar.btnPaste.$el.detach().appendTo($box);
me.toolbar.btnCopy.$el.removeClass('split');
if ( config.isProtectSupport && config.isOffline ) { // don't add protect panel to toolbar
if ( config.canProtect ) { // don't add protect panel to toolbar
tab = {action: 'protect', caption: me.toolbar.textTabProtect};
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
if ($panel)

View file

@ -240,7 +240,7 @@ define([
applyMode: function() {
this.miPrint[this.mode.canPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[(this.mode.isEdit && this.mode.isDesktopApp && this.mode.isOffline) ?'show':'hide']();
this.miProtect[this.mode.canProtect ?'show':'hide']();
this.miProtect.$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide']();
this.miRecent[this.mode.canOpenRecent?'show':'hide']();
this.miNew[this.mode.canCreateNew?'show':'hide']();
@ -280,12 +280,12 @@ define([
}
}
if (this.mode.isDesktopApp && this.mode.isOffline) {
if (this.mode.isDesktopApp && this.mode.isOffline)
this.$el.find('#fm-btn-create, #fm-btn-back, #fm-btn-create+.devider').hide();
if (this.mode.isEdit) {
this.panels['protect'] = (new PE.Views.FileMenuPanels.ProtectDoc({menu:this})).render();
this.panels['protect'].setMode(this.mode);
}
if (this.mode.canProtect) {
this.panels['protect'] = (new PE.Views.FileMenuPanels.ProtectDoc({menu:this})).render();
this.panels['protect'].setMode(this.mode);
}
if (this.mode.canHelp) {

View file

@ -938,7 +938,8 @@ define([
this.btnDeletePwd.render(this.$el.find('#fms-btn-delete-pwd'));
this.btnDeletePwd.on('click', _.bind(this.closeMenu, this));
this.cntPassword = $('#id-fms-view-pwd');
this.cntPassword = $('#id-fms-password');
this.cntPasswordView = $('#id-fms-view-pwd');
this.btnAddInvisibleSign = protection.getButton('signature');
this.btnAddInvisibleSign.render(this.$el.find('#fms-btn-invisible-sign'));
@ -967,7 +968,8 @@ define([
setMode: function(mode) {
this.mode = mode;
this.cntSignature.toggleClass('hidden', !this.mode.canProtect);
this.cntSignature.toggleClass('hidden', !this.mode.isSignatureSupport);
this.cntPassword.toggleClass('hidden', !this.mode.isPasswordSupport);
},
setApi: function(o) {
@ -1022,7 +1024,7 @@ define([
},
updateEncrypt: function() {
this.cntPassword.toggleClass('hidden', this.btnAddPwd.isVisible());
this.cntPasswordView.toggleClass('hidden', this.btnAddPwd.isVisible());
},
strProtect: 'Protect Presentation',

View file

@ -899,8 +899,9 @@ define([
(typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave);
this.appOptions.forcesave = this.appOptions.canForcesave;
this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly);
this.appOptions.isProtectSupport = true; // remove in 5.2
this.appOptions.canProtect = this.appOptions.isProtectSupport && this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport() && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge);
this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport() && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge);
this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isProtectionSupport() && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge);
this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport);
this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false);
if (!this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge) {
@ -1004,7 +1005,7 @@ define([
reviewController.setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
if (me.appOptions.isDesktopApp && me.appOptions.isOffline)
if (me.appOptions.canProtect)
application.getController('Common.Controllers.Protection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
if (statusbarController) {

View file

@ -3107,7 +3107,7 @@ define([
me.toolbar.btnPaste.$el.detach().appendTo($box);
me.toolbar.btnCopy.$el.removeClass('split');
if ( config.isProtectSupport && config.isOffline ) {
if ( config.canProtect ) {
tab = {action: 'protect', caption: me.toolbar.textTabProtect};
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
if ($panel)

View file

@ -229,7 +229,7 @@ define([
applyMode: function() {
this.miPrint[this.mode.canPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[(this.mode.isEdit && this.mode.isDesktopApp && this.mode.isOffline) ?'show':'hide']();
this.miProtect[this.mode.canProtect ?'show':'hide']();
this.miProtect.$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide']();
this.miRecent[this.mode.canOpenRecent?'show':'hide']();
this.miNew[this.mode.canCreateNew?'show':'hide']();
@ -271,7 +271,7 @@ define([
}
}
if (this.mode.isEdit && this.mode.isDesktopApp && this.mode.isOffline) {
if (this.mode.canProtect) {
this.panels['protect'] = (new SSE.Views.FileMenuPanels.ProtectDoc({menu:this})).render();
this.panels['protect'].setMode(this.mode);
}

View file

@ -1399,7 +1399,8 @@ define([
this.btnDeletePwd.render(this.$el.find('#fms-btn-delete-pwd'));
this.btnDeletePwd.on('click', _.bind(this.closeMenu, this));
this.cntPassword = $('#id-fms-view-pwd');
this.cntPassword = $('#id-fms-password');
this.cntPasswordView = $('#id-fms-view-pwd');
this.btnAddInvisibleSign = protection.getButton('signature');
this.btnAddInvisibleSign.render(this.$el.find('#fms-btn-invisible-sign'));
@ -1428,7 +1429,8 @@ define([
setMode: function(mode) {
this.mode = mode;
this.cntSignature.toggleClass('hidden', !this.mode.canProtect);
this.cntSignature.toggleClass('hidden', !this.mode.isSignatureSupport);
this.cntPassword.toggleClass('hidden', !this.mode.isPasswordSupport);
},
setApi: function(o) {
@ -1489,7 +1491,7 @@ define([
},
updateEncrypt: function() {
this.cntPassword.toggleClass('hidden', this.btnAddPwd.isVisible());
this.cntPasswordView.toggleClass('hidden', this.btnAddPwd.isVisible());
},
strProtect: 'Protect Workbook',