From 5ebceea09a114788d74667c1be5f3bb23edb26bf Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 20 Dec 2018 17:16:50 +0800 Subject: [PATCH] * add project field for create task. --- module/task/control.php | 2 + module/task/js/create.js | 68 ++++++++++++++++++++++++++++++++ module/task/model.php | 2 +- module/task/view/create.html.php | 4 ++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/module/task/control.php b/module/task/control.php index 46ecb8b6f2..a033b93da1 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -92,6 +92,7 @@ class task extends control $response['result'] = 'success'; $response['message'] = ''; + if($this->post->project) $projectID = $this->post->project; $tasksID = $this->task->create($projectID); if(dao::isError()) { @@ -191,6 +192,7 @@ class task extends control $this->view->title = $title; $this->view->position = $position; $this->view->project = $project; + $this->view->projects = $this->loadModel('project')->getPairs(); $this->view->task = $task; $this->view->users = $users; $this->view->stories = $stories; diff --git a/module/task/js/create.js b/module/task/js/create.js index 946a40201b..576d6d7545 100644 --- a/module/task/js/create.js +++ b/module/task/js/create.js @@ -1,3 +1,71 @@ +/** + * Load module, stories and members. + * + * @param int $projectID + * @access public + * @return void + */ +function loadAll(projectID) +{ + loadModuleMenu(projectID); + loadProjectStories(projectID); + loadProjectMembers(projectID); +} + +/** + * Load team members of the project. + * + * @param int $projectID + * @access public + * @return void + */ +function loadProjectMembers(projectID) +{ + $.get(createLink('project', 'ajaxGetMembers', 'projectID=' + projectID + '&assignedTo=' + $('#assignedTo').val()), function(data) + { + $('#assignedTo_chosen').remove(); + $('#assignedTo').replaceWith(data); + $('#assignedTo').attr('name', 'assignedTo[]').chosen(); + + $('.modal-dialog #taskTeamEditor tr').each(function() + { + $(this).find('#team_chosen').remove(); + $(this).find('#team').replaceWith(data); + $(this).find('#assignedTo').attr('id', 'team').attr('name', 'team[]').chosen(); + }); + }); +} + +/** + * Load stories of the project. + * + * @param int $projectID + * @access public + * @return void + */ +function loadProjectStories(projectID) +{ + $.get(createLink('story', 'ajaxGetProjectStories', 'projectID=' + projectID + '&productID=0&branch=0&moduleID=0&storyID=' + $('#story').val()), function(data) + { + $('#story_chosen').remove(); + $('#story').replaceWith(data); + $('#story').chosen(); + }); +} + +/** + * Load module of the project. + * + * @param int $projectID + * @access public + * @return void + */ +function loadModuleMenu(projectID) +{ + var link = createLink('tree', 'ajaxGetOptionMenu', 'rootID=' + projectID + '&viewtype=task'); + $('#moduleIdBox').load(link, function(){$('#module').chosen();}); +} + /* Copy story title as task title. */ function copyStoryTitle() { diff --git a/module/task/model.php b/module/task/model.php index 501ec23d8d..fe042c3a73 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -26,7 +26,7 @@ class taskModel extends model $taskFiles = array(); $this->loadModel('file'); $task = fixer::input('post') - ->add('project', (int)$projectID) + ->setDefault('project', (int)$projectID) ->setDefault('estimate, left, story', 0) ->setDefault('status', 'wait') ->setIF($this->post->estimate != false, 'left', $this->post->estimate) diff --git a/module/task/view/create.html.php b/module/task/view/create.html.php index 8814db76a2..cdcf1acdb6 100644 --- a/module/task/view/create.html.php +++ b/module/task/view/create.html.php @@ -26,6 +26,10 @@
+ + + +
task->project;?>id, "class='form-control chosen' onchange='loadAll(this.value)' required");?>
task->type;?> task->typeList, $task->type, "class='form-control chosen' onchange='setOwners(this.value)' required");?>