[PE][SSE] Add parameters to api customization: macros, plugins, macrosMode

This commit is contained in:
Julia Radzhabova 2020-05-22 17:55:35 +03:00
parent 204ae649a2
commit 0d6ab2808c
5 changed files with 168 additions and 5 deletions

View file

@ -2276,7 +2276,6 @@ define([
}
}
});
}
}
},

View file

@ -342,6 +342,14 @@ define([
$('#editor-container').append('<div class="doc-placeholder"><div class="slide-h"><div class="slide-v"><div class="slide-container"><div class="line"></div><div class="line empty"></div><div class="line"></div></div></div></div></div>');
}
var value = Common.localStorage.getItem("pe-macros-mode");
if (value === null) {
value = this.editorConfig.customization ? this.editorConfig.customization.macrosMode : 'warn';
value = (value == 'enable') ? 1 : (value == 'disable' ? 2 : 0);
} else
value = parseInt(value);
Common.Utils.InternalSettings.set("pe-macros-mode", value);
Common.Controllers.Desktop.init(this.appOptions);
},
@ -373,10 +381,16 @@ define([
docInfo.put_Token(data.doc.token);
docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(this.editorConfig.encryptionKeys);
var enable = !this.editorConfig.customization || (this.editorConfig.customization.macros!==false);
docInfo.asc_putIsEnabledMacroses(!!enable);
enable = !this.editorConfig.customization || (this.editorConfig.customization.plugins!==false);
docInfo.asc_putIsEnabledPlugins(!!enable);
}
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);
@ -1883,6 +1897,36 @@ define([
}});
},
onRunAutostartMacroses: function() {
var me = this,
enable = !this.editorConfig.customization || (this.editorConfig.customization.macros!==false);
if (enable) {
var value = Common.Utils.InternalSettings.get("pe-macros-mode");
if (value==1)
this.api.asc_runAutostartMacroses();
else if (value === 0) {
Common.UI.warning({
msg: this.textHasMacros + '<br>',
buttons: ['yes', 'no'],
primary: 'yes',
dontshow: true,
textDontShow: this.textRemember,
callback: function(btn, dontshow){
if (dontshow) {
Common.Utils.InternalSettings.set("pe-macros-mode", (btn == 'yes') ? 1 : 2);
Common.localStorage.setItem("pe-macros-mode", (btn == 'yes') ? 1 : 2);
}
if (btn == 'yes') {
setTimeout(function() {
me.api.asc_runAutostartMacroses();
}, 1);
}
}
});
}
}
},
// Translation
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.',
criticalErrorTitle: 'Error',
@ -2234,7 +2278,9 @@ define([
textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.<br>Please contact our Sales Department to get a quote.',
waitText: 'Please, wait...',
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.'
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.',
textHasMacros: 'The file contains automatic macros.<br>Do you want to run macros?',
textRemember: 'Remember my choice'
}
})(), PE.Controllers.Main || {}))
});

View file

@ -208,6 +208,12 @@ define([
'<td class="left"><label><%= scope.strUnit %></label></td>',
'<td class="right"><span id="fms-cmb-unit" /></td>',
'</tr>','<tr class="divider edit"></tr>',
'<tr class="macros">',
'<td class="left"><label><%= scope.strMacrosSettings %></label></td>',
'<td class="right">',
'<div><div id="fms-cmb-macros" style="display: inline-block; margin-right: 15px;vertical-align: middle;"/>',
'<label id="fms-lbl-macros" style="vertical-align: middle;"><%= scope.txtWarnMacrosDesc %></label></div></td>',
'</tr>','<tr class="divider macros"></tr>',
'<tr>',
'<td class="left"></td>',
'<td class="right"><button id="fms-btn-apply" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>',
@ -331,6 +337,21 @@ define([
]
});
this.cmbMacros = new Common.UI.ComboBox({
el : $markup.findById('#fms-cmb-macros'),
style : 'width: 160px;',
editable : false,
cls : 'input-group-nr',
data : [
{ value: 2, displayValue: this.txtStopMacros, descValue: this.txtStopMacrosDesc },
{ value: 0, displayValue: this.txtWarnMacros, descValue: this.txtWarnMacrosDesc },
{ value: 1, displayValue: this.txtRunMacros, descValue: this.txtRunMacrosDesc }
]
}).on('selected', function(combo, record) {
me.lblMacrosDesc.text(record.descValue);
});
this.lblMacrosDesc = $markup.findById('#fms-lbl-macros');
this.btnApply = new Common.UI.Button({
el: $markup.findById('#fms-btn-apply')
});
@ -367,6 +388,7 @@ define([
/** coauthoring begin **/
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide']();
/** coauthoring end **/
$('tr.macros', this.el)[(mode.customization && mode.customization.macros===false) ? 'hide' : 'show']();
},
updateSettings: function() {
@ -409,6 +431,10 @@ define([
}
this.chAlignGuides.setValue(Common.Utils.InternalSettings.get("pe-settings-showsnaplines"));
item = this.cmbMacros.store.findWhere({value: Common.Utils.InternalSettings.get("pe-macros-mode")});
this.cmbMacros.setValue(item ? item.get('value') : 0);
this.lblMacrosDesc.text(item ? item.get('descValue') : this.txtWarnMacrosDesc);
},
applySettings: function() {
@ -430,6 +456,9 @@ define([
Common.localStorage.setItem("pe-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);
Common.Utils.InternalSettings.set("pe-settings-showsnaplines", this.chAlignGuides.isChecked());
Common.localStorage.setItem("pe-macros-mode", this.cmbMacros.getValue());
Common.Utils.InternalSettings.set("pe-macros-mode", Common.localStorage.getItem("pe-macros-mode"));
Common.localStorage.save();
if (this.menu) {
@ -484,7 +513,14 @@ define([
strForcesave: 'Always save to server (otherwise save to server on document close)',
txtSpellCheck: 'Spell Checking',
strSpellCheckMode: 'Turn on spell checking option',
txtCacheMode: 'Default cache mode'
txtCacheMode: 'Default cache mode',
strMacrosSettings: 'Macros Settings',
txtWarnMacros: 'Show Notification',
txtRunMacros: 'Enable All',
txtStopMacros: 'Disable All',
txtWarnMacrosDesc: 'Disable all macros with notification',
txtRunMacrosDesc: 'Enable all macros without notification',
txtStopMacrosDesc: 'Disable all macros without notification'
}, PE.Views.FileMenuPanels.Settings || {}));
PE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({

View file

@ -390,6 +390,14 @@ define([
$('#editor_sdk').append('<div class="doc-placeholder">' + '<div class="columns"></div>'.repeat(2) + '</div>');
}
var value = Common.localStorage.getItem("sse-macros-mode");
if (value === null) {
value = this.editorConfig.customization ? this.editorConfig.customization.macrosMode : 'warn';
value = (value == 'enable') ? 1 : (value == 'disable' ? 2 : 0);
} else
value = parseInt(value);
Common.Utils.InternalSettings.set("sse-macros-mode", value);
this.isFrameClosed = (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge);
Common.Controllers.Desktop.init(this.appOptions);
},
@ -422,6 +430,11 @@ define([
docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(this.editorConfig.encryptionKeys);
var enable = !this.editorConfig.customization || (this.editorConfig.customization.macros!==false);
docInfo.asc_putIsEnabledMacroses(!!enable);
enable = !this.editorConfig.customization || (this.editorConfig.customization.plugins!==false);
docInfo.asc_putIsEnabledPlugins(!!enable);
this.headerView && this.headerView.setDocumentCaption(data.doc.title);
Common.Utils.InternalSettings.set("sse-doc-info-key", data.doc.key);
@ -429,6 +442,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_registerCallback('asc_onRunAutostartMacroses', _.bind(this.onRunAutostartMacroses, this));
this.api.asc_setDocInfo(docInfo);
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
},
@ -2183,6 +2197,36 @@ define([
}});
},
onRunAutostartMacroses: function() {
var me = this,
enable = !this.editorConfig.customization || (this.editorConfig.customization.macros!==false);
if (enable) {
var value = Common.Utils.InternalSettings.get("sse-macros-mode");
if (value==1)
this.api.asc_runAutostartMacroses();
else if (value === 0) {
Common.UI.warning({
msg: this.textHasMacros + '<br>',
buttons: ['yes', 'no'],
primary: 'yes',
dontshow: true,
textDontShow: this.textRemember,
callback: function(btn, dontshow){
if (dontshow) {
Common.Utils.InternalSettings.set("sse-macros-mode", (btn == 'yes') ? 1 : 2);
Common.localStorage.setItem("sse-macros-mode", (btn == 'yes') ? 1 : 2);
}
if (btn == 'yes') {
setTimeout(function() {
me.api.asc_runAutostartMacroses();
}, 1);
}
}
});
}
}
},
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.',
criticalErrorTitle: 'Error',
notcriticalErrorTitle: 'Warning',
@ -2548,7 +2592,9 @@ define([
txtRowLbls: 'Row Labels',
txtColLbls: 'Column Labels',
errNoDuplicates: 'No duplicate values found.',
errRemDuplicates: 'Duplicate values found and deleted: {0}, unique values left: {1}.'
errRemDuplicates: 'Duplicate values found and deleted: {0}, unique values left: {1}.',
textHasMacros: 'The file contains automatic macros.<br>Do you want to run macros?',
textRemember: 'Remember my choice'
}
})(), SSE.Controllers.Main || {}))
});

View file

@ -667,6 +667,12 @@ define([
'<td class="left"></td>',
'<td class="right"><div id="fms-thousands-separator"/><label class="label-separator" style="margin-left: 10px; padding-top: 4px;"><%= scope.strThousandsSeparator %></label></td>',
'</tr>','<tr class="divider edit"></tr>',
'<tr class="macros">',
'<td class="left"><label><%= scope.strMacrosSettings %></label></td>',
'<td class="right">',
'<div><div id="fms-cmb-macros" style="display: inline-block; margin-right: 15px;vertical-align: middle;"/>',
'<label id="fms-lbl-macros" style="vertical-align: middle;"><%= scope.txtWarnMacrosDesc %></label></div></td>',
'</tr>','<tr class="divider macros"></tr>',
'<tr>',
'<td class="left"></td>',
'<td class="right"><button id="fms-btn-apply" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>',
@ -897,6 +903,21 @@ define([
var $thousandsSeparatorInput = this.inputThousandsSeparator.$el.find('input');
$thousandsSeparatorInput.on('keydown', keyDown);
this.cmbMacros = new Common.UI.ComboBox({
el : $markup.findById('#fms-cmb-macros'),
style : 'width: 160px;',
editable : false,
cls : 'input-group-nr',
data : [
{ value: 2, displayValue: this.txtStopMacros, descValue: this.txtStopMacrosDesc },
{ value: 0, displayValue: this.txtWarnMacros, descValue: this.txtWarnMacrosDesc },
{ value: 1, displayValue: this.txtRunMacros, descValue: this.txtRunMacrosDesc }
]
}).on('selected', function(combo, record) {
me.lblMacrosDesc.text(record.descValue);
});
this.lblMacrosDesc = $markup.findById('#fms-lbl-macros');
this.btnApply = new Common.UI.Button({
el: $markup.findById('#fms-btn-apply')
});
@ -932,6 +953,7 @@ define([
$('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide']();
$('tr.comments', this.el)[mode.canCoAuthoring ? 'show' : 'hide']();
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring? 'show' : 'hide']();
$('tr.macros', this.el)[(mode.customization && mode.customization.macros===false) ? 'hide' : 'show']();
},
setApi: function(api) {
@ -1016,6 +1038,10 @@ define([
} else {
this.$el.find('.label-separator').removeClass('disabled');
}
item = this.cmbMacros.store.findWhere({value: Common.Utils.InternalSettings.get("sse-macros-mode")});
this.cmbMacros.setValue(item ? item.get('value') : 0);
this.lblMacrosDesc.text(item ? item.get('descValue') : this.txtWarnMacrosDesc);
},
applySettings: function() {
@ -1056,6 +1082,9 @@ define([
Common.localStorage.setBool("sse-settings-use-base-separator", isChecked);
Common.Utils.InternalSettings.set("sse-settings-use-base-separator", isChecked);
Common.localStorage.setItem("sse-macros-mode", this.cmbMacros.getValue());
Common.Utils.InternalSettings.set("sse-macros-mode", Common.localStorage.getItem("sse-macros-mode"));
Common.localStorage.save();
if (this.menu) {
this.menu.fireEvent('settings:apply', [this.menu]);
@ -1150,7 +1179,14 @@ define([
strUseSeparatorsBasedOnRegionalSettings: 'Use separators based on regional settings',
strDecimalSeparator: 'Decimal separator',
strThousandsSeparator: 'Thousands separator',
txtCacheMode: 'Default cache mode'
txtCacheMode: 'Default cache mode',
strMacrosSettings: 'Macros Settings',
txtWarnMacros: 'Show Notification',
txtRunMacros: 'Enable All',
txtStopMacros: 'Disable All',
txtWarnMacrosDesc: 'Disable all macros with notification',
txtRunMacrosDesc: 'Enable all macros without notification',
txtStopMacrosDesc: 'Disable all macros without notification'
}, SSE.Views.FileMenuPanels.MainSettingsGeneral || {}));
SSE.Views.FileMenuPanels.MainSpellCheckSettings = Common.UI.BaseView.extend(_.extend({