ref
This commit is contained in:
@@ -98,6 +98,11 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
*/
|
||||
viewModalView = null
|
||||
|
||||
/**
|
||||
* @protected
|
||||
*/
|
||||
listLayoutName
|
||||
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
|
||||
@@ -26,49 +26,47 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/scheduled-job/fields/job', ['views/fields/enum'], function (Dep) {
|
||||
import EnumFieldView from 'views/fields/enum';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends EnumFieldView {
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
if (this.isEditMode() || this.isDetailMode()) {
|
||||
this.wait(true);
|
||||
if (this.isEditMode() || this.isDetailMode()) {
|
||||
this.wait(true);
|
||||
|
||||
Espo.Ajax
|
||||
.getRequest('Admin/jobs')
|
||||
.then(data => {
|
||||
this.params.options = data.filter(item => {
|
||||
return !this.getMetadata().get(['entityDefs', 'ScheduledJob', 'jobs', item, 'isSystem']);
|
||||
});
|
||||
|
||||
this.params.options.unshift('');
|
||||
|
||||
this.wait(false);
|
||||
Espo.Ajax.getRequest('Admin/jobs')
|
||||
.then(data => {
|
||||
this.params.options = data.filter(item => {
|
||||
return !this.getMetadata().get(['entityDefs', 'ScheduledJob', 'jobs', item, 'isSystem']);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.model.isNew()) {
|
||||
this.on('change', () => {
|
||||
const job = this.model.get('job');
|
||||
this.params.options.unshift('');
|
||||
|
||||
if (job) {
|
||||
const label = this.getLanguage().translateOption(job, 'job', 'ScheduledJob');
|
||||
const scheduling =
|
||||
this.getMetadata().get(`entityDefs.ScheduledJob.jobSchedulingMap.${job}`) ||
|
||||
'*/10 * * * *';
|
||||
|
||||
this.model.set('name', label);
|
||||
this.model.set('scheduling', scheduling);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.model.set('name', '');
|
||||
this.model.set('scheduling', '');
|
||||
this.wait(false);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (this.model.isNew()) {
|
||||
this.on('change', () => {
|
||||
const job = this.model.get('job');
|
||||
|
||||
if (job) {
|
||||
const label = this.getLanguage().translateOption(job, 'job', 'ScheduledJob');
|
||||
const scheduling =
|
||||
this.getMetadata().get(`entityDefs.ScheduledJob.jobSchedulingMap.${job}`) ||
|
||||
'*/10 * * * *';
|
||||
|
||||
this.model.set('name', label);
|
||||
this.model.set('scheduling', scheduling);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.model.set('name', '');
|
||||
this.model.set('scheduling', '');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,82 +26,82 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/scheduled-job/fields/scheduling', ['views/fields/varchar'], function (Dep) {
|
||||
import VarcharFieldView from 'views/fields/varchar';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends VarcharFieldView {
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
if (this.isEditMode() || this.isDetailMode()) {
|
||||
this.wait(
|
||||
Espo.loader.requirePromise('lib!cronstrue')
|
||||
.then(Cronstrue => {
|
||||
this.Cronstrue = Cronstrue;
|
||||
if (this.isEditMode() || this.isDetailMode()) {
|
||||
this.wait(
|
||||
Espo.loader.requirePromise('lib!cronstrue')
|
||||
.then(Cronstrue => {
|
||||
this.Cronstrue = Cronstrue;
|
||||
|
||||
this.listenTo(this.model, 'change:' + this.name, () => this.showText());
|
||||
})
|
||||
);
|
||||
}
|
||||
},
|
||||
this.listenTo(this.model, 'change:' + this.name, () => this.showText());
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
afterRender() {
|
||||
super.afterRender();
|
||||
|
||||
if (this.isEditMode() || this.isDetailMode()) {
|
||||
let $text = this.$text = $('<div class="small text-success"/>');
|
||||
if (this.isEditMode() || this.isDetailMode()) {
|
||||
const $text = this.$text = $('<div class="small text-success"/>');
|
||||
|
||||
this.$el.append($text);
|
||||
this.showText();
|
||||
}
|
||||
},
|
||||
this.$el.append($text);
|
||||
this.showText();
|
||||
}
|
||||
}
|
||||
|
||||
showText: function () {
|
||||
if (!this.$text || !this.$text.length) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
showText() {
|
||||
let text;
|
||||
if (!this.$text || !this.$text.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.Cronstrue) {
|
||||
return;
|
||||
}
|
||||
if (!this.Cronstrue) {
|
||||
return;
|
||||
}
|
||||
|
||||
var exp = this.model.get(this.name);
|
||||
const exp = this.model.get(this.name);
|
||||
|
||||
if (!exp) {
|
||||
this.$text.text('');
|
||||
if (!exp) {
|
||||
this.$text.text('');
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (exp === '* * * * *') {
|
||||
this.$text.text(this.translate('As often as possible', 'labels', 'ScheduledJob'));
|
||||
if (exp === '* * * * *') {
|
||||
this.$text.text(this.translate('As often as possible', 'labels', 'ScheduledJob'));
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var locale = 'en';
|
||||
var localeList = Object.keys(this.Cronstrue.default.locales);
|
||||
var language = this.getLanguage().name;
|
||||
let locale = 'en';
|
||||
const localeList = Object.keys(this.Cronstrue.default.locales);
|
||||
const language = this.getLanguage().name;
|
||||
|
||||
if (~localeList.indexOf(language)) {
|
||||
locale = language;
|
||||
}
|
||||
else if (~localeList.indexOf(language.split('_')[0])) {
|
||||
locale = language.split('_')[0];
|
||||
}
|
||||
if (~localeList.indexOf(language)) {
|
||||
locale = language;
|
||||
} else if (~localeList.indexOf(language.split('_')[0])) {
|
||||
locale = language.split('_')[0];
|
||||
}
|
||||
|
||||
try {
|
||||
var text = this.Cronstrue.toString(exp, {
|
||||
use24HourTimeFormat: !this.getDateTime().hasMeridian(),
|
||||
locale: locale,
|
||||
});
|
||||
try {
|
||||
text = this.Cronstrue.toString(exp, {
|
||||
use24HourTimeFormat: !this.getDateTime().hasMeridian(),
|
||||
locale: locale,
|
||||
});
|
||||
} catch (e) {
|
||||
text = this.translate('Not valid');
|
||||
}
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
text = this.translate('Not valid');
|
||||
}
|
||||
|
||||
this.$text.text(text);
|
||||
},
|
||||
});
|
||||
});
|
||||
this.$text.text(text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,44 +26,43 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/scheduled-job/list', ['views/list'], function (Dep) {
|
||||
import ListView from 'views/list';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends ListView {
|
||||
|
||||
searchPanel: false,
|
||||
searchPanel = false
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
this.menu.buttons.push({
|
||||
link: '#Admin/jobs',
|
||||
text: this.translate('Jobs', 'labels', 'Admin'),
|
||||
this.addMenuItem('buttons', {
|
||||
link: '#Admin/jobs',
|
||||
text: this.translate('Jobs', 'labels', 'Admin'),
|
||||
});
|
||||
|
||||
this.createView('search', 'views/base', {
|
||||
fullSelector: '#main > .search-container',
|
||||
template: 'scheduled-job/cronjob',
|
||||
});
|
||||
}
|
||||
|
||||
afterRender() {
|
||||
super.afterRender();
|
||||
|
||||
Espo.Ajax
|
||||
.getRequest('Admin/action/cronMessage')
|
||||
.then(data => {
|
||||
this.$el.find('.cronjob .message').html(data.message);
|
||||
this.$el.find('.cronjob .command').html('<strong>' + data.command + '</strong>');
|
||||
});
|
||||
}
|
||||
|
||||
this.createView('search', 'views/base', {
|
||||
fullSelector: '#main > .search-container',
|
||||
template: 'scheduled-job/cronjob',
|
||||
});
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
|
||||
Espo.Ajax
|
||||
.getRequest('Admin/action/cronMessage')
|
||||
.then(data => {
|
||||
this.$el.find('.cronjob .message').html(data.message);
|
||||
this.$el.find('.cronjob .command').html('<strong>' + data.command + '</strong>');
|
||||
});
|
||||
},
|
||||
|
||||
getHeader: function () {
|
||||
return this.buildHeaderHtml([
|
||||
$('<a>')
|
||||
.attr('href', '#Admin')
|
||||
.text(this.translate('Administration', 'labels', 'Admin')),
|
||||
this.getLanguage().translate(this.scope, 'scopeNamesPlural')
|
||||
]);
|
||||
},
|
||||
});
|
||||
});
|
||||
getHeader() {
|
||||
return this.buildHeaderHtml([
|
||||
$('<a>')
|
||||
.attr('href', '#Admin')
|
||||
.text(this.translate('Administration', 'labels', 'Admin')),
|
||||
this.getLanguage().translate(this.scope, 'scopeNamesPlural')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,9 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/scheduled-job/record/detail', ['views/record/detail'], function (Dep) {
|
||||
import DetailRecordView from 'views/record/detail';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends DetailRecordView {
|
||||
|
||||
duplicateAction: false,
|
||||
});
|
||||
});
|
||||
duplicateAction = false
|
||||
}
|
||||
|
||||
@@ -26,15 +26,11 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/scheduled-job/record/list', ['views/record/list'], function (Dep) {
|
||||
import ListRecordView from 'views/record/list';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends ListRecordView {
|
||||
|
||||
quickDetailDisabled: true,
|
||||
|
||||
quickEditDisabled: true,
|
||||
|
||||
massActionList: ['remove', 'massUpdate'],
|
||||
|
||||
});
|
||||
});
|
||||
quickDetailDisabled = true
|
||||
quickEditDisabled = true
|
||||
massActionList = ['remove', 'massUpdate']
|
||||
}
|
||||
|
||||
@@ -26,16 +26,15 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/scheduled-job/record/panels/log', ['views/record/panels/relationship'], function (Dep) {
|
||||
import RelationshipPanelView from 'views/record/panels/relationship';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends RelationshipPanelView {
|
||||
|
||||
setupListLayout: function () {
|
||||
var jobWithTargetList = this.getMetadata().get(['clientDefs', 'ScheduledJob', 'jobWithTargetList']) || [];
|
||||
setupListLayout() {
|
||||
const jobWithTargetList = this.getMetadata().get(['clientDefs', 'ScheduledJob', 'jobWithTargetList']) || [];
|
||||
|
||||
if (~jobWithTargetList.indexOf(this.model.get('job'))) {
|
||||
this.listLayoutName = 'listSmallWithTarget'
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
if (~jobWithTargetList.indexOf(this.model.get('job'))) {
|
||||
this.listLayoutName = 'listSmallWithTarget'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user