diff --git a/module/project/config.php b/module/project/config.php index e2d7def473..fabc3e426a 100644 --- a/module/project/config.php +++ b/module/project/config.php @@ -348,4 +348,4 @@ $config->project->actionList['whitelist']['url'] = array('module' => 'project', $config->project->actionList['delete']['icon'] = 'trash'; $config->project->actionList['delete']['hint'] = $lang->project->delete; -$config->project->actionList['delete']['url'] = array('module' => 'project', 'method' => 'delete', 'params' => 'projectID={id}'); +$config->project->actionList['delete']['url'] = 'javascript:confirmDelete("{id}", "{name}")'; diff --git a/module/project/control.php b/module/project/control.php index 0d58a879fc..add41d36e5 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -1662,47 +1662,33 @@ class project extends control * Delete a project and confirm. * * @param string $projectID - * @param string $confirm * @param string $from browse|view * * @access public - * @return int + * @return void */ - public function delete(string $projectID, string $confirm = 'no', string $from = 'browse'): int + public function delete(int $projectID, string $from = 'browse') { $projectID = (int)$projectID; $project = $this->project->getByID($projectID); + $this->project->delete(TABLE_PROJECT, $projectID); + $this->project->deleteByTableName('zt_doclib', $projectID); + $this->loadModel('user')->updateUserView($projectID, 'project'); - if($confirm == 'no') - { - return print(js::confirm(sprintf($this->lang->project->confirmDelete, $project->name), $this->createLink('project', 'delete', "projectID=$projectID&confirm=yes&from=$from"))); - } - else - { - $this->project->delete(TABLE_PROJECT, $projectID); - $this->project->deleteByTableName('zt_doclib', $projectID); - $this->loadModel('user')->updateUserView($projectID, 'project'); + $response['closedModal'] = true; + $response['load'] = true; - $message = $this->executeHooks($projectID); - if($message) $this->lang->saveSuccess = $message; + $message = $this->executeHooks($projectID); + if($message) $response['message'] = $message; - /* Delete the execution and product under the project. */ - $executionIdList = $this->loadModel('execution')->getPairs($projectID); - if(empty($executionIdList)) - { - if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); - if($from == 'view') return print(js::locate($this->createLink('project', 'browse'), 'parent')); - return print(js::reload('parent')); - } - $this->projectZen->removeAssociatedExecutions($executionIdList); - $this->projectZen->removeAssociatedProducts($project); + /* Delete the execution and product under the project. */ + $executionIdList = $this->loadModel('execution')->getPairs($projectID); + if(!empty($executionIdList)) $this->projectZen->removeAssociatedExecutions($executionIdList); + $this->projectZen->removeAssociatedProducts($project); - if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); - - $this->session->set('project', ''); - if($from == 'view') return print(js::locate($this->createLink('project', 'browse'), 'parent')); - return print(js::reload('parent')); - } + $this->session->set('project', ''); + if($from == 'view') $response['load'] = helper::createLink('project', 'browse'); + return $this->sendSuccess($response); } /** diff --git a/module/project/css/browse.ui.css b/module/project/css/browse.ui.css index e1a2736a10..f091192ad0 100644 --- a/module/project/css/browse.ui.css +++ b/module/project/css/browse.ui.css @@ -1,3 +1,2 @@ textarea {width: 704px !important;} input[name="realEnd"] {width: 150px;} -.modal-dialog {width: 890px !important;} diff --git a/module/project/js/common.ui.js b/module/project/js/common.ui.js index 4d5f2ec465..b067ecbb3e 100644 --- a/module/project/js/common.ui.js +++ b/module/project/js/common.ui.js @@ -116,3 +116,20 @@ window.createSortLink = function(col) if(sort == orderBy) sort = col.name + '_desc'; return sortLink.replace('{orderBy}', sort); } + +/** + * 提示并删除项目。 + * Delete project with tips. + * + * @param int projectID + * @param string projectName + * @access public + * @return void + */ +window.confirmDelete = function(projectID, projectName) +{ + zui.Modal.confirm({message: confirmDeleteTip.replace('%s', projectName), icon:'icon-info-sign', iconClass: 'warning-pale rounded-full icon-2x'}).then((res) => + { + if(res) $.ajaxSubmit({url: $.createLink('project', 'delete', 'projectID=' + projectID)}); + }); +} diff --git a/module/project/ui/browse.html.php b/module/project/ui/browse.html.php index b40573f639..9a3c2d19f8 100644 --- a/module/project/ui/browse.html.php +++ b/module/project/ui/browse.html.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace zin; +jsVar('confirmDeleteTip', $lang->project->confirmDelete); /* zin: Define the feature bar on main menu. */ featureBar (