[SSE mobile] Change applying the license (disable editing when connections are over the limitations).

This commit is contained in:
Julia Radzhabova 2017-11-23 12:16:04 +03:00
parent c31fad7d91
commit 85b8c5702a
3 changed files with 55 additions and 13 deletions

View file

@ -82,6 +82,7 @@ define([
this.api.asc_registerCallback('asc_onShowPopMenu', _.bind(this.onApiShowPopMenu, this));
this.api.asc_registerCallback('asc_onHidePopMenu', _.bind(this.onApiHidePopMenu, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
},
setMode: function (mode) {
@ -180,7 +181,7 @@ define([
},
onApiShowPopMenu: function(posX, posY) {
if ( !_isEdit ) return;
if ( !_isEdit || this.isDisconnected) return;
if ($('.popover.settings, .popup.settings, .picker-modal.settings, .modal-in, .actions-modal').length > 0) {
return;
@ -334,6 +335,10 @@ define([
return menuItems;
},
onCoAuthoringDisconnect: function() {
this.isDisconnected = true;
},
warnMergeLostData: 'Operation can destroy data in the selected cells.<br>Continue?',
menuCopy: 'Copy',
menuCut: 'Cut',

View file

@ -239,6 +239,7 @@ define([
}
this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this));
this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this));
this.api.asc_setDocInfo(docInfo);
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
@ -534,10 +535,33 @@ define([
mode: me.appOptions.isEdit ? 'edit' : 'view'
});
SSE.getController('Toolbar').activateControls();
me.applyLicense();
$('.view-main').on('click', function (e) {
uiApp.closeModal('.document-menu.modal-in');
})
},
onLicenseChanged: function(params) {
if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) return;
var licType = params.asc_getLicenseType();
if (licType !== undefined && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') {
this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers;
}
if (this._isDocReady && this._state.licenseWarning)
this.applyLicense();
},
applyLicense: function() {
var me = this;
if (me._state.licenseWarning) {
value = Common.localStorage.getItem("sse-license-warning");
SSE.getController('Toolbar').activateViewControls();
SSE.getController('Toolbar').deactivateEditControls();
Common.NotificationCenter.trigger('api:disconnect');
var value = Common.localStorage.getItem("sse-license-warning");
value = (value!==null) ? parseInt(value) : 0;
var now = (new Date).getTime();
@ -545,7 +569,7 @@ define([
Common.localStorage.setItem("sse-license-warning", now);
uiApp.modal({
title: me.textNoLicenseTitle,
text : me.warnNoLicense,
text : me._state.licenseWarning,
buttons: [
{
text: me.textBuyNow,
@ -560,14 +584,11 @@ define([
window.open('mailto:sales@onlyoffice.com', "_blank");
}
}
],
]
});
}
}
$('.view-main').on('click', function (e) {
uiApp.closeModal('.document-menu.modal-in');
})
} else
SSE.getController('Toolbar').activateControls();
},
onOpenDocument: function(progress) {
@ -624,8 +645,6 @@ define([
me.appOptions.canDownload = !me.appOptions.nativeApp && (me.permissions.download !== false);
me.appOptions.canPrint = (me.permissions.print !== false);
me._state.licenseWarning = !(me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge) && (licType===Asc.c_oLicenseResult.Connections) && me.appOptions.canEdit && me.editorConfig.mode !== 'view';
me.applyModeCommonElements();
me.applyModeEditorElements();
@ -1417,7 +1436,8 @@ define([
txtStyle_Total: 'Total',
txtStyle_Currency: 'Currency',
txtStyle_Percent: 'Percent',
txtStyle_Comma: 'Comma'
txtStyle_Comma: 'Comma',
warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).<br>If you need more please consider purchasing a commercial license.'
}
})(), SSE.Controllers.Main || {}))
});

View file

@ -86,6 +86,7 @@ define([
this.api.asc_registerCallback('asc_onWorkbookLocked', _.bind(this.onApiWorkbookLocked, this));
this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onApiWorksheetLocked, this));
this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onApiActiveSheetChanged, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('sheet:active', this.onApiActiveSheetChanged.bind(this));
},
@ -159,6 +160,8 @@ define([
},
onApiCanRevert: function(which, can) {
if (this.isDisconnected) return;
if (which == 'undo') {
$('#toolbar-undo').toggleClass('disabled', !can);
} else {
@ -167,6 +170,8 @@ define([
},
onApiSelectionChanged: function(info) {
if (this.isDisconnected) return;
if ( !info ) info = this.api.asc_getCellInfo();
var islocked = false;
@ -195,6 +200,18 @@ define([
$('#toolbar-settings, #toolbar-search, #document-back').removeClass('disabled');
},
activateViewControls: function() {
$('#toolbar-search, #document-back').removeClass('disabled');
},
deactivateEditControls: function() {
$('#toolbar-edit, #toolbar-add, #toolbar-settings').addClass('disabled');
},
onCoAuthoringDisconnect: function() {
this.isDisconnected = true;
},
dlgLeaveTitleText : 'You leave the application',
dlgLeaveMsgText : 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.',
leaveButtonText : 'Leave this Page',