From fec5fb2da512daa153efd4da5496445ffbc6ef35 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 12 Jul 2023 15:27:57 +0800 Subject: [PATCH] * Refactor delete cron. --- module/cron/control.php | 7 ++----- module/cron/js/index.ui.js | 13 ------------- module/cron/ui/index.html.php | 10 +++------- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/module/cron/control.php b/module/cron/control.php index fb97cecb6e..7ec38090e2 100644 --- a/module/cron/control.php +++ b/module/cron/control.php @@ -107,16 +107,13 @@ class cron extends control * Delete cron. * * @param int $cronID - * @param string $confirm * @access public * @return void */ - public function delete($cronID, $confirm = 'no') + public function delete($cronID) { - if($confirm == 'no') return print(js::confirm($this->lang->cron->confirmDelete, inlink('delete', "cronID=$cronID&confirm=yes"))); - $this->dao->delete()->from(TABLE_CRON)->where('id')->eq($cronID)->exec(); - return print(js::reload('parent')); + return $this->sendSuccess(array('load' => true)); } /** diff --git a/module/cron/js/index.ui.js b/module/cron/js/index.ui.js index 0d898dcc94..02cf61e764 100644 --- a/module/cron/js/index.ui.js +++ b/module/cron/js/index.ui.js @@ -2,16 +2,3 @@ $(document).on('click', '.ajaxRefresh', function() { $.get($(this).attr('href'), function(){loadPage($.createLink('cron', 'index'));}) }) - -$(document).on('click', '.ajaxDelete', function(e) -{ - if(window.confirm(confirmDelete)) return $.get($.createLink('cron', 'delete', 'id=' + $(this).data('id') + '&confirm=yes'), function(){loadPage($.createLink('cron', 'index'));}) - e.stopPropagation(); - return false; -}) - -window.confirmTurnon = function() -{ - if(window.confirm(confirmTurnonMessage)) return $.get($.createLink('cron', 'turnon', 'confirm=yes'), function(){loadPage($.createLink('cron', 'index'));}) - return false; -} diff --git a/module/cron/ui/index.html.php b/module/cron/ui/index.html.php index a0fcd4267e..2cd742065e 100644 --- a/module/cron/ui/index.html.php +++ b/module/cron/ui/index.html.php @@ -10,15 +10,12 @@ declare(strict_types=1); */ namespace zin; -jsVar('confirmTurnonMessage', $this->lang->cron->confirmTurnon); -jsVar('confirmDelete', $this->lang->cron->confirmDelete); - foreach($crons as $cron) { $actionsHtml = ''; - if(common::hasPriv('cron', 'toggle') and !empty($cron->command)) $actionsHtml .= html::a(inlink('toggle', "id=$cron->id&status=" . ($cron->status == 'stop' ? 'normal' : 'stop')), $cron->status == 'stop' ? $lang->cron->toggleList['start'] : $lang->cron->toggleList['stop'], '', "class='primary-500 ajaxRefresh'"); - if(!empty($cron->command) and common::hasPriv('cron', 'edit')) $actionsHtml .= html::a(inlink('edit', "id=$cron->id"), $lang->edit, '', "class='primary-500'"); - if($cron->buildin == 0 and common::hasPriv('cron', 'delete')) $actionsHtml .= html::a('###', $lang->delete, '', "class='primary-500 ajaxDelete' data-id={$cron->id}"); + if(common::hasPriv('cron', 'toggle') and !empty($cron->command)) $actionsHtml .= html::a(inlink('toggle', "id={$cron->id}&status=" . ($cron->status == 'stop' ? 'normal' : 'stop')), $cron->status == 'stop' ? $lang->cron->toggleList['start'] : $lang->cron->toggleList['stop'], '', "class='primary-500 ajaxRefresh'"); + if(!empty($cron->command) and common::hasPriv('cron', 'edit')) $actionsHtml .= html::a(inlink('edit', "id={$cron->id}"), $lang->edit, '', "class='primary-500'"); + if($cron->buildin == 0 and common::hasPriv('cron', 'delete')) $actionsHtml .= html::a(inlink('delete', "id={$cron->id}"), $lang->delete, '', "class='primary-500 ajax-submit' data-confirm={$lang->cron->confirmDelete}"); $cron->actions = $actionsHtml; if($cron->lastTime) $cron->lastTime = substr($cron->lastTime, 2, 17); @@ -50,4 +47,3 @@ panel ); render(); -