From 6547d09a913b00270783d14785a79f0076cc6ec9 Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Tue, 23 Feb 2021 10:31:01 +0800 Subject: [PATCH] * Finish task#36046. --- module/upgrade/js/mergeprogram.js | 36 +++++++++++++- module/upgrade/model.php | 58 ++++++++++++---------- module/upgrade/view/createprogram.html.php | 4 +- 3 files changed, 69 insertions(+), 29 deletions(-) diff --git a/module/upgrade/js/mergeprogram.js b/module/upgrade/js/mergeprogram.js index 14ba9e89b2..60007daeb3 100644 --- a/module/upgrade/js/mergeprogram.js +++ b/module/upgrade/js/mergeprogram.js @@ -93,6 +93,8 @@ $(function() setPGMBegin(PGMBegin); setPGMEnd(PGMEnd); setPRJPM(); + + hiddenProject(); }) $('[name^=sprints]').change(function() @@ -108,10 +110,14 @@ $(function() setPGMBegin(PGMBegin); setPGMEnd(PGMEnd); setPRJPM(); + + hiddenProject(); }) toggleProgram($('form #newProgram0')); toggleProject($('form #newProject0')); + + hiddenProject(); }); function getProjectByProgram(obj) @@ -140,7 +146,7 @@ function toggleProgram(obj) $('form .pgm-no-exist').removeClass('hidden'); $('form .pgm-exist').addClass('hidden'); $programs.attr('disabled', 'disabled'); - $('#PGMStatus').closest('.PGMParams').show(); + $('.PGMStatus').show(); $('form #newProject0').prop('checked', true); toggleProject($('form #newProject0')); @@ -149,7 +155,7 @@ function toggleProgram(obj) { $('form .pgm-exist').removeClass('hidden'); $('form .pgm-no-exist').addClass('hidden'); - $('#PGMStatus').closest('.PGMParams').hide(); + $('.PGMStatus').hide(); $programs.removeAttr('disabled'); } } @@ -183,6 +189,32 @@ function toggleProject(obj) } } +function hiddenProject() +{ + if($('[name^=sprints]:checked').length == 0) + { + $(".PGMParams input").attr('disabled' ,'disabled'); + $(".PGMParams select").attr('disabled' ,'disabled').trigger('chosen:updated'); + $('.PGMParams').hide(); + + $(".PRJName input").attr('disabled' ,'disabled'); + $(".PRJName select").attr('disabled' ,'disabled').trigger('chosen:updated'); + $('.PRJName').hide(); + } + else + { + $(".PRJName input").removeAttr('disabled'); + $(".PRJName select").removeAttr('disabled').trigger('chosen:updated'); + $('.PRJName').show(); + + $(".PGMParams input").removeAttr('disabled'); + $(".PGMParams select").removeAttr('disabled').trigger('chosen:updated'); + $('.PGMParams').show(); + + if($('#newProject0').is(':checked')) $('#projects').attr('disabled', 'disabled'); + } +} + function setPRJStatus() { var PRJStatus = 'closed'; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 0a2dad7a67..173c847091 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -3992,15 +3992,13 @@ class upgradeModel extends model if(!isset($data->programs)) { - if(!$this->post->longTime and !$this->post->end) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->program->end))); - /* Insert program. */ $program = new stdclass(); $program->name = $data->PGMName; $program->type = 'program'; $program->status = $data->PGMStatus; - $program->begin = $data->begin; - $program->end = isset($data->end) ? $data->end : ''; + $program->begin = isset($data->begin) ? $data->begin : helper::now(); + $program->end = isset($data->end) ? $data->end : LONG_TIME; $program->openedBy = $account; $program->openedDate = helper::now(); $program->openedVersion = $this->config->version; @@ -4032,6 +4030,8 @@ class upgradeModel extends model $programID = $data->programs; } + if(!isset($data->sprints)) return array($programID); + if(!isset($data->projects)) { if(!$this->post->longTime and !$this->post->end) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->program->end))); @@ -4044,7 +4044,7 @@ class upgradeModel extends model $project->parent = $programID; $project->status = $data->PRJStatus; $project->begin = $data->begin; - $project->end = isset($data->end) ? $data->end : ''; + $project->end = isset($data->end) ? $data->end : LONG_TIME; $project->PM = $data->PM; $project->auth = 'extend'; $project->openedBy = $account; @@ -4054,6 +4054,10 @@ class upgradeModel extends model $this->lang->project->name = $this->lang->program->PRJName; + $programDate = $this->dao->select('begin,end')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch(); + if($data->begin < $programDate->begin) $this->dao->update(TABLE_PROGRAM)->set('begin')->eq($data->begin)->where('id')->eq($programID)->exec(); + if($data->end > $programDate->end) $this->dao->update(TABLE_PROGRAM)->set('end')->eq($data->end)->where('id')->eq($programID)->exec(); + $this->dao->insert(TABLE_PROJECT)->data($project) ->batchcheck('name', 'notempty') ->check('name', 'unique', "deleted='0' and type = 'project'") @@ -4090,11 +4094,33 @@ class upgradeModel extends model */ public function processMergedData($programID, $projectID, $productIdList = array(), $sprintIdList = array()) { - if(!$projectID) die(js::alert($this->lang->upgrade->projectEmpty)); - /* Product linked objects. */ $this->dao->update(TABLE_STORY)->set('PRJ')->eq($programID)->where('product')->in($productIdList)->exec(); $this->dao->update(TABLE_RELEASE)->set('PRJ')->eq($programID)->where('product')->in($productIdList)->exec(); + + /* Compute product acl. */ + $products = $this->dao->select('id,program,acl')->from(TABLE_PRODUCT)->where('id')->in($productIdList)->fetchAll(); + foreach($products as $product) + { + if($product->program) continue; + + $data = new stdclass(); + $data->program = $programID; + $data->acl = $product->acl == 'custom' ? 'private' : $product->acl; + + $this->dao->update(TABLE_PRODUCT)->data($data)->where('id')->eq($product->id)->exec(); + } + + /* Compute program status. */ + $PGMStatus = $this->computeStatus($programID); + $this->dao->update(TABLE_PROJECT)->set('status')->eq($PGMStatus)->where('id')->eq($programID)->exec(); + if($PGMStatus == 'closed') $this->loadModel('action')->create('program', $programID, 'closedbysystem'); + + /* No project is created when there are no sprints. */ + if(!$sprintIdList) return; + + if(!$projectID) die(js::alert($this->lang->upgrade->projectEmpty)); + $this->dao->update(TABLE_BUG)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); $this->dao->update(TABLE_CASE)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); $this->dao->update(TABLE_TESTREPORT)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); @@ -4118,19 +4144,6 @@ class upgradeModel extends model $this->dao->replace(TABLE_PROJECTSTORY)->data($projectStory)->exec(); } - /* Compute product acl. */ - $products = $this->dao->select('id,program,acl')->from(TABLE_PRODUCT)->where('id')->in($productIdList)->fetchAll(); - foreach($products as $product) - { - if($product->program) continue; - - $data = new stdclass(); - $data->program = $programID; - $data->acl = $product->acl == 'custom' ? 'private' : $product->acl; - - $this->dao->update(TABLE_PRODUCT)->data($data)->where('id')->eq($product->id)->exec(); - } - /* Compute sprint path and grade. */ $sprints = $this->dao->select('id, type, acl')->from(TABLE_PROJECT)->where('id')->in($sprintIdList)->fetchAll(); foreach($sprints as $sprint) @@ -4167,11 +4180,6 @@ class upgradeModel extends model $this->dao->update(TABLE_PROJECT)->data($data)->where('id')->eq($projectID)->exec(); if($PRJStatus == 'closed') $this->loadModel('action')->create('project', $projectID, 'closedbysystem'); - /* Compute program status. */ - $PGMStatus = $this->computeStatus($programID); - $this->dao->update(TABLE_PROJECT)->set('status')->eq($PGMStatus)->where('id')->eq($programID)->exec(); - if($PGMStatus == 'closed') $this->loadModel('action')->create('program', $programID, 'closedbysystem'); - /* Set product and project relation. */ foreach($productIdList as $productID) { diff --git a/module/upgrade/view/createprogram.html.php b/module/upgrade/view/createprogram.html.php index 4c0369e48e..81bb12dc8f 100644 --- a/module/upgrade/view/createprogram.html.php +++ b/module/upgrade/view/createprogram.html.php @@ -20,11 +20,11 @@ - + program->PGMCommon . $lang->program->PGMStatus;?> program->statusList, '', "class='form-control chosen'");?> - + program->PRJName;?>