Add bulk task modification in list view

This commit is contained in:
Frédéric Guillot 2018-06-06 11:07:12 -07:00
parent 653128cdb4
commit 2a299d33d1
39 changed files with 265 additions and 3 deletions

View File

@ -0,0 +1,83 @@
<?php
namespace Kanboard\Controller;
use Kanboard\Core\Controller\AccessForbiddenException;
class TaskBulkChangePropertyController extends BaseController
{
public function show(array $values = [], array $errors = [])
{
$project = $this->getProject();
if (empty($values)) {
$values['task_ids'] = $this->request->getStringParam('task_ids');
}
$this->response->html($this->template->render('task_bulk_change_property/show', [
'project' => $project,
'values' => $values,
'errors' => $errors,
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']),
'categories_list' => $this->categoryModel->getList($project['id']),
]));
}
public function save()
{
$project = $this->getProject();
$values = $this->request->getValues();
$taskIDs = explode(',', $values['task_ids']);
foreach ($taskIDs as $taskID) {
$changes = [];
if (isset($values['change_color']) && $values['change_color'] == 1) {
$changes['color_id'] = $values['color_id'];
}
if (isset($values['change_assignee']) && $values['change_assignee'] == 1) {
$changes['owner_id'] = $values['owner_id'];
}
if (isset($values['change_priority']) && $values['change_priority'] == 1) {
$changes['priority'] = $values['priority'];
}
if (isset($values['change_category']) && $values['change_category'] == 1) {
$changes['category_id'] = $values['category_id'];
}
if (isset($values['change_tags']) && $values['change_tags'] == 1) {
$changes['tags'] = $values['tags'];
}
if (isset($values['change_due_date']) && $values['change_due_date'] == 1) {
$changes['date_due'] = $values['date_due'];
}
if (isset($values['change_start_date']) && $values['change_start_date'] == 1) {
$changes['date_started'] = $values['date_started'];
}
if (isset($values['change_estimated_time']) && $values['change_estimated_time'] == 1) {
$changes['time_estimated'] = $values['time_estimated'];
}
if (isset($values['change_spent_time']) && $values['change_spent_time'] == 1) {
$changes['time_spent'] = $values['time_spent'];
}
if (isset($values['change_score']) && $values['change_score'] == 1) {
$changes['score'] = $values['score'];
}
if (! empty($changes)) {
$changes['id'] = $taskID;
$this->taskModificationModel->update($changes);
}
}
$this->response->redirect($this->helper->url->to('TaskListController', 'show', ['project_id' => $project['id']]), true);
}
}

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
'Unselect All' => 'Tout désélectionner',
'Apply action' => 'Appliquer une action',
'Move selected tasks to another column' => 'Déplaçer les tâches sélectionnées vers une autre colonne',
'Edit tasks in bulk' => 'Modifier les tâches en masse',
'Choose the properties that you would to change for the selected tasks.' => 'Choisissez les propriétés que vous souhaitez changer pour les tâches sélectionnées.',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
'Unselect All' => 'Снять выделение со всех',
'Apply action' => 'Применить действие',
'Move selected tasks to another column' => 'Переместить выбранные задачи в другую колонку',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -1381,4 +1381,6 @@ return array(
// 'Unselect All' => '',
// 'Apply action' => '',
// 'Move selected tasks to another column' => '',
// 'Edit tasks in bulk' => '',
// 'Choose the properties that you would to change for the selected tasks.' => '',
);

View File

@ -107,6 +107,7 @@ class AuthenticationProvider implements ServiceProviderInterface
$acl->add('TaskCreationController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskBulkController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskBulkMoveColumnController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskBulkChangePropertyController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskDuplicationController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskRecurrenceController', '*', Role::PROJECT_MEMBER);
$acl->add('TaskImportController', '*', Role::PROJECT_MANAGER);

View File

@ -0,0 +1,102 @@
<div class="page-header">
<h2><?= t('Edit tasks in bulk') ?></h2>
</div>
<form action="<?= $this->url->href('TaskBulkChangePropertyController', 'save', ['project_id' => $project['id']]) ?>" method="post">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('task_ids', $values) ?>
<p class="form-help"><?= t('Choose the properties that you would to change for the selected tasks.') ?></p>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_color" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderColorField($values) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_assignee" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderAssigneeField($users_list, $values, $errors) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_priority" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderPriorityField($project, $values) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_category" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderCategoryField($categories_list, $values, $errors, [], true) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_tags" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderTagField($project) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_due_date" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderDueDateField($values, $errors) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_start_date" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderStartDateField($values, $errors) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_estimated_time" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderTimeEstimatedField($values, $errors) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_spent_time" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderTimeSpentField($values, $errors) ?>
</div>
</fieldset>
<fieldset class="bulk-change-block">
<div class="bulk-change-checkbox">
<input type="checkbox" name="change_score" value="1">
</div>
<div class="bulk-change-inputs">
<?= $this->task->renderScoreField($values, $errors) ?>
</div>
</fieldset>
<?= $this->modal->submitButtons() ?>
</form>

View File

@ -19,6 +19,9 @@
<li>
<a href="<?= $this->url->href('TaskBulkMoveColumnController', 'show', ['project_id' => $project['id']]) ?>" data-list-item-action="modal"><?= t('Move selected tasks to another column') ?></a>
</li>
<li>
<a href="<?= $this->url->href('TaskBulkChangePropertyController', 'show', ['project_id' => $project['id']]) ?>" data-list-item-action="modal"><?= t('Edit tasks in bulk') ?></a>
</li>
</ul>
</div>
</div>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
.bulk-change-checkbox
float: left
.bulk-change-inputs
float: left
padding-left: 10px
label
margin-top: 0
margin-bottom: 3px

View File

@ -2,8 +2,8 @@
@import mixins
fieldset
border: 1px solid #ccc
margin-top: 20px
border: 1px solid #ddd
margin-top: 10px
legend
font-weight: 500

View File

@ -53,3 +53,4 @@
@import user_mentions
@import image_slideshow
@import list_items
@import bulk_change