* Code for task #95519.
This commit is contained in:
@@ -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}")';
|
||||
|
||||
+16
-30
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
textarea {width: 704px !important;}
|
||||
input[name="realEnd"] {width: 150px;}
|
||||
.modal-dialog {width: 890px !important;}
|
||||
|
||||
@@ -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)});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace zin;
|
||||
|
||||
jsVar('confirmDeleteTip', $lang->project->confirmDelete);
|
||||
/* zin: Define the feature bar on main menu. */
|
||||
featureBar
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user