* Adjust for save change story data.

This commit is contained in:
wangyidong
2023-06-09 16:43:12 +08:00
parent e2795dbd5a
commit aeba8a580f
4 changed files with 67 additions and 63 deletions
+7 -54
View File
@@ -634,65 +634,18 @@ class story extends control
if($story->status == 'reviewing') $this->action->create('story', $storyID, 'submitReview');
}
$this->executeHooks($storyID);
$message = $this->executeHooks($storyID);
if(empty($message)) $message = $this->lang->saveSuccess;
if(isonlybody())
{
$execution = $this->execution->getByID($this->session->execution);
if($this->app->tab == 'execution')
{
$executionLaneType = $this->session->executionLaneType ? $this->session->executionLaneType : 'all';
$executionGroupBy = $this->session->executionGroupBy ? $this->session->executionGroupBy : 'default';
if($execution->type == 'kanban')
{
$rdSearchValue = $this->session->rdSearchValue ? $this->session->rdSearchValue : '';
$kanbanData = $this->loadModel('kanban')->getRDKanban($this->session->execution, $executionLaneType, 'id_desc', 0, $executionGroupBy, $rdSearchValue);
$kanbanData = json_encode($kanbanData);
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.parent.updateKanban($kanbanData)"));
}
if($from == 'taskkanban')
{
$taskSearchValue = $this->session->taskSearchValue ? $this->session->taskSearchValue : '';
$kanbanData = $this->loadModel('kanban')->getExecutionKanban($execution->id, $executionLaneType, $executionGroupBy, $taskSearchValue);
$kanbanType = $executionLaneType == 'all' ? 'story' : key($kanbanData);
$kanbanData = $kanbanData[$kanbanType];
$kanbanData = json_encode($kanbanData);
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.parent.updateKanban(\"story\", $kanbanData)"));
}
}
else
{
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => 'reloadByAjaxForm()'));
}
$response = $this->storyZen->responseAfterCreateInModal($message);
if($response) return $this->send($response);
}
if(defined('RUN_MODE') and RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $storyID));
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success'));
if($this->app->tab == 'project')
{
$module = 'projectstory';
$method = 'view';
$params = "storyID=$storyID";
if(!$this->session->multiple)
{
$module = 'story';
$params .= "&version=0&param={$this->session->project}&storyType=$storyType";
}
}
elseif($this->app->tab == 'execution')
{
$module = 'execution';
$method = 'storyView';
$params = "storyID=$storyID";
}
else
{
$module = 'story';
$method = 'view';
$params = "storyID=$storyID&version=0&param=0&storyType=$storyType";
}
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink($module, $method, $params)));
$location = $this->storyZen->getAfterChangeLocation($storyID, $storyType);
return $this->send(array('result' => 'success', 'message' => $message, 'load' => $location));
}
$this->commonAction($storyID);
+30 -8
View File
@@ -4,13 +4,24 @@ $(function()
var $saveDraftButton = $('#saveDraftButton');
$(document).on('click', '#saveButton', function(e)
{
$saveButton.attr('type', 'submit').attr('disabled', 'disabled');
$saveDraftButton.attr('type', 'button').attr('disabled', 'disabled');
$saveButton.attr('disabled', 'disabled');
$saveDraftButton.attr('disabled', 'disabled');
var storyStatus = !$('#reviewer').val() || $('#needNotReview').prop('checked') ? 'active' : 'reviewing';
if($('#dataform #status').length == 0) $('<input />').attr('type', 'hidden').attr('name', 'status').attr('id', 'status').attr('value', storyStatus).appendTo('#dataform .form-actions');
$('#dataform #status').val(storyStatus);
$(this).submit();
$dataform = $('#dataform');
$.ajaxSubmit(
{
data: new FormData($dataform[0]),
url:$dataform.attr('action'),
onSuccess: function(result)
{
location.href = result.load;
},
});
e.preventDefault();
setTimeout(function()
@@ -19,7 +30,7 @@ $(function()
{
setTimeout(function()
{
$saveButton.attr('type', 'button').removeAttr('disabled');
$saveButton.removeAttr('disabled');
$saveDraftButton.removeAttr('disabled');
}, 10000);
}
@@ -33,15 +44,26 @@ $(function()
$(document).on('click', '#saveDraftButton', function(e)
{
$saveButton.attr('type', 'button').attr('disabled', 'disabled');
$saveDraftButton.attr('type', 'submit').attr('disabled', 'disabled');
$saveButton.attr('disabled', 'disabled');
$saveDraftButton.attr('disabled', 'disabled');
storyStatus = 'draft';
if(typeof(page) != 'undefined' && page == 'change') storyStatus = 'changing';
if(typeof(page) !== 'undefined' && page == 'edit' && $('#status').val() == 'changing') storyStatus = 'changing';
if($('#dataform #status').length == 0) $('<input />').attr('type', 'hidden').attr('name', 'status').attr('id', 'status').attr('value', storyStatus).appendTo('#dataform .form-actions');
$('#dataform #status').val(storyStatus);
$(this).submit();
$dataform = $('#dataform');
$.ajaxSubmit(
{
data: new FormData($dataform[0]),
url:$dataform.attr('action'),
onSuccess: function(result)
{
location.href = result.load;
},
});
e.preventDefault();
setTimeout(function()
@@ -51,7 +73,7 @@ $(function()
setTimeout(function()
{
$saveButton.removeAttr('disabled');
$saveDraftButton.attr('type', 'button').removeAttr('disabled');
$saveDraftButton.removeAttr('disabled');
}, 10000);
}
else
+2 -1
View File
@@ -147,7 +147,7 @@ $formItems['file'] = formGroup
input
(
set::type('file'),
set::name('files'),
set::name('files[]'),
)
);
$formItems['affected'] = getAffectedTabs($story, $users);
@@ -162,6 +162,7 @@ $formActions = formRow
formPanel
(
set::id('dataform'),
set::title(''),
set::actions(false),
$formTitle,
+28
View File
@@ -911,6 +911,34 @@ class storyZen extends story
return $this->createLink('product', 'browse', "productID=$productID&branch=$branch&browseType=unclosed&queryID=0&storyType=$storyType");
}
/**
* 获取变更需求后的跳转地址。
* Get after change story location.
*
* @param int $storyID
* @param string $storyType
* @access protected
* @return string
*/
protected function getAfterChangeLocation(int $storyID, string $storyType = 'story'): string
{
if($this->app->tab == 'execution') return helper::createLink('execution', 'storyView', "storyID=$storyID");
if($this->app->tab != 'project') return helper::createLink('story', 'view', "storyID=$storyID&version=0&param=0&storyType=$storyType");
if($this->app->tab == 'project')
{
$module = 'projectstory';
$method = 'view';
$params = "storyID=$storyID";
if(!$this->session->multiple)
{
$module = 'story';
$params .= "&version=0&param={$this->session->project}&storyType=$storyType";
}
return helper::createLink($module, $module, $params);
}
}
/**
* 获取评审需求后的跳转地址。
* Get after review location.