Merge and modification of pull-request #785
This commit is contained in:
@@ -197,7 +197,7 @@ class Board extends Base
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$this->response->html($this->template->render('board/tasklinks', array(
|
||||
'links' => $this->taskLink->getLinks($task['id']),
|
||||
'links' => $this->taskLink->getAll($task['id']),
|
||||
'task' => $task,
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class Task extends Base
|
||||
'project' => $project,
|
||||
'comments' => $this->comment->getAll($task['id']),
|
||||
'subtasks' => $this->subtask->getAll($task['id']),
|
||||
'links' => $this->taskLink->getLinks($task['id']),
|
||||
'links' => $this->taskLink->getAllGroupedByLabel($task['id']),
|
||||
'task' => $task,
|
||||
'columns_list' => $this->board->getColumnsList($task['project_id']),
|
||||
'colors_list' => $this->color->getList(),
|
||||
@@ -72,7 +72,7 @@ class Task extends Base
|
||||
'images' => $this->file->getAllImages($task['id']),
|
||||
'comments' => $this->comment->getAll($task['id']),
|
||||
'subtasks' => $subtasks,
|
||||
'links' => $this->taskLink->getLinks($task['id']),
|
||||
'links' => $this->taskLink->getAllGroupedByLabel($task['id']),
|
||||
'task' => $task,
|
||||
'values' => $values,
|
||||
'link_label_list' => $this->link->getList(0, false),
|
||||
|
||||
@@ -38,13 +38,7 @@ class Tasklink extends Base
|
||||
$task = $this->getTask();
|
||||
$ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
|
||||
|
||||
if (empty($values)) {
|
||||
$values = array(
|
||||
'task_id' => $task['id'],
|
||||
);
|
||||
}
|
||||
|
||||
if ($ajax) {
|
||||
if ($ajax && empty($errors)) {
|
||||
$this->response->html($this->template->render('tasklink/create', array(
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
@@ -81,19 +75,72 @@ class Tasklink extends Base
|
||||
|
||||
if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
|
||||
$this->session->flash(t('Link added successfully.'));
|
||||
|
||||
if ($ajax) {
|
||||
$this->response->redirect($this->helper->url('board', 'show', array('project_id' => $task['project_id'])));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
|
||||
}
|
||||
else {
|
||||
$this->session->flashError(t('Unable to create your link.'));
|
||||
}
|
||||
|
||||
$errors = array('title' => array(t('The exact same link already exists')));
|
||||
$this->session->flashError(t('Unable to create your link.'));
|
||||
}
|
||||
|
||||
$this->create($values, $errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit form
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function edit(array $values = array(), array $errors = array())
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$task_link = $this->getTaskLink();
|
||||
|
||||
if (empty($values)) {
|
||||
$opposite_task = $this->taskFinder->getById($task_link['opposite_task_id']);
|
||||
$values = $task_link;
|
||||
$values['title'] = '#'.$opposite_task['id'].' - '.$opposite_task['title'];
|
||||
}
|
||||
|
||||
$this->response->html($this->taskLayout('tasklink/edit', array(
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
'task_link' => $task_link,
|
||||
'task' => $task,
|
||||
'labels' => $this->link->getList(0, false),
|
||||
'title' => t('Edit link')
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation and update
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$values = $this->request->getValues();
|
||||
|
||||
list($valid, $errors) = $this->taskLink->validateModification($values);
|
||||
|
||||
if ($valid) {
|
||||
|
||||
if ($this->taskLink->update($values['id'], $values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
|
||||
$this->session->flash(t('Link updated successfully.'));
|
||||
$this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
|
||||
}
|
||||
|
||||
$this->session->flashError(t('Unable to update your link.'));
|
||||
}
|
||||
|
||||
$this->edit($values, $errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirmation dialog before removing a link
|
||||
*
|
||||
@@ -127,6 +174,6 @@ class Tasklink extends Base
|
||||
$this->session->flashError(t('Unable to remove this link.'));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
|
||||
$this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
'Help on Sendgrid integration' => 'Hilfe bei Sendgrid-Integration',
|
||||
'Disable two factor authentication' => 'Deaktiviere Zwei-Faktor-Authentifizierung',
|
||||
'Do you really want to disable the two factor authentication for this user: "%s"?' => 'Willst du wirklich für folgenden Nutzer die Zwei-Faktor-Authentifizierung deaktivieren: "%s"?',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -614,7 +614,7 @@ return array(
|
||||
'Remove a swimlane' => 'Remover un carril',
|
||||
'Rename' => 'Renombrar',
|
||||
'Show default swimlane' => 'Mostrar carril por defecto',
|
||||
'Swimlane modification for the project "%s"' => '',
|
||||
// 'Swimlane modification for the project "%s"' => '',
|
||||
'Swimlane not found.' => 'Carril no encontrado',
|
||||
'Swimlane removed successfully.' => 'Carril removido correctamente',
|
||||
'Swimlanes' => 'Carriles',
|
||||
@@ -653,7 +653,7 @@ return array(
|
||||
'Filter by status' => 'Filtrar por estado',
|
||||
'Calendar' => 'Calendario',
|
||||
'Next' => 'Siguiente',
|
||||
'#%d' => '',
|
||||
// '#%d' => '',
|
||||
'Filter by color' => 'Filtrar por color',
|
||||
'Filter by swimlane' => 'Filtrar por carril',
|
||||
'All swimlanes' => 'Todos los carriles',
|
||||
@@ -846,8 +846,8 @@ return array(
|
||||
'Secret key: ' => 'Clave secreta: ',
|
||||
'Test your device' => 'Probar tu dispositivo',
|
||||
'Assign a color when the task is moved to a specific column' => 'Asignar un color al mover la tarea a una columna específica',
|
||||
'%s via Kanboard' => '%s vía Kanboard',
|
||||
'uploaded by: %s' => 'cargado por: %s',
|
||||
'%s via Kanboard' => '%s vía Kanboard',
|
||||
'uploaded by: %s' => 'cargado por: %s',
|
||||
'uploaded on: %s' => 'cargado en: %s',
|
||||
'size: %s' => 'tamaño: %s',
|
||||
'Burndown chart for "%s"' => 'Trabajo pendiente para "%s"',
|
||||
@@ -868,5 +868,8 @@ return array(
|
||||
'Help on Sendgrid integration' => 'Ayuda sobre la integración con Sendgrid',
|
||||
'Disable two factor authentication' => 'Desactivar la autenticación de dos factores',
|
||||
'Do you really want to disable the two factor authentication for this user: "%s"?' => '¿Realmentes quieres desactuvar la autenticación de dos factores para este usuario: "%s?"',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -719,7 +719,7 @@ return array(
|
||||
'is a child of' => 'est un enfant de',
|
||||
'is a parent of' => 'est un parent de',
|
||||
'targets milestone' => 'vise l\'étape importante',
|
||||
'is a milestone of' => 'est une étape importante de',
|
||||
'is a milestone of' => 'est une étape importante incluant',
|
||||
'fixes' => 'corrige',
|
||||
'is fixed by' => 'est corrigée par',
|
||||
'This task' => 'Cette tâche',
|
||||
@@ -870,4 +870,8 @@ return array(
|
||||
'Help on Sendgrid integration' => 'Aide sur l\'intégration avec Sendgrid',
|
||||
'Disable two factor authentication' => 'Désactiver l\'authentification à deux facteurs',
|
||||
'Do you really want to disable the two factor authentication for this user: "%s"?' => 'Voulez-vous vraiment désactiver l\'authentification à deux facteurs pour cet utilisateur : « %s » ?',
|
||||
'Edit a link' => 'Modifier un lien',
|
||||
'Start to type task title...' => 'Tappez le titre de la tâche...',
|
||||
'A task cannot be linked to itself' => 'Une tâche ne peut être liée à elle-même',
|
||||
'The exact same link already exists' => 'Un lien identique existe déjà',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
'Help on Sendgrid integration' => 'Ajuda na integração do Sendgrid',
|
||||
'Disable two factor authentication' => 'Desativar autenticação à dois fatores',
|
||||
'Do you really want to disable the two factor authentication for this user: "%s"?' => 'Você deseja realmente desativar a autenticação à dois fatores para esse usuário: "%s"?',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
'Disable two factor authentication' => 'Выключить двухфакторную авторизацию',
|
||||
'Do you really want to disable the two factor authentication for this user: "%s"?' => 'Вы действительно хотите выключить двухфакторную авторизацию для пользователя "%s"?',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -868,4 +868,8 @@ return array(
|
||||
// 'Help on Sendgrid integration' => '',
|
||||
// 'Disable two factor authentication' => '',
|
||||
// 'Do you really want to disable the two factor authentication for this user: "%s"?' => '',
|
||||
// 'Edit a link' => '',
|
||||
// 'Start to type task title...' => '',
|
||||
// 'A task cannot be linked to itself' => '',
|
||||
// 'The exact same link already exists' => '',
|
||||
);
|
||||
|
||||
@@ -34,6 +34,24 @@ class TaskLink extends Base
|
||||
return $this->db->table(self::TABLE)->eq('id', $task_link_id)->findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the opposite task link (use the unique index task_has_links_unique)
|
||||
*
|
||||
* @access public
|
||||
* @param array $task_link
|
||||
* @return array
|
||||
*/
|
||||
public function getOppositeTaskLink(array $task_link)
|
||||
{
|
||||
$opposite_link_id = $this->link->getOppositeLinkId($task_link['link_id']);
|
||||
|
||||
return $this->db->table(self::TABLE)
|
||||
->eq('opposite_task_id', $task_link['task_id'])
|
||||
->eq('task_id', $task_link['opposite_task_id'])
|
||||
->eq('link_id', $opposite_link_id)
|
||||
->findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all links attached to a task
|
||||
*
|
||||
@@ -41,7 +59,7 @@ class TaskLink extends Base
|
||||
* @param integer $task_id Task id
|
||||
* @return array
|
||||
*/
|
||||
public function getLinks($task_id)
|
||||
public function getAll($task_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(self::TABLE)
|
||||
@@ -52,16 +70,46 @@ class TaskLink extends Base
|
||||
Task::TABLE.'.title',
|
||||
Task::TABLE.'.is_active',
|
||||
Task::TABLE.'.project_id',
|
||||
Task::TABLE.'.time_spent AS task_time_spent',
|
||||
Task::TABLE.'.time_estimated AS task_time_estimated',
|
||||
Task::TABLE.'.owner_id AS task_assignee_id',
|
||||
User::TABLE.'.username AS task_assignee_username',
|
||||
User::TABLE.'.name AS task_assignee_name',
|
||||
Board::TABLE.'.title AS column_title'
|
||||
)
|
||||
->eq(self::TABLE.'.task_id', $task_id)
|
||||
->join(Link::TABLE, 'id', 'link_id')
|
||||
->join(Task::TABLE, 'id', 'opposite_task_id')
|
||||
->join(Board::TABLE, 'id', 'column_id', Task::TABLE)
|
||||
->join(User::TABLE, 'id', 'owner_id', Task::TABLE)
|
||||
->orderBy(Link::TABLE.'.id ASC, '.Board::TABLE.'.position ASC, '.Task::TABLE.'.is_active DESC, '.Task::TABLE.'.id', Table::SORT_ASC)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all links attached to a task grouped by label
|
||||
*
|
||||
* @access public
|
||||
* @param integer $task_id Task id
|
||||
* @return array
|
||||
*/
|
||||
public function getAllGroupedByLabel($task_id)
|
||||
{
|
||||
$links = $this->getAll($task_id);
|
||||
$result = array();
|
||||
|
||||
foreach ($links as $link) {
|
||||
|
||||
if (! isset($result[$link['label']])) {
|
||||
$result[$link['label']] = array();
|
||||
}
|
||||
|
||||
$result[$link['label']][] = $link;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new link
|
||||
*
|
||||
@@ -69,31 +117,76 @@ class TaskLink extends Base
|
||||
* @param integer $task_id Task id
|
||||
* @param integer $opposite_task_id Opposite task id
|
||||
* @param integer $link_id Link id
|
||||
* @return boolean
|
||||
* @return integer Task link id
|
||||
*/
|
||||
public function create($task_id, $opposite_task_id, $link_id)
|
||||
{
|
||||
$this->db->startTransaction();
|
||||
|
||||
// Create the original link
|
||||
// Get opposite link
|
||||
$opposite_link_id = $this->link->getOppositeLinkId($link_id);
|
||||
|
||||
// Create the original task link
|
||||
$this->db->table(self::TABLE)->insert(array(
|
||||
'task_id' => $task_id,
|
||||
'opposite_task_id' => $opposite_task_id,
|
||||
'link_id' => $link_id,
|
||||
));
|
||||
|
||||
$link_id = $this->link->getOppositeLinkId($link_id);
|
||||
$task_link_id = $this->db->getConnection()->getLastId();
|
||||
|
||||
// Create the opposite link
|
||||
// Create the opposite task link
|
||||
$this->db->table(self::TABLE)->insert(array(
|
||||
'task_id' => $opposite_task_id,
|
||||
'opposite_task_id' => $task_id,
|
||||
'link_id' => $link_id,
|
||||
'link_id' => $opposite_link_id,
|
||||
));
|
||||
|
||||
$this->db->closeTransaction();
|
||||
|
||||
return true;
|
||||
return $task_link_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a task link
|
||||
*
|
||||
* @access public
|
||||
* @param integer $task_link_id Task link id
|
||||
* @param integer $task_id Task id
|
||||
* @param integer $opposite_task_id Opposite task id
|
||||
* @param integer $link_id Link id
|
||||
* @return boolean
|
||||
*/
|
||||
public function update($task_link_id, $task_id, $opposite_task_id, $link_id)
|
||||
{
|
||||
$this->db->startTransaction();
|
||||
|
||||
// Get original task link
|
||||
$task_link = $this->getById($task_link_id);
|
||||
|
||||
// Find opposite task link
|
||||
$opposite_task_link = $this->getOppositeTaskLink($task_link);
|
||||
|
||||
// Get opposite link
|
||||
$opposite_link_id = $this->link->getOppositeLinkId($link_id);
|
||||
|
||||
// Update the original task link
|
||||
$rs1 = $this->db->table(self::TABLE)->eq('id', $task_link_id)->update(array(
|
||||
'task_id' => $task_id,
|
||||
'opposite_task_id' => $opposite_task_id,
|
||||
'link_id' => $link_id,
|
||||
));
|
||||
|
||||
// Update the opposite link
|
||||
$rs2 = $this->db->table(self::TABLE)->eq('id', $opposite_task_link['id'])->update(array(
|
||||
'task_id' => $opposite_task_id,
|
||||
'opposite_task_id' => $task_id,
|
||||
'link_id' => $opposite_link_id,
|
||||
));
|
||||
|
||||
$this->db->closeTransaction();
|
||||
|
||||
return $rs1 && $rs2;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,6 +216,23 @@ class TaskLink extends Base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common validation rules
|
||||
*
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
private function commonValidationRules()
|
||||
{
|
||||
return array(
|
||||
new Validators\Required('task_id', t('Field required')),
|
||||
new Validators\Required('opposite_task_id', t('Field required')),
|
||||
new Validators\Required('link_id', t('Field required')),
|
||||
new Validators\NotEquals('opposite_task_id', 'task_id', t('A task cannot be linked to itself')),
|
||||
new Validators\Exists('opposite_task_id', t('This linked task id doesn\'t exists'), $this->db->getConnection(), Task::TABLE, 'id')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate creation
|
||||
*
|
||||
@@ -132,11 +242,28 @@ class TaskLink extends Base
|
||||
*/
|
||||
public function validateCreation(array $values)
|
||||
{
|
||||
$v = new Validator($values, array(
|
||||
new Validators\Required('task_id', t('Field required')),
|
||||
new Validators\Required('link_id', t('Field required')),
|
||||
new Validators\Required('title', t('Field required')),
|
||||
));
|
||||
$v = new Validator($values, $this->commonValidationRules());
|
||||
|
||||
return array(
|
||||
$v->execute(),
|
||||
$v->getErrors()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate modification
|
||||
*
|
||||
* @access public
|
||||
* @param array $values Form values
|
||||
* @return array $valid, $errors [0] = Success or not, [1] = List of errors
|
||||
*/
|
||||
public function validateModification(array $values)
|
||||
{
|
||||
$rules = array(
|
||||
new Validators\Required('id', t('Field required')),
|
||||
);
|
||||
|
||||
$v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
|
||||
|
||||
return array(
|
||||
$v->execute(),
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
false,
|
||||
$link['is_active'] ? '' : 'task-link-closed'
|
||||
) ?>
|
||||
<?php if (! empty($link['task_assignee_username'])): ?>
|
||||
[<?= $this->e($link['task_assignee_name'] ?: $link['task_assignee_username']) ?>]
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<form action="<?= $this->u('tasklink', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'ajax' => isset($ajax))) ?>" method="post" autocomplete="off">
|
||||
|
||||
<?= $this->formCsrf() ?>
|
||||
<?= $this->formHidden('task_id', $values) ?>
|
||||
<?= $this->formHidden('task_id', array('task_id' => $task['id'])) ?>
|
||||
<?= $this->formHidden('opposite_task_id', $values) ?>
|
||||
|
||||
<?= $this->formLabel(t('Label'), 'link_id') ?>
|
||||
@@ -16,7 +16,13 @@
|
||||
'title',
|
||||
$values,
|
||||
$errors,
|
||||
array('required', 'data-dst-field="opposite_task_id"', 'data-search-url="'.$this->u('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"'),
|
||||
array(
|
||||
'required',
|
||||
'placeholder="'.t('Start to type task title...').'"',
|
||||
'title="'.t('Start to type task title...').'"',
|
||||
'data-dst-field="opposite_task_id"',
|
||||
'data-search-url="'.$this->u('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"',
|
||||
),
|
||||
'task-autocomplete') ?>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
34
app/Template/tasklink/edit.php
Normal file
34
app/Template/tasklink/edit.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('Edit a link') ?></h2>
|
||||
</div>
|
||||
|
||||
<form action="<?= $this->u('tasklink', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'link_id' => $task_link['id'])) ?>" method="post" autocomplete="off">
|
||||
|
||||
<?= $this->formCsrf() ?>
|
||||
<?= $this->formHidden('id', $values) ?>
|
||||
<?= $this->formHidden('task_id', $values) ?>
|
||||
<?= $this->formHidden('opposite_task_id', $values) ?>
|
||||
|
||||
<?= $this->formLabel(t('Label'), 'link_id') ?>
|
||||
<?= $this->formSelect('link_id', $labels, $values, $errors) ?>
|
||||
|
||||
<?= $this->formLabel(t('Task'), 'title') ?>
|
||||
<?= $this->formText(
|
||||
'title',
|
||||
$values,
|
||||
$errors,
|
||||
array(
|
||||
'required',
|
||||
'placeholder="'.t('Start to type task title...').'"',
|
||||
'title="'.t('Start to type task title...').'"',
|
||||
'data-dst-field="opposite_task_id"',
|
||||
'data-search-url="'.$this->u('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"',
|
||||
),
|
||||
'task-autocomplete') ?>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<?= $this->a(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
</div>
|
||||
</form>
|
||||
@@ -2,63 +2,103 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('Links') ?></h2>
|
||||
</div>
|
||||
<table class="table-fixed" id="links">
|
||||
<table id="links">
|
||||
<tr>
|
||||
<th class="column-30"><?= t('Label') ?></th>
|
||||
<th class="column-40"><?= t('Task') ?></th>
|
||||
<th class="column-20"><?= t('Column') ?></th>
|
||||
<th class="column-20"><?= t('Label') ?></th>
|
||||
<th class="column-30"><?= t('Task') ?></th>
|
||||
<th><?= t('Column') ?></th>
|
||||
<th><?= t('Assignee') ?></th>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<th><?= t('Action') ?></th>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
<?php foreach ($links as $link): ?>
|
||||
<tr>
|
||||
<td><?= t('This task') ?> <strong><?= t($link['label']) ?></strong></td>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<?php foreach ($links as $label => $grouped_links): ?>
|
||||
<?php $hide_td = false ?>
|
||||
<?php foreach ($grouped_links as $link): ?>
|
||||
<tr>
|
||||
<?php if (! $hide_td): ?>
|
||||
<td rowspan="<?= count($grouped_links) ?>"><?= t('This task') ?> <strong><?= t($label) ?></strong></td>
|
||||
<?php $hide_td = true ?>
|
||||
<?php endif ?>
|
||||
|
||||
<td>
|
||||
<?= $this->a(
|
||||
$this->e('#'.$link['task_id'].' - '.$link['title']),
|
||||
'task', 'show', array('task_id' => $link['task_id'], 'project_id' => $link['project_id']),
|
||||
false,
|
||||
$link['is_active'] ? '' : 'task-link-closed'
|
||||
) ?>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<?= $this->a(
|
||||
$this->e('#'.$link['task_id'].' '.$link['title']),
|
||||
'task',
|
||||
'show',
|
||||
array('task_id' => $link['task_id'], 'project_id' => $link['project_id']),
|
||||
false,
|
||||
$link['is_active'] ? '' : 'task-link-closed'
|
||||
) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->a(
|
||||
$this->e('#'.$link['task_id'].' '.$link['title']),
|
||||
'task',
|
||||
'readonly',
|
||||
array('task_id' => $link['task_id'], 'token' => $project['token']),
|
||||
false,
|
||||
$link['is_active'] ? '' : 'task-link-closed'
|
||||
) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<br/>
|
||||
|
||||
<?php if (! empty($link['task_time_spent'])): ?>
|
||||
<strong><?= $this->e($link['task_time_spent']).'h' ?></strong> <?= t('spent') ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (! empty($link['task_time_estimated'])): ?>
|
||||
<strong><?= $this->e($link['task_time_estimated']).'h' ?></strong> <?= t('estimated') ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td><?= $this->e($link['column_title']) ?></td>
|
||||
<td>
|
||||
<?= $this->a(t('Remove'), 'tasklink', 'confirm', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
<?php if (! empty($link['task_assignee_username'])): ?>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<?= $this->a($this->e($link['task_assignee_name'] ?: $link['task_assignee_username']), 'user', 'show', array('user_id' => $link['task_assignee_id'])) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->e($link['task_assignee_name'] ?: $link['task_assignee_username']) ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<?php if (! isset($not_editable)): ?>
|
||||
<td>
|
||||
<?= $this->a(
|
||||
$this->e('#'.$link['task_id'].' - '.$link['title']),
|
||||
'task', 'readonly', array('task_id' => $link['task_id'], 'token' => $project['token']),
|
||||
false,
|
||||
$link['is_active'] ? '' : 'task-link-closed'
|
||||
) ?>
|
||||
<ul>
|
||||
<li><?= $this->a(t('Edit'), 'tasklink', 'edit', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id'])) ?></li>
|
||||
<li><?= $this->a(t('Remove'), 'tasklink', 'confirm', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id'])) ?></li>
|
||||
</ul>
|
||||
</td>
|
||||
<td><?= $this->e($link['column_title']) ?></td>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
|
||||
<?php if (! isset($not_editable) && isset($link_label_list)): ?>
|
||||
<form action="<?= $this->u('tasklink', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post" autocomplete="off">
|
||||
|
||||
|
||||
<?= $this->formCsrf() ?>
|
||||
<?= $this->formHidden('task_id', array('task_id' => $task['id'])) ?>
|
||||
<?= $this->formHidden('opposite_task_id', array()) ?>
|
||||
|
||||
|
||||
<?= $this->formSelect('link_id', $link_label_list, array(), array()) ?>
|
||||
|
||||
|
||||
<?= $this->formText(
|
||||
'title',
|
||||
array(),
|
||||
array(),
|
||||
array('required', 'data-dst-field="opposite_task_id"', 'data-search-url="'.$this->u('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"'),
|
||||
array(
|
||||
'required',
|
||||
'placeholder="'.t('Start to type task title...').'"',
|
||||
'title="'.t('Start to type task title...').'"',
|
||||
'data-dst-field="opposite_task_id"',
|
||||
'data-search-url="'.$this->u('app', 'autocomplete', array('exclude_task_id' => $task['id'])).'"',
|
||||
),
|
||||
'task-autocomplete') ?>
|
||||
|
||||
|
||||
<input type="submit" value="<?= t('Add') ?>" class="btn btn-blue"/>
|
||||
</form>
|
||||
<?php endif ?>
|
||||
|
||||
<?php endif ?>
|
||||
|
||||
Reference in New Issue
Block a user