Show project name in task forms
This commit is contained in:
@@ -3,6 +3,7 @@ Version 1.0.33 (unreleased)
|
|||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
* Show project name in task forms
|
||||||
* Convert vanilla CSS to SASS
|
* Convert vanilla CSS to SASS
|
||||||
|
|
||||||
Version 1.0.32
|
Version 1.0.32
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Kanboard\Controller;
|
namespace Kanboard\Controller;
|
||||||
|
|
||||||
|
use Kanboard\Core\Controller\PageNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task Creation Controller
|
* Task Creation Controller
|
||||||
*
|
*
|
||||||
@@ -14,9 +16,9 @@ class TaskCreationController extends BaseController
|
|||||||
* Display a form to create a new task
|
* Display a form to create a new task
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $values
|
* @param array $values
|
||||||
* @param array $errors
|
* @param array $errors
|
||||||
* @throws \Kanboard\Core\Controller\PageNotFoundException
|
* @throws PageNotFoundException
|
||||||
*/
|
*/
|
||||||
public function show(array $values = array(), array $errors = array())
|
public function show(array $values = array(), array $errors = array())
|
||||||
{
|
{
|
||||||
@@ -24,15 +26,7 @@ class TaskCreationController extends BaseController
|
|||||||
$swimlanes_list = $this->swimlaneModel->getList($project['id'], false, true);
|
$swimlanes_list = $this->swimlaneModel->getList($project['id'], false, true);
|
||||||
|
|
||||||
if (empty($values)) {
|
if (empty($values)) {
|
||||||
$values = array(
|
$values = $this->prepareValues($swimlanes_list);
|
||||||
'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)),
|
|
||||||
'column_id' => $this->request->getIntegerParam('column_id'),
|
|
||||||
'color_id' => $this->colorModel->getDefaultColor(),
|
|
||||||
'owner_id' => $this->userSession->getId(),
|
|
||||||
);
|
|
||||||
|
|
||||||
$values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
|
|
||||||
$values = $this->hook->merge('controller:task-creation:form:default', $values, array('default_values' => $values));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->html($this->template->render('task_creation/show', array(
|
$this->response->html($this->template->render('task_creation/show', array(
|
||||||
@@ -43,7 +37,6 @@ class TaskCreationController extends BaseController
|
|||||||
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id'], true, false, true),
|
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id'], true, false, true),
|
||||||
'categories_list' => $this->categoryModel->getList($project['id']),
|
'categories_list' => $this->categoryModel->getList($project['id']),
|
||||||
'swimlanes_list' => $swimlanes_list,
|
'swimlanes_list' => $swimlanes_list,
|
||||||
'title' => $project['name'].' > '.t('New task')
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,17 +54,17 @@ class TaskCreationController extends BaseController
|
|||||||
|
|
||||||
if ($valid && $this->taskCreationModel->create($values)) {
|
if ($valid && $this->taskCreationModel->create($values)) {
|
||||||
$this->flash->success(t('Task created successfully.'));
|
$this->flash->success(t('Task created successfully.'));
|
||||||
return $this->afterSave($project, $values);
|
$this->afterSave($project, $values);
|
||||||
|
} else {
|
||||||
|
$this->flash->failure(t('Unable to create your task.'));
|
||||||
|
$this->show($values, $errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->flash->failure(t('Unable to create your task.'));
|
|
||||||
return $this->show($values, $errors);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function afterSave(array $project, array &$values)
|
private function afterSave(array $project, array &$values)
|
||||||
{
|
{
|
||||||
if (isset($values['another_task']) && $values['another_task'] == 1) {
|
if (isset($values['another_task']) && $values['another_task'] == 1) {
|
||||||
return $this->show(array(
|
$this->show(array(
|
||||||
'owner_id' => $values['owner_id'],
|
'owner_id' => $values['owner_id'],
|
||||||
'color_id' => $values['color_id'],
|
'color_id' => $values['color_id'],
|
||||||
'category_id' => isset($values['category_id']) ? $values['category_id'] : 0,
|
'category_id' => isset($values['category_id']) ? $values['category_id'] : 0,
|
||||||
@@ -79,8 +72,29 @@ class TaskCreationController extends BaseController
|
|||||||
'swimlane_id' => isset($values['swimlane_id']) ? $values['swimlane_id'] : 0,
|
'swimlane_id' => isset($values['swimlane_id']) ? $values['swimlane_id'] : 0,
|
||||||
'another_task' => 1,
|
'another_task' => 1,
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
$this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id'])), true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id'])), true);
|
/**
|
||||||
|
* Prepare form values
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
* @param array $swimlanes_list
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareValues(array $swimlanes_list)
|
||||||
|
{
|
||||||
|
$values = array(
|
||||||
|
'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)),
|
||||||
|
'column_id' => $this->request->getIntegerParam('column_id'),
|
||||||
|
'color_id' => $this->colorModel->getDefaultColor(),
|
||||||
|
'owner_id' => $this->userSession->getId(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
|
||||||
|
$values = $this->hook->merge('controller:task-creation:form:default', $values, array('default_values' => $values));
|
||||||
|
return $values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ class TaskGanttCreationController extends BaseController
|
|||||||
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id'], true, false, true),
|
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id'], true, false, true),
|
||||||
'categories_list' => $this->categoryModel->getList($project['id']),
|
'categories_list' => $this->categoryModel->getList($project['id']),
|
||||||
'swimlanes_list' => $this->swimlaneModel->getList($project['id'], false, true),
|
'swimlanes_list' => $this->swimlaneModel->getList($project['id'], false, true),
|
||||||
'title' => $project['name'].' > '.t('New task')
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,17 +53,12 @@ class TaskGanttCreationController extends BaseController
|
|||||||
|
|
||||||
list($valid, $errors) = $this->taskValidator->validateCreation($values);
|
list($valid, $errors) = $this->taskValidator->validateCreation($values);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid && $this->taskCreationModel->create($values)) {
|
||||||
$task_id = $this->taskCreationModel->create($values);
|
$this->flash->success(t('Task created successfully.'));
|
||||||
|
$this->response->redirect($this->helper->url->to('TaskGanttController', 'show', array('project_id' => $project['id'])));
|
||||||
if ($task_id !== false) {
|
} else {
|
||||||
$this->flash->success(t('Task created successfully.'));
|
$this->flash->failure(t('Unable to create your task.'));
|
||||||
return $this->response->redirect($this->helper->url->to('TaskGanttController', 'show', array('project_id' => $project['id'])));
|
$this->show($values, $errors);
|
||||||
} else {
|
|
||||||
$this->flash->failure(t('Unable to create your task.'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->show($values, $errors);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,7 @@ class TaskModificationController extends BaseController
|
|||||||
$project = $this->projectModel->getById($task['project_id']);
|
$project = $this->projectModel->getById($task['project_id']);
|
||||||
|
|
||||||
if (empty($values)) {
|
if (empty($values)) {
|
||||||
$values = $task;
|
$values = $this->prepareValues($task);
|
||||||
$values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
|
|
||||||
$values = $this->hook->merge('controller:task-modification:form:default', $values, array('default_values' => $values));
|
|
||||||
$values = $this->dateParser->format($values, array('date_due'), $this->dateParser->getUserDateFormat());
|
|
||||||
$values = $this->dateParser->format($values, array('date_started'), $this->dateParser->getUserDateTimeFormat());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->html($this->template->render('task_modification/show', array(
|
$this->response->html($this->template->render('task_modification/show', array(
|
||||||
@@ -75,4 +71,22 @@ class TaskModificationController extends BaseController
|
|||||||
$this->edit($values, $errors);
|
$this->edit($values, $errors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare form values
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
* @param array $task
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareValues(array $task)
|
||||||
|
{
|
||||||
|
$values = $task;
|
||||||
|
$values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
|
||||||
|
$values = $this->hook->merge('controller:task-modification:form:default', $values, array('default_values' => $values));
|
||||||
|
$values = $this->dateParser->format($values, array('date_due'), $this->dateParser->getUserDateFormat());
|
||||||
|
$values = $this->dateParser->format($values, array('date_started'), $this->dateParser->getUserDateTimeFormat());
|
||||||
|
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('New task') ?></h2>
|
<h2><?= $this->text->e($project['name']) ?> > <?= t('New task') ?></h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form class="popover-form" method="post" action="<?= $this->url->href('TaskCreationController', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
|
<form class="popover-form" method="post" action="<?= $this->url->href('TaskCreationController', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('New task') ?></h2>
|
<h2><?= $this->text->e($project['name']) ?> > <?= t('New task') ?></h2>
|
||||||
</div>
|
</div>
|
||||||
<form method="post" action="<?= $this->url->href('TaskGanttCreationController', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
|
<form class="popover-form" method="post" action="<?= $this->url->href('TaskGanttCreationController', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
|
||||||
<?= $this->form->csrf() ?>
|
<?= $this->form->csrf() ?>
|
||||||
<?= $this->form->hidden('project_id', $values) ?>
|
<?= $this->form->hidden('project_id', $values) ?>
|
||||||
<?= $this->form->hidden('column_id', $values) ?>
|
<?= $this->form->hidden('column_id', $values) ?>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('Edit a task') ?></h2>
|
<h2><?= $this->text->e($project['name']) ?> > <?= $this->text->e($task['title']) ?></h2>
|
||||||
</div>
|
</div>
|
||||||
<form class="popover-form" method="post" action="<?= $this->url->href('TaskModificationController', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
|
<form class="popover-form" method="post" action="<?= $this->url->href('TaskModificationController', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
|
||||||
<?= $this->form->csrf() ?>
|
<?= $this->form->csrf() ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user