Skip to content

Commit c97a25e

Browse files
authored
1.1.5
1 parent 5cf8203 commit c97a25e

File tree

4 files changed

+29
-40
lines changed

4 files changed

+29
-40
lines changed
Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
1-
define('manual-scheduled-job:manual-job-handler', ['action-handler'], function (Dep) {
1+
define('manual-scheduled-job:manual-job-handler', ['action-handler'], (Dep) => {
22

3-
return Dep.extend({
3+
return class extends Dep {
44

5-
actionRunManually: function () {
5+
initManualScheduledJob() {}
6+
7+
runManually() {
68
Espo.Ui.warning('Running...');
7-
var data = {
9+
const data = {
810
id: this.view.model.id,
911
name: this.view.model.attributes.name
1012
};
13+
14+
Espo.Ajax.postRequest('ManualScheduledJob/action/RunManually', data)
15+
.then(returnData => {
16+
const message = this.view.translate('willRunNextRound', 'messages', 'ScheduledJob');
17+
Espo.Ui.success(message);
18+
})
19+
.catch(() => {
20+
const message = this.view.translate('cannotRunJob', 'messages', 'ScheduledJob');
21+
Espo.Ui.error(message);
22+
});
23+
}
1124

12-
Espo.Ajax.postRequest('ManualScheduledJob/action/RunManually', data).then(returnData => {
13-
let message = this.view.translate('willRunNextRound', 'messages', 'ScheduledJob');
14-
Espo.Ui.success(message);
15-
}).fail(() => {
16-
let message = this.view.translate('cannotRunJob', 'messages', 'ScheduledJob');
17-
Espo.Ui.error(message);
18-
});
19-
},
20-
21-
initManualScheduledJob: function () {
22-
this.controlButtonVisibility();
23-
24-
this.view.listenTo(
25-
this.view.model,
26-
'change:status',
27-
this.controlButtonVisibility.bind(this)
28-
);
29-
},
30-
31-
controlButtonVisibility: function () {
32-
if (this.view.model.get('status') != 'Inactive') {
33-
this.view.showHeaderActionItem('RunManually');
34-
} else {
35-
this.view.hideHeaderActionItem('RunManually');
36-
}
37-
},
38-
});
25+
isManualScheduledJobVisible() {
26+
return this.view.model.get('status') !== 'Inactive';
27+
}
28+
}
3929
});

files/custom/Espo/Modules/ManualScheduledJob/Resources/metadata/clientDefs/ScheduledJob.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
{
77
"label": "Run Manually",
88
"name": "RunManually",
9-
"action": "RunManually",
9+
"action": "runManually",
10+
"actionFunction": "runManually",
1011
"style": "warning",
1112
"iconHtml": "<span class='fas fa-business-time fa-sm'></span>",
12-
"acl": "admin",
13+
"acl": "read",
1314
"aclScope": "ScheduledJob",
14-
"data": {
15-
"handler": "manual-scheduled-job:manual-job-handler"
16-
},
17-
"initFunction": "initManualScheduledJob"
15+
"handler": "manual-scheduled-job:manual-job-handler",
16+
"checkVisibilityFunction": "isManualScheduledJobVisible"
1817
}
1918
]
2019
}

files/custom/Espo/Modules/ManualScheduledJob/Services/ManualScheduledJob.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ManualScheduledJob extends Record
1919
*/
2020
public function runJobManually(object $data): bool {
2121
$nextDate = date('Y-m-d H:i:s');
22-
$jobEntity = $this->getEntityManager()->getEntity('Job');
22+
$jobEntity = $this->entityManager->getEntity('Job');
2323

2424
$jobEntity->set([
2525
'name' => $data->name,
@@ -30,7 +30,7 @@ public function runJobManually(object $data): bool {
3030

3131
// Handle potential exceptions when saving the entity
3232
try {
33-
return $this->getEntityManager()->saveEntity($jobEntity)? true : false;
33+
return $this->entityManager->saveEntity($jobEntity)? true : false;
3434
} catch (\Exception $e) {
3535
// Log the error and re-throw it
3636
$GLOBALS['log']->error('Error while running ManualScheduledJob: ' . $e->getMessage());

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Manual Scheduled Job",
3-
"version": "1.1.1",
3+
"version": "1.1.5",
44
"type": "extension",
55
"acceptableVersions": [
66
">=7.0.0"

0 commit comments

Comments
 (0)