Merge branch 'fix'
This commit is contained in:
@@ -36,7 +36,6 @@ export default class extends View {
|
||||
targetEntityType = null
|
||||
storageKey = 'formulaSandbox'
|
||||
|
||||
|
||||
setup() {
|
||||
const entityTypeList = [''].concat(
|
||||
this.getMetadata()
|
||||
@@ -132,7 +131,7 @@ export default class extends View {
|
||||
return;
|
||||
}
|
||||
|
||||
let dataToStore = {
|
||||
const dataToStore = {
|
||||
script: this.model.get('script'),
|
||||
targetType: this.model.get('targetType'),
|
||||
targetId: this.model.get('targetId'),
|
||||
@@ -143,6 +142,13 @@ export default class extends View {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {import('views/record/detail').default}
|
||||
*/
|
||||
getRecordView() {
|
||||
return this.getView('record');
|
||||
}
|
||||
|
||||
createRecordView() {
|
||||
return this.createView('record', 'views/admin/formula-sandbox/record/edit', {
|
||||
selector: '.record',
|
||||
@@ -157,7 +163,7 @@ export default class extends View {
|
||||
this.setPageTitle(this.getLanguage().translate('Formula Sandbox', 'labels', 'Admin'));
|
||||
}
|
||||
|
||||
run() {
|
||||
async run() {
|
||||
const script = this.model.get('script');
|
||||
|
||||
this.model.set({
|
||||
@@ -175,50 +181,62 @@ export default class extends View {
|
||||
return;
|
||||
}
|
||||
|
||||
Espo.Ajax
|
||||
.postRequest('Formula/action/run', {
|
||||
this.getRecordView().disableActionItems();
|
||||
Espo.Ui.notifyWait();
|
||||
|
||||
/** @var {Record} */
|
||||
let response;
|
||||
|
||||
try {
|
||||
response = await Espo.Ajax.postRequest('Formula/action/run', {
|
||||
expression: script,
|
||||
targetId: this.model.get('targetId'),
|
||||
targetType: this.model.get('targetType'),
|
||||
})
|
||||
.then(response => {
|
||||
this.model.set('output', response.output || null);
|
||||
|
||||
let errorMessage = null;
|
||||
|
||||
if (!response.isSuccess) {
|
||||
errorMessage = response.message || null;
|
||||
}
|
||||
|
||||
this.model.set('errorMessage', errorMessage);
|
||||
|
||||
if (response.isSuccess) {
|
||||
Espo.Ui.success(
|
||||
this.translate('runSuccess', 'messages', 'Formula')
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.isSyntaxError) {
|
||||
let msg = this.translate('checkSyntaxError', 'messages', 'Formula');
|
||||
|
||||
if (response.message) {
|
||||
msg += ' ' + response.message;
|
||||
}
|
||||
|
||||
Espo.Ui.error(msg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let msg = this.translate('runError', 'messages', 'Formula');
|
||||
|
||||
if (response.message) {
|
||||
msg += ' ' + response.message;
|
||||
}
|
||||
|
||||
Espo.Ui.error(msg);
|
||||
});
|
||||
} catch (e) {
|
||||
this.getRecordView().enableActionItems();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.getRecordView().enableActionItems();
|
||||
|
||||
this.model.set('output', response.output || null);
|
||||
|
||||
let errorMessage = null;
|
||||
|
||||
if (!response.isSuccess) {
|
||||
errorMessage = response.message || null;
|
||||
}
|
||||
|
||||
this.model.set('errorMessage', errorMessage);
|
||||
|
||||
if (response.isSuccess) {
|
||||
Espo.Ui.success(
|
||||
this.translate('runSuccess', 'messages', 'Formula')
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.isSyntaxError) {
|
||||
let msg = this.translate('checkSyntaxError', 'messages', 'Formula');
|
||||
|
||||
if (response.message) {
|
||||
msg += ' ' + response.message;
|
||||
}
|
||||
|
||||
Espo.Ui.error(msg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let msg = this.translate('runError', 'messages', 'Formula');
|
||||
|
||||
if (response.message) {
|
||||
msg += ' ' + response.message;
|
||||
}
|
||||
|
||||
Espo.Ui.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
************************************************************************/
|
||||
|
||||
import View from 'view';
|
||||
import Ajax from 'ajax';
|
||||
|
||||
export default class extends View {
|
||||
|
||||
@@ -35,25 +36,40 @@ export default class extends View {
|
||||
/** @type {Record} */
|
||||
requirements
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
noAccess = false
|
||||
|
||||
data() {
|
||||
return {
|
||||
phpRequirementList: this.requirements.php,
|
||||
databaseRequirementList: this.requirements.database,
|
||||
permissionRequirementList: this.requirements.permission,
|
||||
noAccess: this.noAccess,
|
||||
};
|
||||
}
|
||||
|
||||
setup() {
|
||||
this.requirements = {};
|
||||
|
||||
this.wait(this.loadData());
|
||||
}
|
||||
|
||||
async loadData() {
|
||||
Espo.Ui.notifyWait();
|
||||
|
||||
const promise = Espo.Ajax.getRequest('Admin/action/systemRequirementList').then(requirements => {
|
||||
this.requirements = requirements;
|
||||
try {
|
||||
this.requirements = await Espo.Ajax.getRequest('Admin/action/systemRequirementList');
|
||||
} catch(e) {
|
||||
this.noAccess = true;
|
||||
|
||||
Espo.Ui.notify();
|
||||
});
|
||||
if ('errorIsHandled' in e) {
|
||||
e.errorIsHandled = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.wait(promise);
|
||||
Espo.Ui.notify();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user