Start templates cleanup and reorganisation

This commit is contained in:
Frédéric Guillot 2014-11-09 20:04:27 -05:00
parent e89ba5e9e6
commit 7eadf7cfd8
28 changed files with 182 additions and 195 deletions

View File

@ -19,7 +19,7 @@ class Action extends Base
{
$project = $this->getProjectManagement();
$this->response->html($this->projectLayout('action_index', array(
$this->response->html($this->projectLayout('action/index', array(
'values' => array('project_id' => $project['id']),
'project' => $project,
'actions' => $this->action->getAllByProject($project['id']),
@ -49,7 +49,7 @@ class Action extends Base
$this->response->redirect('?controller=action&action=index&project_id='.$project['id']);
}
$this->response->html($this->projectLayout('action_event', array(
$this->response->html($this->projectLayout('action/event', array(
'values' => $values,
'project' => $project,
'events' => $this->action->getCompatibleEvents($values['action_name']),
@ -81,7 +81,7 @@ class Action extends Base
$projects_list = $this->project->getList(false);
unset($projects_list[$project['id']]);
$this->response->html($this->projectLayout('action_params', array(
$this->response->html($this->projectLayout('action/params', array(
'values' => $values,
'action_params' => $action_params,
'columns_list' => $this->board->getColumnsList($project['id']),
@ -137,7 +137,7 @@ class Action extends Base
{
$project = $this->getProjectManagement();
$this->response->html($this->projectLayout('action_remove', array(
$this->response->html($this->projectLayout('action/remove', array(
'action' => $this->action->getById($this->request->getIntegerParam('action_id')),
'available_events' => $this->action->getAvailableEvents(),
'available_actions' => $this->action->getAvailableActions(),

View File

@ -23,7 +23,7 @@ class App extends Base
$projects = $this->projectPermission->getMemberProjects($user_id);
$project_ids = array_keys($projects);
$this->response->html($this->template->layout('app_index', array(
$this->response->html($this->template->layout('app/index', array(
'board_selector' => $this->projectPermission->getAllowedProjects($user_id),
'events' => $this->projectActivity->getProjects($project_ids, 10),
'tasks' => $this->taskFinder->getAllTasksByUser($user_id),

View File

@ -174,7 +174,7 @@ abstract class Base
*/
public function notfound($no_layout = false)
{
$this->response->html($this->template->layout('app_notfound', array(
$this->response->html($this->template->layout('app/notfound', array(
'title' => t('Page not found'),
'no_layout' => $no_layout,
)));
@ -188,7 +188,7 @@ abstract class Base
*/
public function forbidden($no_layout = false)
{
$this->response->html($this->template->layout('app_forbidden', array(
$this->response->html($this->template->layout('app/forbidden', array(
'title' => t('Access Forbidden'),
'no_layout' => $no_layout,
)));

View File

@ -43,24 +43,11 @@ class Board extends Base
$task = $this->getTask();
$project = $this->project->getById($task['project_id']);
$params = array(
'errors' => array(),
$this->response->html($this->template->load('board/assignee', array(
'values' => $task,
'users_list' => $this->projectPermission->getMemberList($project['id']),
'current_project_id' => $project['id'],
'current_project_name' => $project['name'],
);
if ($this->request->isAjax()) {
$this->response->html($this->template->load('board_assignee', $params));
}
else {
$this->response->html($this->template->layout('board_assignee', $params + array(
'title' => t('Change assignee').' - '.$task['title'],
)));
}
'project' => $project,
)));
}
/**
@ -95,24 +82,11 @@ class Board extends Base
$task = $this->getTask();
$project = $this->project->getById($task['project_id']);
$params = array(
'errors' => array(),
$this->response->html($this->template->load('board/category', array(
'values' => $task,
'categories_list' => $this->category->getList($project['id']),
'current_project_id' => $project['id'],
'current_project_name' => $project['name'],
);
if ($this->request->isAjax()) {
$this->response->html($this->template->load('board_category', $params));
}
else {
$this->response->html($this->template->layout('board_category', $params + array(
'title' => t('Change category').' - '.$task['title'],
)));
}
'project' => $project,
)));
}
/**
@ -154,7 +128,7 @@ class Board extends Base
}
// Display the board with a specific layout
$this->response->html($this->template->layout('board_public', array(
$this->response->html($this->template->layout('board/public', array(
'project' => $project,
'columns' => $this->board->get($project['id']),
'categories' => $this->category->getList($project['id'], false),
@ -210,12 +184,10 @@ class Board extends Base
$this->user->storeLastSeenProjectId($project['id']);
$this->response->html($this->template->layout('board_index', array(
$this->response->html($this->template->layout('board/index', array(
'users' => $this->projectPermission->getMemberList($project['id'], true, true),
'filters' => array('user_id' => UserModel::EVERYBODY_ID),
'projects' => $projects,
'current_project_id' => $project['id'],
'current_project_name' => $project['name'],
'project' => $project,
'board' => $this->board->get($project['id']),
'categories' => $this->category->getList($project['id'], true, true),
'title' => $project['name'],
@ -241,7 +213,7 @@ class Board extends Base
$values['task_limit['.$column['id'].']'] = $column['task_limit'] ?: null;
}
$this->response->html($this->projectLayout('board_edit', array(
$this->response->html($this->projectLayout('board/edit', array(
'errors' => array(),
'values' => $values + array('project_id' => $project['id']),
'columns' => $columns,
@ -281,7 +253,7 @@ class Board extends Base
}
}
$this->response->html($this->projectLayout('board_edit', array(
$this->response->html($this->projectLayout('board/edit', array(
'errors' => $errors,
'values' => $values + array('project_id' => $project['id']),
'columns' => $columns,
@ -319,7 +291,7 @@ class Board extends Base
}
}
$this->response->html($this->projectLayout('board_edit', array(
$this->response->html($this->projectLayout('board/edit', array(
'errors' => $errors,
'values' => $values + $data,
'columns' => $columns,
@ -351,7 +323,7 @@ class Board extends Base
$this->response->redirect('?controller=board&action=edit&project_id='.$project['id']);
}
$this->response->html($this->projectLayout('board_remove', array(
$this->response->html($this->projectLayout('board/remove', array(
'column' => $this->board->getColumn($this->request->getIntegerParam('column_id')),
'project' => $project,
'title' => t('Remove a column from a board')
@ -373,13 +345,13 @@ class Board extends Base
$this->response->status(401);
}
$values = $this->request->getValues();
$values = $this->request->getJson();
if ($this->task->movePosition($project_id, $values['task_id'], $values['column_id'], $values['position'])) {
$this->response->html(
$this->template->load('board_show', array(
'current_project_id' => $project_id,
$this->template->load('board/show', array(
'project' => $this->project->getById($project_id),
'board' => $this->board->get($project_id),
'categories' => $this->category->getList($project_id, false),
'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),
@ -416,8 +388,8 @@ class Board extends Base
if ($this->project->isModifiedSince($project_id, $timestamp)) {
$this->response->html(
$this->template->load('board_show', array(
'current_project_id' => $project_id,
$this->template->load('board/show', array(
'project' => $this->project->getById($project_id),
'board' => $this->board->get($project_id),
'categories' => $this->category->getList($project_id, false),
'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),

View File

@ -57,7 +57,7 @@ class Webhook extends Base
$result = $this->githubWebhook->parsePayload(
$this->request->getHeader('X-Github-Event'),
$this->request->getBody()
$this->request->getJson()
);
echo $result ? 'PARSED' : 'IGNORED';

View File

@ -75,6 +75,17 @@ class Request
return file_get_contents('php://input');
}
/**
* Get the Json request body
*
* @access public
* @return array
*/
public function getJson()
{
return json_decode($this->getBody(), true);
}
/**
* Get the content of an uploaded file
*

View File

@ -47,13 +47,11 @@ class GithubWebhook extends Base
*
* @access public
* @param string $type Github event type
* @param string $payload Raw Github event (JSON)
* @param array $payload Github event
* @return boolean
*/
public function parsePayload($type, $payload)
public function parsePayload($type, array $payload)
{
$payload = json_decode($payload, true);
switch ($type) {
case 'push':
return $this->parsePushEvent($payload);

View File

@ -3,8 +3,10 @@
</div>
<h3><?= t('Choose an event') ?></h3>
<form method="post" action="?controller=action&amp;action=params&amp;project_id=<?= $project['id'] ?>" autocomplete="off">
<form method="post" action="<?= Helper\u('action', 'params', array('project_id' => $project['id'])) ?>">
<?= Helper\form_csrf() ?>
<?= Helper\form_hidden('project_id', $values) ?>
<?= Helper\form_hidden('action_name', $values) ?>
@ -17,6 +19,7 @@
<div class="form-actions">
<input type="submit" value="<?= t('Next step') ?>" class="btn btn-blue"/>
<?= t('or') ?> <a href="?controller=action&amp;action=index&amp;project_id=<?= $project['id'] ?>"><?= t('cancel') ?></a>
<?= t('or') ?>
<?= Helper\a(t('cancel'), 'action', 'index', array('project_id' => $project['id'])) ?>
</div>
</form>

View File

@ -42,17 +42,16 @@
</ul>
</td>
<td>
<a href="?controller=action&amp;action=confirm&amp;project_id=<?= $project['id'] ?>&amp;action_id=<?= $action['id'] ?>"><?= t('Remove') ?></a>
<?= Helper\a(t('Remove'), 'action', 'confirm', array('project_id' => $project['id'], 'action_id' => $action['id'])) ?>
</td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
<h3><?= t('Add an action') ?></h3>
<form method="post" action="?controller=action&amp;action=event&amp;project_id=<?= $project['id'] ?>" autocomplete="off">
<form method="post" action="<?= Helper\u('action', 'event', array('project_id' => $project['id'])) ?>">
<?= Helper\form_csrf() ?>
<?= Helper\form_hidden('project_id', $values) ?>

View File

@ -3,8 +3,10 @@
</div>
<h3><?= t('Define action parameters') ?></h3>
<form method="post" action="?controller=action&amp;action=create&amp;project_id=<?= $project['id'] ?>" autocomplete="off">
<form method="post" action="<?= Helper\u('action', 'create', array('project_id' => $project['id'])) ?>" autocomplete="off">
<?= Helper\form_csrf() ?>
<?= Helper\form_hidden('project_id', $values) ?>
<?= Helper\form_hidden('event_name', $values) ?>
<?= Helper\form_hidden('action_name', $values) ?>
@ -35,6 +37,7 @@
<div class="form-actions">
<input type="submit" value="<?= t('Save this action') ?>" class="btn btn-blue"/>
<?= t('or') ?> <a href="?controller=action&amp;action=index&amp;project_id=<?= $project['id'] ?>"><?= t('cancel') ?></a>
<?= t('or') ?>
<?= Helper\a(t('cancel'), 'action', 'index', array('project_id' => $project['id'])) ?>
</div>
</form>

View File

@ -9,6 +9,7 @@
<div class="form-actions">
<?= Helper\a(t('Yes'), 'action', 'remove', array('project_id' => $project['id'], 'action_id' => $action['id']), true, 'btn btn-red') ?>
<?= t('or') ?> <?= Helper\a(t('cancel'), 'action', 'index', array('project_id' => $project['id'])) ?>
<?= t('or') ?>
<?= Helper\a(t('cancel'), 'action', 'index', array('project_id' => $project['id'])) ?>
</div>
</div>

View File

@ -1,24 +1,21 @@
<section id="main">
<div class="page-header board">
<h2><?= t('Project "%s"', $current_project_name) ?></h2>
</div>
<section>
<h3><?= t('Change assignee for the task "%s"', $values['title']) ?></h3>
<form method="post" action="?controller=board&amp;action=updateAssignee" autocomplete="off">
<form method="post" action="<?= Helper\u('board', 'updateAssignee', array('task_id' => $values['id'])) ?>">
<?= Helper\form_csrf() ?>
<?= Helper\form_hidden('id', $values) ?>
<?= Helper\form_hidden('project_id', $values) ?>
<?= Helper\form_label(t('Assignee'), 'owner_id') ?>
<?= Helper\form_select('owner_id', $users_list, $values, $errors) ?><br/>
<?= Helper\form_select('owner_id', $users_list, $values) ?><br/>
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
<?= t('or') ?> <a href="?controller=board&amp;action=show&amp;project_id=<?= $values['project_id'] ?>"><?= t('cancel') ?></a>
<?= t('or') ?>
<?= Helper\a(t('cancel'), 'board', 'show', array('project_id' => $project['id'])) ?>
</div>
</form>
</section>
</section>

View File

@ -1,22 +1,20 @@
<section id="main">
<div class="page-header board">
<h2><?= t('Project "%s"', $current_project_name) ?></h2>
</div>
<section>
<h3><?= t('Change category for the task "%s"', $values['title']) ?></h3>
<form method="post" action="?controller=board&amp;action=updateCategory" autocomplete="off">
<form method="post" action="<?= Helper\u('board', 'updateCategory', array('task_id' => $values['id'])) ?>">
<?= Helper\form_csrf() ?>
<?= Helper\form_hidden('id', $values) ?>
<?= Helper\form_hidden('project_id', $values) ?>
<?= Helper\form_label(t('Category'), 'category_id') ?>
<?= Helper\form_select('category_id', $categories_list, $values, $errors) ?><br/>
<?= Helper\form_select('category_id', $categories_list, $values) ?><br/>
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
<?= t('or') ?> <a href="?controller=board&amp;action=show&amp;project_id=<?= $values['project_id'] ?>"><?= t('cancel') ?></a>
<?= t('or') ?>
<?= Helper\a(t('cancel'), 'board', 'show', array('project_id' => $project['id'])) ?>
</div>
</form>
</section>

View File

@ -4,7 +4,7 @@
<section>
<h3><?= t('Change columns') ?></h3>
<form method="post" action="?controller=board&amp;action=update&amp;project_id=<?= $project['id'] ?>" autocomplete="off">
<form method="post" action="<?= Helper\u('board', 'update', array('project_id' => $project['id'])) ?>" autocomplete="off">
<?= Helper\form_csrf() ?>
<?php $i = 0; ?>
<table>
@ -46,9 +46,12 @@
</form>
<h3><?= t('Add a new column') ?></h3>
<form method="post" action="?controller=board&amp;action=add&amp;project_id=<?= $project['id'] ?>" autocomplete="off">
<form method="post" action="<?= Helper\u('board', 'add', array('project_id' => $project['id'])) ?>" autocomplete="off">
<?= Helper\form_csrf() ?>
<?= Helper\form_hidden('project_id', $values) ?>
<?= Helper\form_label(t('Title'), 'title') ?>
<?= Helper\form_text('title', $values, $errors, array('required')) ?>

View File

@ -0,0 +1,35 @@
<div class="page-header">
<ul>
<li>
<?= t('Filter by user') ?>
<?= Helper\form_select('user_id', $users) ?>
</li>
<li>
<?= t('Filter by category') ?>
<?= Helper\form_select('category_id', $categories) ?>
</li>
<li>
<a href="#" id="filter-due-date"><?= t('Filter by due date') ?></a>
</li>
<li>
<i class="fa fa-search"></i>
<?= Helper\a(t('Search'), 'project', 'search', array('project_id' => $project['id'])) ?>
</li>
<li>
<i class="fa fa-check-square-o fa-fw"></i>
<?= Helper\a(t('Completed tasks'), 'project', 'tasks', array('project_id' => $project['id'])) ?>
</li>
<li>
<i class="fa fa-dashboard fa-fw"></i>
<?= Helper\a(t('Activity'), 'project', 'activity', array('project_id' => $project['id'])) ?>
</li>
<li>
<i class="fa fa-line-chart fa-fw"></i>
<?= Helper\a(t('Analytics'), 'analytic', 'repartition', array('project_id' => $project['id'])) ?>
</li>
<?php if (Helper\is_admin()): ?>
<li><i class="fa fa-cog fa-fw"></i>
<?= Helper\a(t('Configure'), 'project', 'show', array('project_id' => $project['id'])) ?>
<?php endif ?>
</ul>
</div>

View File

@ -0,0 +1,21 @@
<section id="main">
<?= Helper\template('board/filters', array(
'categories' => $categories,
'users' => $users,
'project' => $project,
)) ?>
<?php if (empty($board)): ?>
<p class="alert alert-error"><?= t('There is no column in your project!') ?></p>
<?php else: ?>
<?= Helper\template('board/show', array(
'project' => $project,
'board' => $board,
'categories' => $categories,
'board_private_refresh_interval' => $board_private_refresh_interval,
'board_highlight_period' => $board_highlight_period,
)) ?>
<?php endif ?>
</section>

View File

@ -21,7 +21,7 @@
<?php foreach ($column['tasks'] as $task): ?>
<div class="task-board task-<?= $task['color_id'] ?>">
<?= Helper\template('board_task', array('task' => $task, 'categories' => $categories, 'not_editable' => true, 'project' => $project)) ?>
<?= Helper\template('board/task', array('task' => $task, 'categories' => $categories, 'not_editable' => true, 'project' => $project)) ?>
</div>
<?php endforeach ?>

View File

@ -1,8 +1,9 @@
<table id="board"
data-project-id="<?= $current_project_id ?>"
data-time="<?= time() ?>"
data-project-id="<?= $project['id'] ?>"
data-check-interval="<?= $board_private_refresh_interval ?>"
data-csrf-token=<?= \Core\Security::getCSRFToken() ?>>
data-save-url="<?= Helper\u('board', 'save', array('project_id' => $project['id'])) ?>"
data-check-url="<?= Helper\u('board', 'check', array('project_id' => $project['id'], 'timestamp' => time())) ?>"
>
<tr>
<?php $column_with = round(100 / count($board), 2); ?>
<?php foreach ($board as $column): ?>
@ -37,9 +38,10 @@
data-owner-id="<?= $task['owner_id'] ?>"
data-category-id="<?= $task['category_id'] ?>"
data-due-date="<?= $task['date_due'] ?>"
data-task-url="<?= Helper\u('task', 'show', array('task_id' => $task['id'])) ?>"
title="<?= t('View this task') ?>">
<?= Helper\template('board_task', array('task' => $task, 'categories' => $categories)) ?>
<?= Helper\template('board/task', array('task' => $task, 'categories' => $categories)) ?>
</div>
<?php endforeach ?>

View File

@ -1,6 +1,6 @@
<?php if (isset($not_editable)): ?>
<a href="?controller=task&amp;action=readonly&amp;task_id=<?= $task['id'] ?>&amp;token=<?= $project['token'] ?>">#<?= $task['id'] ?></a>
<?= Helper\a('#'.$task['id'], 'task', 'readonly', array('task_id' => $task['id'], 'token' => $project['token'])) ?>
<?php if ($task['reference']): ?>
<span class="task-board-reference" title="<?= t('Reference') ?>">
@ -23,14 +23,12 @@
<?php endif ?>
<div class="task-board-title">
<a href="?controller=task&amp;action=readonly&amp;task_id=<?= $task['id'] ?>&amp;token=<?= $project['token'] ?>">
<?= Helper\escape($task['title']) ?>
</a>
<?= Helper\a(Helper\escape($task['title']), 'task', 'readonly', array('task_id' => $task['id'], 'token' => $project['token'])) ?>
</div>
<?php else: ?>
<a class="task-edit-popover" href="?controller=task&amp;action=edit&amp;task_id=<?= $task['id'] ?>" title="<?= t('Edit this task') ?>">#<?= $task['id'] ?></a>
<?= Helper\a('#'.$task['id'], 'task', 'edit', array('task_id' => $task['id']), false, 'task-edit-popover', t('Edit this task')) ?>
<?php if ($task['reference']): ?>
<span class="task-board-reference" title="<?= t('Reference') ?>">
@ -41,13 +39,15 @@
&nbsp;-&nbsp;
<span class="task-board-user">
<a class="assignee-popover" href="?controller=board&amp;action=changeAssignee&amp;task_id=<?= $task['id'] ?>" title="<?= t('Change assignee') ?>">
<?php if (! empty($task['owner_id'])): ?>
<?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?></a>
<?php else: ?>
<?= t('Nobody assigned') ?>
<?php endif ?>
</a>
<?= Helper\a(
! empty($task['owner_id']) ? t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) : t('Nobody assigned'),
'board',
'changeAssignee',
array('task_id' => $task['id']),
false,
'assignee-popover',
t('Change assignee')
) ?>
</span>
<?php if ($task['score']): ?>
@ -55,7 +55,7 @@
<?php endif ?>
<div class="task-board-title">
<a href="?controller=task&amp;action=show&amp;task_id=<?= $task['id'] ?>" title="<?= t('View this task') ?>"><?= Helper\escape($task['title']) ?></a>
<?= Helper\a(Helper\escape($task['title']), 'task', 'show', array('task_id' => $task['id']), false, '', t('View this task')) ?>
</div>
<?php endif ?>
@ -64,9 +64,15 @@
<?php if ($task['category_id']): ?>
<div class="task-board-category-container">
<span class="task-board-category">
<a class="category-popover" href="?controller=board&amp;action=changeCategory&amp;task_id=<?= $task['id'] ?>" title="<?= t('Change category') ?>">
<?= Helper\in_list($task['category_id'], $categories) ?>
</a>
<?= Helper\a(
Helper\in_list($task['category_id'], $categories),
'board',
'changeCategory',
array('task_id' => $task['id']),
false,
'category-popover',
t('Change category')
) ?>
</span>
</div>
<?php endif ?>

View File

@ -1,50 +0,0 @@
<section id="main">
<div class="page-header">
<ul>
<li>
<?= t('Filter by user') ?>
<?= Helper\form_select('user_id', $users, $filters) ?>
</li>
<li>
<?= t('Filter by category') ?>
<?= Helper\form_select('category_id', $categories, $filters) ?>
</li>
<li>
<a href="#" id="filter-due-date"><?= t('Filter by due date') ?></a>
</li>
<li>
<i class="fa fa-search"></i>
<?= Helper\a(t('Search'), 'project', 'search', array('project_id' => $current_project_id)) ?>
</li>
<li>
<i class="fa fa-check-square-o fa-fw"></i>
<?= Helper\a(t('Completed tasks'), 'project', 'tasks', array('project_id' => $current_project_id)) ?>
</li>
<li>
<i class="fa fa-dashboard fa-fw"></i>
<?= Helper\a(t('Activity'), 'project', 'activity', array('project_id' => $current_project_id)) ?>
</li>
<li>
<i class="fa fa-line-chart fa-fw"></i>
<?= Helper\a(t('Analytics'), 'analytic', 'repartition', array('project_id' => $current_project_id)) ?>
</li>
<?php if (Helper\is_admin()): ?>
<li><i class="fa fa-cog fa-fw"></i>
<?= Helper\a(t('Configure'), 'project', 'show', array('project_id' => $current_project_id)) ?>
<?php endif ?>
</ul>
</div>
<?php if (empty($board)): ?>
<p class="alert alert-error"><?= t('There is no column in your project!') ?></p>
<?php else: ?>
<?= Helper\template('board_show', array(
'current_project_id' => $current_project_id,
'board' => $board,
'categories' => $categories,
'board_private_refresh_interval' => $board_private_refresh_interval,
'board_highlight_period' => $board_highlight_period,
)) ?>
<?php endif ?>
</section>

View File

@ -34,7 +34,7 @@
<ul>
<?php if (isset($board_selector) && ! empty($board_selector)): ?>
<li>
<select id="board-selector" data-placeholder="<?= t('Display another project') ?>">
<select id="board-selector" data-placeholder="<?= t('Display another project') ?>" data-board-url="<?= Helper\u('board', 'show', array('project_id' => '%d')) ?>">
<option value=""></option>
<?php foreach($board_selector as $board_id => $board_name): ?>
<option value="<?= $board_id ?>"><?= Helper\escape($board_name) ?></option>

View File

@ -97,7 +97,7 @@ var Kanboard = (function() {
});
$("#board-selector").change(function() {
window.location = "?controller=board&action=show&project_id=" + $(this).val();
window.location = $(this).attr("data-board-url").replace(/%d/g, $(this).val());
});
}
};
@ -140,9 +140,9 @@ Kanboard.Board = (function() {
$(".task-description-popover").click(Kanboard.Popover);
// Redirect to the task details page
$("[data-task-id]").each(function() {
$("[data-task-url]").each(function() {
$(this).click(function() {
window.location = "?controller=task&action=show&task_id=" + $(this).attr("data-task-id");
window.location = $(this).attr("data-task-url");
});
});
@ -157,28 +157,26 @@ Kanboard.Board = (function() {
// Stop events
function board_unload_events()
{
$("[data-task-id]").off();
$("[data-task-url]").off();
clearInterval(checkInterval);
}
// Save and refresh the board
function board_save(taskId, columnId, position)
{
var boardSelector = $("#board");
var projectId = boardSelector.attr("data-project-id");
board_unload_events();
$.ajax({
cache: false,
url: "?controller=board&action=save&project_id=" + projectId,
data: {
url: $("#board").attr("data-save-url"),
contentType: "application/json",
type: "POST",
processData: false,
data: JSON.stringify({
"task_id": taskId,
"column_id": columnId,
"position": position,
"csrf_token": boardSelector.attr("data-csrf-token"),
},
type: "POST",
}),
success: function(data) {
$("#board").remove();
$("#main").append(data);
@ -191,17 +189,13 @@ Kanboard.Board = (function() {
// Check if a board have been changed by someone else
function board_check()
{
var boardSelector = $("#board");
var projectId = boardSelector.attr("data-project-id");
var timestamp = boardSelector.attr("data-time");
if (Kanboard.IsVisible() && projectId != undefined && timestamp != undefined) {
if (Kanboard.IsVisible()) {
$.ajax({
cache: false,
url: "?controller=board&action=check&project_id=" + projectId + "&timestamp=" + timestamp,
url: $("#board").attr("data-check-url"),
statusCode: {
200: function(data) {
boardSelector.remove();
$("#board").remove();
$("#main").append(data);
board_unload_events();
board_load_events();

View File

@ -82,7 +82,7 @@ var Kanboard = (function() {
});
$("#board-selector").change(function() {
window.location = "?controller=board&action=show&project_id=" + $(this).val();
window.location = $(this).attr("data-board-url").replace(/%d/g, $(this).val());
});
}
};

View File

@ -36,9 +36,9 @@ Kanboard.Board = (function() {
$(".task-description-popover").click(Kanboard.Popover);
// Redirect to the task details page
$("[data-task-id]").each(function() {
$("[data-task-url]").each(function() {
$(this).click(function() {
window.location = "?controller=task&action=show&task_id=" + $(this).attr("data-task-id");
window.location = $(this).attr("data-task-url");
});
});
@ -53,28 +53,26 @@ Kanboard.Board = (function() {
// Stop events
function board_unload_events()
{
$("[data-task-id]").off();
$("[data-task-url]").off();
clearInterval(checkInterval);
}
// Save and refresh the board
function board_save(taskId, columnId, position)
{
var boardSelector = $("#board");
var projectId = boardSelector.attr("data-project-id");
board_unload_events();
$.ajax({
cache: false,
url: "?controller=board&action=save&project_id=" + projectId,
data: {
url: $("#board").attr("data-save-url"),
contentType: "application/json",
type: "POST",
processData: false,
data: JSON.stringify({
"task_id": taskId,
"column_id": columnId,
"position": position,
"csrf_token": boardSelector.attr("data-csrf-token"),
},
type: "POST",
}),
success: function(data) {
$("#board").remove();
$("#main").append(data);
@ -87,17 +85,13 @@ Kanboard.Board = (function() {
// Check if a board have been changed by someone else
function board_check()
{
var boardSelector = $("#board");
var projectId = boardSelector.attr("data-project-id");
var timestamp = boardSelector.attr("data-time");
if (Kanboard.IsVisible() && projectId != undefined && timestamp != undefined) {
if (Kanboard.IsVisible()) {
$.ajax({
cache: false,
url: "?controller=board&action=check&project_id=" + projectId + "&timestamp=" + timestamp,
url: $("#board").attr("data-check-url"),
statusCode: {
200: function(data) {
boardSelector.remove();
$("#board").remove();
$("#main").append(data);
board_unload_events();
board_load_events();