Use task description templates in bulk task creation

This commit is contained in:
Frederic Guillot 2017-11-03 10:57:00 -07:00
parent 78a2d3142c
commit e6f8a76a18
32 changed files with 54 additions and 2 deletions

View File

@ -35,6 +35,7 @@ class TaskBulkController extends BaseController
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id'], true, false, $project['is_private'] == 1),
'colors_list' => $this->colorModel->getList(),
'categories_list' => $this->categoryModel->getList($project['id']),
'task_description_templates' => $this->predefinedTaskDescriptionModel->getList($project['id']),
)));
}
@ -85,8 +86,18 @@ class TaskBulkController extends BaseController
'owner_id' => empty($values['owner_id']) ? 0 : $values['owner_id'],
'color_id' => $values['color_id'],
'project_id' => $project['id'],
'description' => $this->getTaskDescription($project, $values),
));
}
}
}
protected function getTaskDescription(array $project, array $values)
{
if (empty($values['task_description_template_id'])) {
return '';
}
return $this->predefinedTaskDescriptionModel->getDescriptionById($project['id'], $values['task_description_template_id']);
}
}

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
'Template removed successfully.' => 'Modèle supprimé avec succès.',
'Unable to remove this template.' => 'Impossible de supprimer ce modèle.',
'Description Templates' => 'Modèles de description',
'Template for the task description' => 'Modèle pour la description des tâches',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1362,4 +1362,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -1356,4 +1356,5 @@ return array(
// 'Template removed successfully.' => '',
// 'Unable to remove this template.' => '',
// 'Description Templates' => '',
// 'Template for the task description' => '',
);

View File

@ -13,11 +13,21 @@ class PredefinedTaskDescriptionModel extends Base
return $this->db->table(self::TABLE)->eq('project_id', $projectId)->findAll();
}
public function getList($projectId)
{
return array('' => t('None')) + $this->db->hashtable(self::TABLE)->eq('project_id', $projectId)->getAll('id', 'title');
}
public function getById($projectId, $id)
{
return $this->db->table(self::TABLE)->eq('project_id', $projectId)->eq('id', $id)->findOne();
}
public function getDescriptionById($projectId, $id)
{
return $this->db->table(self::TABLE)->eq('project_id', $projectId)->eq('id', $id)->findOneColumn('description');
}
public function create($projectId, $title, $description)
{
return $this->db->table(self::TABLE)->persist(array(

View File

@ -6,12 +6,16 @@
<?= $this->form->csrf() ?>
<?= $this->form->hidden('column_id', $values) ?>
<?= $this->form->hidden('swimlane_id', $values) ?>
<?= $this->form->hidden('project_id', $values) ?>
<?= $this->task->renderColorField($values) ?>
<?= $this->task->renderAssigneeField($users_list, $values, $errors) ?>
<?= $this->task->renderCategoryField($categories_list, $values, $errors) ?>
<?php if (! empty($task_description_templates)): ?>
<?= $this->form->label(t('Template for the task description'), 'task_description_template_id') ?>
<?= $this->form->select('task_description_template_id', $task_description_templates, $values, $errors) ?>
<?php endif ?>
<?= $this->form->label(t('Tasks'), 'tasks') ?>
<?= $this->form->textarea('tasks', $values, $errors, array('placeholder="'.t('My task title').'"')) ?>
<p class="form-help"><?= t('Enter one task by line.') ?></p>

View File

@ -81,7 +81,6 @@ class TaskValidator extends BaseValidator
public function validateBulkCreation(array $values)
{
$rules = array(
new Validators\Required('project_id', t('The project is required')),
new Validators\Required('tasks', t('Field required')),
new Validators\Required('column_id', t('Field required')),
new Validators\Required('swimlane_id', t('Field required')),