diff --git a/module/story/control.php b/module/story/control.php index b6478e7346..5cc915f284 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1705,4 +1705,43 @@ class story extends control if($id) die(html::select("storys[$id]", $storys, '', 'class="form-control"')); die(html::select('story', $storys, '', 'class=form-control')); } + + /** + * Ajax get story status. + * + * @param string $method + * @param string $params + * @access public + * @return void + */ + public function ajaxGetStatus($method, $params = '') + { + parse_str(str_replace(',', '&', $params), $params); + $status = ''; + if($method == 'create') + { + $status = 'draft'; + if(!empty($params['needNotReview'])) $status = 'active'; + if(!empty($params['project'])) $status = 'active'; + if($this->story->checkForceReview()) $status = 'draft'; + } + elseif($method == 'change') + { + $oldStory = $this->dao->findById((int)$params['storyID'])->from(TABLE_STORY)->fetch(); + $status = $oldStory->status; + if($params['changed'] and $oldStory->status == 'active' and empty($params['needNotReview'])) $status = 'changed'; + if($params['changed'] and $oldStory->status == 'active' and $this->story->checkForceReview()) $status = 'changed'; + if($params['changed'] and $oldStory->status == 'draft' and $params['needNotReview']) $status = 'active'; + } + elseif($method == 'review') + { + $oldStory = $this->dao->findById((int)$params['storyID'])->from(TABLE_STORY)->fetch(); + $status = $oldStory->status; + if($params['result'] == 'pass' and $oldStory->status == 'draft') $status = 'active'; + if($params['result'] == 'pass' and $oldStory->status == 'changed') $status = 'active'; + if($params['result'] == 'revert') $status = 'active'; + if($params['result'] == 'reject') $status = 'closed'; + } + die($status); + } } diff --git a/module/story/js/change.js b/module/story/js/change.js index e4b512c5a8..b94ee6d026 100644 --- a/module/story/js/change.js +++ b/module/story/js/change.js @@ -3,8 +3,30 @@ $(function() $('#needNotReview').on('change', function() { $('#assignedTo').attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); + getStatus('change', "storyID=" + storyID + ",changed=" + changed + ",needNotReview=" + ($(this).prop('checked') ? 1 : 0)); }); $('#needNotReview').change(); + $specBox = $('#spec').closest('td').find('.ke-container iframe.ke-edit-iframe').contents().find('.article-content'); + $verifyBox = $('#verify').closest('td').find('.ke-container iframe.ke-edit-iframe').contents().find('.article-content'); + $('#title').change(function() + { + newChanged = ($(this).val() != oldStoryTitle || $specBox.html() != oldStorySpec || $verifyBox.html() != oldStoryVerify || $('.file-input-list .file-input.normal').length > 0) ? 1 : 0; + if(changed != newChanged) + { + changed = newChanged; + getStatus('change', "storyID=" + storyID + ",changed=" + changed + ",needNotReview=" + ($('#needNotReview').prop('checked') ? 1 : 0)); + } + }); + $('.ke-container iframe.ke-edit-iframe').contents().find('.article-content').keyup(function() + { + newChanged = ($('#title').val() != oldStoryTitle || $specBox.html() != oldStorySpec || $verifyBox.html() != oldStoryVerify || $('.file-input-list .file-input.normal').length > 0) ? 1 : 0; + if(changed != newChanged) + { + changed = newChanged; + getStatus('change', "storyID=" + storyID + ",changed=" + changed + ",needNotReview=" + ($('#needNotReview').prop('checked') ? 1 : 0)); + } + }); + if($('.tabs .tab-content .tab-pane.active').children().length == 0) $('.tabs .nav-tabs li.active').css('border-bottom', '1px solid #ccc'); }); diff --git a/module/story/js/common.js b/module/story/js/common.js new file mode 100644 index 0000000000..87c3fd50e4 --- /dev/null +++ b/module/story/js/common.js @@ -0,0 +1,14 @@ +function getStatus(method, params) +{ + $.get(createLink('story', 'ajaxGetStatus', "method=" + method + '¶ms=' + params), function(status) + { + if($('form #status').length == 0) + { + $('form').append(""); + } + else + { + $('form #status').val(status); + } + }); +} diff --git a/module/story/js/create.js b/module/story/js/create.js index 9c838d5288..c1f5f5bb8a 100644 --- a/module/story/js/create.js +++ b/module/story/js/create.js @@ -3,6 +3,7 @@ $(function() $('#needNotReview').on('change', function() { $('#assignedTo').attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); + getStatus('create', "product=" + $('#product').val() + ",project=" + projectID + ",needNotReview=" + ($(this).prop('checked') ? 1 : 0)); }); $('#needNotReview').change(); diff --git a/module/story/js/review.js b/module/story/js/review.js index 3f85da5153..a609560c51 100644 --- a/module/story/js/review.js +++ b/module/story/js/review.js @@ -33,6 +33,8 @@ function switchShow(result) $('#assignedTo').val(assignedTo); $('#assignedTo').trigger("chosen:updated"); } + + getStatus('review', "storyID=" + storyID + ",result=" + result); } function setStory(reason) diff --git a/module/story/view/change.html.php b/module/story/view/change.html.php index b8821e3f05..33a9498b9f 100644 --- a/module/story/view/change.html.php +++ b/module/story/view/change.html.php @@ -78,4 +78,9 @@ +id);?> +title);?> +spec);?> +verify);?> + diff --git a/module/story/view/close.html.php b/module/story/view/close.html.php index 3208de9fc9..ad08605ac3 100644 --- a/module/story/view/close.html.php +++ b/module/story/view/close.html.php @@ -44,6 +44,7 @@