[DE forms] Fix check license

This commit is contained in:
Julia Radzhabova 2021-09-02 01:56:21 +03:00
parent ffd5f7dd39
commit 26b6d2ad18
2 changed files with 81 additions and 9 deletions

View file

@ -134,6 +134,12 @@ define([
});
window.onbeforeunload = _.bind(this.onBeforeUnload, this);
this.warnNoLicense = this.warnNoLicense.replace(/%1/g, '{{COMPANY_NAME}}');
this.warnNoLicenseUsers = this.warnNoLicenseUsers.replace(/%1/g, '{{COMPANY_NAME}}');
this.textNoLicenseTitle = this.textNoLicenseTitle.replace(/%1/g, '{{COMPANY_NAME}}');
this.warnLicenseExceeded = this.warnLicenseExceeded.replace(/%1/g, '{{COMPANY_NAME}}');
this.warnLicenseUsersExceeded = this.warnLicenseUsersExceeded.replace(/%1/g, '{{COMPANY_NAME}}');
},
onDocumentResize: function() {
@ -385,7 +391,6 @@ define([
}
this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this));
// this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this));
this.api.asc_registerCallback('asc_onRunAutostartMacroses', _.bind(this.onRunAutostartMacroses, this));
this.api.asc_setDocInfo(docInfo);
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
@ -440,6 +445,8 @@ define([
if (params.asc_getRights() !== Asc.c_oRights.Edit)
this.permissions.edit = this.permissions.review = false;
this.appOptions.trialMode = params.asc_getLicenseMode();
this.appOptions.isBeta = params.asc_getIsBeta();
this.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit);
this.appOptions.canSubmitForms = this.appOptions.canLicense && (typeof (this.editorConfig.customization) == 'object') && !!this.editorConfig.customization.submitForm;
this.appOptions.canFillForms = this.appOptions.canLicense && (this.permissions.fillForms===true) && (this.editorConfig.mode !== 'view');
@ -531,6 +538,44 @@ define([
});
},
applyLicense: function() {
if (this._state.licenseType) {
var license = this._state.licenseType,
buttons = ['ok'],
primary = 'ok';
if ((this.appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0 &&
(license===Asc.c_oLicenseResult.SuccessLimit || license===Asc.c_oLicenseResult.ExpiredLimited || this.appOptions.permissionsLicense===Asc.c_oLicenseResult.SuccessLimit)) {
license = (license===Asc.c_oLicenseResult.ExpiredLimited) ? this.warnLicenseLimitedNoAccess : this.warnLicenseLimitedRenewed;
} else if (license===Asc.c_oLicenseResult.Connections || license===Asc.c_oLicenseResult.UsersCount) {
license = (license===Asc.c_oLicenseResult.Connections) ? this.warnLicenseExceeded : this.warnLicenseUsersExceeded;
} else {
license = (license===Asc.c_oLicenseResult.ConnectionsOS) ? this.warnNoLicense : this.warnNoLicenseUsers;
buttons = [{value: 'buynow', caption: this.textBuyNow}, {value: 'contact', caption: this.textContactUs}];
primary = 'buynow';
}
var value = Common.localStorage.getItem("de-license-warning");
value = (value!==null) ? parseInt(value) : 0;
var now = (new Date).getTime();
if (now - value > 86400000) {
Common.UI.info({
maxwidth: 500,
title: this.textNoLicenseTitle,
msg : license,
buttons: buttons,
primary: primary,
callback: function(btn) {
Common.localStorage.setItem("de-license-warning", now);
if (btn == 'buynow')
window.open('{{PUBLISHER_URL}}', "_blank");
else if (btn == 'contact')
window.open('mailto:{{SALES_EMAIL}}', "_blank");
}
});
}
}
},
onLongActionBegin: function(type, id) {
var action = {id: id, type: type};
this.stackLongActions.push(action);
@ -952,9 +997,12 @@ define([
if (this.appOptions.canFillForms) {
this.api.asc_registerCallback('asc_onShowContentControlsActions', _.bind(this.onShowContentControlsActions, this));
this.api.asc_registerCallback('asc_onHideContentControlsActions', _.bind(this.onHideContentControlsActions, this));
// this.api.asc_SetHighlightRequiredFields(true);
this.api.asc_SetHighlightRequiredFields(true);
}
if (this.editorConfig.mode !== 'view') // if want to open editor, but viewer is loaded
this.applyLicense();
Common.Gateway.on('processmouse', _.bind(this.onProcessMouse, this));
Common.Gateway.on('downloadas', _.bind(this.onDownloadAs, this));
Common.Gateway.on('requestclose', _.bind(this.onRequestClose, this));
@ -1190,8 +1238,6 @@ define([
txtClose: 'Close',
errorFileSizeExceed: 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.',
errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.',
textNext: 'Next Field',
textClear: 'Clear All Fields',
textSubmited: '<b>Form submitted successfully</b><br>Click to close the tip.',
errorSubmit: 'Submit failed.',
errorEditingDownloadas: 'An error occurred during the work with the document.<br>Use the \'Download as...\' option to save the file backup copy to your computer hard drive.',
@ -1204,6 +1250,18 @@ define([
txtPressLink: 'Press Ctrl and click link',
txtEmpty: '(Empty)',
titleServerVersion: 'Editor updated',
errorServerVersion: 'The editor version has been updated. The page will be reloaded to apply the changes.'
errorServerVersion: 'The editor version has been updated. The page will be reloaded to apply the changes.',
titleUpdateVersion: 'Version changed',
errorUpdateVersion: 'The file version has been changed. The page will be reloaded.',
warnLicenseLimitedRenewed: 'License needs to be renewed.<br>You have a limited access to document editing functionality.<br>Please contact your administrator to get full access',
warnLicenseLimitedNoAccess: 'License expired.<br>You have no access to document editing functionality.<br>Please contact your administrator.',
warnLicenseExceeded: "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.<br>Contact your administrator to learn more.",
warnLicenseUsersExceeded: "You've reached the user limit for %1 editors. Contact your administrator to learn more.",
warnNoLicense: "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.<br>Contact %1 sales team for personal upgrade terms.",
warnNoLicenseUsers: "You've reached the user limit for %1 editors. Contact %1 sales team for personal upgrade terms.",
textBuyNow: 'Visit website',
textNoLicenseTitle: 'License limit reached',
textContactUs: 'Contact sales'
}, DE.Controllers.ApplicationController));
});

View file

@ -21,14 +21,11 @@
"DE.ApplicationController.notcriticalErrorTitle": "Warning",
"DE.ApplicationController.scriptLoadError": "The connection is too slow, some of the components could not be loaded. Please reload the page.",
"DE.ApplicationController.textAnonymous": "Anonymous",
"DE.ApplicationController.textClear": "Clear All Fields",
"DE.ApplicationController.textGotIt": "Got it",
"DE.ApplicationController.textGuest": "Guest",
"DE.ApplicationController.textLoadingDocument": "Loading document",
"DE.ApplicationController.textNext": "Next Field",
"DE.ApplicationController.textOf": "of",
"DE.ApplicationController.textRequired": "Fill all required fields to send form.",
"DE.ApplicationController.textSubmit": "Submit",
"DE.ApplicationController.textSubmited": "<b>Form submitted successfully</b><br>Click to close the tip",
"DE.ApplicationController.txtClose": "Close",
"DE.ApplicationController.unknownErrorText": "Unknown error.",
@ -36,6 +33,20 @@
"DE.ApplicationController.waitText": "Please, wait...",
"DE.ApplicationController.txtEmpty": "(Empty)",
"DE.ApplicationController.txtPressLink": "Press Ctrl and click link",
"DE.ApplicationController.textCloseTip": "Click to close the tip.",
"DE.ApplicationController.titleServerVersion": "Editor updated",
"DE.ApplicationController.errorServerVersion": "The editor version has been updated. The page will be reloaded to apply the changes.",
"DE.ApplicationController.titleUpdateVersion": "Version changed",
"DE.ApplicationController.errorUpdateVersion": "The file version has been changed. The page will be reloaded.",
"DE.ApplicationController.warnLicenseLimitedRenewed": "License needs to be renewed.<br>You have a limited access to document editing functionality.<br>Please contact your administrator to get full access",
"DE.ApplicationController.warnLicenseLimitedNoAccess": "License expired.<br>You have no access to document editing functionality.<br>Please contact your administrator.",
"DE.ApplicationController.warnLicenseExceeded": "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.<br>Contact your administrator to learn more.",
"DE.ApplicationController.warnLicenseUsersExceeded": "You've reached the user limit for %1 editors. Contact your administrator to learn more.",
"DE.ApplicationController.warnNoLicense": "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.<br>Contact %1 sales team for personal upgrade terms.",
"DE.ApplicationController.warnNoLicenseUsers": "You've reached the user limit for %1 editors. Contact %1 sales team for personal upgrade terms.",
"DE.ApplicationController.textBuyNow": "Visit website",
"DE.ApplicationController.textNoLicenseTitle": "License limit reached",
"DE.ApplicationController.textContactUs": "Contact sales",
"DE.ApplicationView.txtDownload": "Download",
"DE.ApplicationView.txtDownloadDocx": "Download as docx",
"DE.ApplicationView.txtDownloadPdf": "Download as pdf",
@ -43,5 +54,8 @@
"DE.ApplicationView.txtFileLocation": "Open file location",
"DE.ApplicationView.txtFullScreen": "Full Screen",
"DE.ApplicationView.txtPrint": "Print",
"DE.ApplicationView.txtShare": "Share"
"DE.ApplicationView.txtShare": "Share",
"DE.ApplicationView.textSubmit": "Submit",
"DE.ApplicationView.textClear": "Clear All Fields",
"DE.ApplicationView.textNext": "Next Field"
}