Simplify code to handle ajax popover and redirects
This commit is contained in:
parent
4a52d327f7
commit
bb040cfb78
|
|
@ -21,6 +21,7 @@ New features:
|
|||
Improvements:
|
||||
|
||||
* Show progress for task links in board tooltips
|
||||
* Simplify code to handle ajax popover and redirects
|
||||
|
||||
Version 1.0.24
|
||||
--------------
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ abstract class Base extends \Kanboard\Core\Base
|
|||
*/
|
||||
protected function taskLayout($template, array $params)
|
||||
{
|
||||
$params['ajax'] = $this->request->isAjax() || $this->request->getIntegerParam('ajax') === 1;
|
||||
$params['ajax'] = $this->request->isAjax();
|
||||
$content = $this->template->render($template, $params);
|
||||
|
||||
if ($params['ajax']) {
|
||||
|
|
|
|||
|
|
@ -21,13 +21,11 @@ class Comment extends Base
|
|||
$comment = $this->comment->getById($this->request->getIntegerParam('comment_id'));
|
||||
|
||||
if (empty($comment)) {
|
||||
$this->notfound();
|
||||
return $this->notfound();
|
||||
}
|
||||
|
||||
if (! $this->userSession->isAdmin() && $comment['user_id'] != $this->userSession->getId()) {
|
||||
$this->response->html($this->template->layout('comment/forbidden', array(
|
||||
'title' => t('Access Forbidden')
|
||||
)));
|
||||
return $this->forbidden();
|
||||
}
|
||||
|
||||
return $comment;
|
||||
|
|
@ -66,7 +64,6 @@ class Comment extends Base
|
|||
{
|
||||
$task = $this->getTask();
|
||||
$values = $this->request->getValues();
|
||||
$ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
|
||||
|
||||
list($valid, $errors) = $this->commentValidator->validateCreation($values);
|
||||
|
||||
|
|
@ -77,11 +74,7 @@ class Comment extends Base
|
|||
$this->flash->failure(t('Unable to create your comment.'));
|
||||
}
|
||||
|
||||
if ($ajax) {
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'));
|
||||
return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true);
|
||||
}
|
||||
|
||||
$this->create($values, $errors);
|
||||
|
|
@ -126,7 +119,7 @@ class Comment extends Base
|
|||
$this->flash->failure(t('Unable to update your comment.'));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comment-'.$comment['id']));
|
||||
return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comment-'.$comment['id']));
|
||||
}
|
||||
|
||||
$this->edit($values, $errors);
|
||||
|
|
|
|||
|
|
@ -23,17 +23,11 @@ class File extends Base
|
|||
|
||||
if ($this->request->isPost() && $this->file->uploadScreenshot($task['project_id'], $task['id'], $this->request->getValue('screenshot')) !== false) {
|
||||
$this->flash->success(t('Screenshot uploaded successfully.'));
|
||||
|
||||
if ($this->request->getStringParam('redirect') === 'board') {
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
|
||||
return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
|
||||
}
|
||||
|
||||
$this->response->html($this->taskLayout('file/screenshot', array(
|
||||
'task' => $task,
|
||||
'redirect' => 'task',
|
||||
)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class TaskExternalLink extends Base
|
|||
|
||||
if ($valid && $this->taskExternalLink->update($values)) {
|
||||
$this->flash->success(t('Link updated successfully.'));
|
||||
return $this->response->redirect($this->helper->url->to('TaskExternalLink', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
|
||||
return $this->response->redirect($this->helper->url->to('TaskExternalLink', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
|
||||
}
|
||||
|
||||
$this->edit($values, $errors);
|
||||
|
|
|
|||
|
|
@ -18,22 +18,18 @@ class Taskcreation extends Base
|
|||
public function create(array $values = array(), array $errors = array())
|
||||
{
|
||||
$project = $this->getProject();
|
||||
$method = $this->request->isAjax() ? 'render' : 'layout';
|
||||
$swimlanes_list = $this->swimlane->getList($project['id'], false, true);
|
||||
|
||||
if (empty($values)) {
|
||||
$values = array(
|
||||
'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)),
|
||||
'column_id' => $this->request->getIntegerParam('column_id'),
|
||||
'color_id' => $this->request->getStringParam('color_id', $this->color->getDefaultColor()),
|
||||
'owner_id' => $this->request->getIntegerParam('owner_id'),
|
||||
'another_task' => $this->request->getIntegerParam('another_task'),
|
||||
'color_id' => $this->color->getDefaultColor(),
|
||||
);
|
||||
}
|
||||
|
||||
$this->response->html($this->template->$method('task_creation/form', array(
|
||||
$this->response->html($this->template->render('task_creation/form', array(
|
||||
'project' => $project,
|
||||
'ajax' => $this->request->isAjax(),
|
||||
'errors' => $errors,
|
||||
'values' => $values + array('project_id' => $project['id']),
|
||||
'columns_list' => $this->board->getColumnsList($project['id']),
|
||||
|
|
@ -61,25 +57,26 @@ class Taskcreation extends Base
|
|||
|
||||
if ($valid && $this->taskCreation->create($values)) {
|
||||
$this->flash->success(t('Task created successfully.'));
|
||||
$this->afterSave($project, $values);
|
||||
} else {
|
||||
$this->flash->failure(t('Unable to create your task.'));
|
||||
return $this->afterSave($project, $values);
|
||||
}
|
||||
|
||||
$this->flash->failure(t('Unable to create your task.'));
|
||||
$this->create($values, $errors);
|
||||
}
|
||||
|
||||
private function afterSave(array $project, array &$values)
|
||||
{
|
||||
if (isset($values['another_task']) && $values['another_task'] == 1) {
|
||||
unset($values['title']);
|
||||
unset($values['description']);
|
||||
|
||||
if (! $this->request->isAjax()) {
|
||||
$this->response->redirect($this->helper->url->to('taskcreation', 'create', $values));
|
||||
}
|
||||
} else {
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id'])));
|
||||
return $this->create(array(
|
||||
'owner_id' => $values['owner_id'],
|
||||
'color_id' => $values['color_id'],
|
||||
'category_id' => $values['category_id'],
|
||||
'column_id' => $values['column_id'],
|
||||
'swimlane_id' => isset($values['swimlane_id']) ? $values['swimlane_id'] : 0,
|
||||
'another_task' => 1,
|
||||
));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id'])));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class Tasklink extends Base
|
|||
$link = $this->taskLink->getById($this->request->getIntegerParam('link_id'));
|
||||
|
||||
if (empty($link)) {
|
||||
$this->notfound();
|
||||
return $this->notfound();
|
||||
}
|
||||
|
||||
return $link;
|
||||
|
|
@ -74,19 +74,13 @@ class Tasklink extends Base
|
|||
{
|
||||
$task = $this->getTask();
|
||||
$values = $this->request->getValues();
|
||||
$ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
|
||||
|
||||
list($valid, $errors) = $this->taskLinkValidator->validateCreation($values);
|
||||
|
||||
if ($valid) {
|
||||
if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
|
||||
$this->flash->success(t('Link added successfully.'));
|
||||
|
||||
if ($ajax) {
|
||||
return $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
|
||||
}
|
||||
|
||||
return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
|
||||
return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links', true);
|
||||
}
|
||||
|
||||
$errors = array('title' => array(t('The exact same link already exists')));
|
||||
|
|
|
|||
|
|
@ -48,41 +48,44 @@ class Taskmodification extends Base
|
|||
*
|
||||
* @access public
|
||||
*/
|
||||
public function description()
|
||||
public function description(array $values = array(), array $errors = array())
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$values = $this->request->getValues();
|
||||
|
||||
list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values);
|
||||
|
||||
if ($valid) {
|
||||
if ($this->taskModification->update($values)) {
|
||||
$this->flash->success(t('Task updated successfully.'));
|
||||
} else {
|
||||
$this->flash->failure(t('Unable to update your task.'));
|
||||
}
|
||||
|
||||
if ($ajax) {
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
|
||||
} else {
|
||||
$this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$values = $task;
|
||||
$errors = array();
|
||||
if (empty($values)) {
|
||||
$values = array('id' => $task['id'], 'description' => $task['description']);
|
||||
}
|
||||
|
||||
$params = array(
|
||||
$this->response->html($this->taskLayout('task_modification/edit_description', array(
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
'task' => $task,
|
||||
);
|
||||
)));
|
||||
}
|
||||
|
||||
$this->response->html($this->taskLayout('task_modification/edit_description', $params));
|
||||
/**
|
||||
* Update description
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function updateDescription()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$values = $this->request->getValues();
|
||||
|
||||
list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values);
|
||||
|
||||
if ($valid) {
|
||||
if ($this->taskModification->update($values)) {
|
||||
$this->flash->success(t('Task updated successfully.'));
|
||||
} else {
|
||||
$this->flash->failure(t('Unable to update your task.'));
|
||||
}
|
||||
|
||||
return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
|
||||
}
|
||||
|
||||
$this->description($values, $errors);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,7 +97,6 @@ class Taskmodification extends Base
|
|||
{
|
||||
$task = $this->getTask();
|
||||
$project = $this->project->getById($task['project_id']);
|
||||
$ajax = $this->request->isAjax();
|
||||
|
||||
if (empty($values)) {
|
||||
$values = $task;
|
||||
|
|
@ -102,7 +104,7 @@ class Taskmodification extends Base
|
|||
|
||||
$this->dateParser->format($values, array('date_due'));
|
||||
|
||||
$params = array(
|
||||
$this->response->html($this->taskLayout('task_modification/edit_task', array(
|
||||
'project' => $project,
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
|
|
@ -112,16 +114,7 @@ class Taskmodification extends Base
|
|||
'categories_list' => $this->category->getList($task['project_id']),
|
||||
'date_format' => $this->config->get('application_date_format'),
|
||||
'date_formats' => $this->dateParser->getAvailableFormats(),
|
||||
'ajax' => $ajax,
|
||||
);
|
||||
|
||||
if ($ajax) {
|
||||
$html = $this->template->render('task_modification/edit_task', $params);
|
||||
} else {
|
||||
$html = $this->taskLayout('task_modification/edit_task', $params);
|
||||
}
|
||||
|
||||
$this->response->html($html);
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,12 +131,7 @@ class Taskmodification extends Base
|
|||
|
||||
if ($valid && $this->taskModification->update($values)) {
|
||||
$this->flash->success(t('Task updated successfully.'));
|
||||
|
||||
if ($this->request->isAjax()) {
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
|
||||
} else {
|
||||
$this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
|
||||
}
|
||||
return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
|
||||
} else {
|
||||
$this->flash->failure(t('Unable to update your task.'));
|
||||
$this->edit($values, $errors);
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ class Taskstatus extends Base
|
|||
*/
|
||||
public function close()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$this->changeStatus($task, 'close', t('Task closed successfully.'), t('Unable to close this task.'));
|
||||
$this->renderTemplate($task, 'task_status/close');
|
||||
$this->changeStatus('close', 'task_status/close', t('Task closed successfully.'), t('Unable to close this task.'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -29,13 +27,22 @@ class Taskstatus extends Base
|
|||
*/
|
||||
public function open()
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$this->changeStatus($task, 'open', t('Task opened successfully.'), t('Unable to open this task.'));
|
||||
$this->renderTemplate($task, 'task_status/open');
|
||||
$this->changeStatus('open', 'task_status/open', t('Task opened successfully.'), t('Unable to open this task.'));
|
||||
}
|
||||
|
||||
private function changeStatus(array $task, $method, $success_message, $failure_message)
|
||||
/**
|
||||
* Common method to change status
|
||||
*
|
||||
* @access private
|
||||
* @param string $method
|
||||
* @param string $template
|
||||
* @param string $success_message
|
||||
* @param string $failure_message
|
||||
*/
|
||||
private function changeStatus($method, $template, $success_message, $failure_message)
|
||||
{
|
||||
$task = $this->getTask();
|
||||
|
||||
if ($this->request->getStringParam('confirmation') === 'yes') {
|
||||
$this->checkCSRFParam();
|
||||
|
||||
|
|
@ -45,28 +52,11 @@ class Taskstatus extends Base
|
|||
$this->flash->failure($failure_message);
|
||||
}
|
||||
|
||||
if ($this->request->getStringParam('redirect') === 'board') {
|
||||
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
|
||||
}
|
||||
}
|
||||
|
||||
private function renderTemplate(array $task, $template)
|
||||
{
|
||||
$redirect = $this->request->getStringParam('redirect');
|
||||
|
||||
if ($this->request->isAjax()) {
|
||||
$this->response->html($this->template->render($template, array(
|
||||
'task' => $task,
|
||||
'redirect' => $redirect,
|
||||
)));
|
||||
return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
|
||||
}
|
||||
|
||||
$this->response->html($this->taskLayout($template, array(
|
||||
'task' => $task,
|
||||
'redirect' => $redirect,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Response extends Base
|
|||
*/
|
||||
public function redirect($url, $self = false)
|
||||
{
|
||||
if ($this->request->getServerVariable('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest') {
|
||||
if ($this->request->isAjax()) {
|
||||
header('X-Ajax-Redirect: '.($self ? 'self' : $url));
|
||||
} else {
|
||||
header('Location: '.$url);
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
<li><i class="fa fa-external-link fa-fw"></i> <?= $this->url->link(t('Add external link'), 'TaskExternalLink', 'find', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-camera fa-fw"></i> <?= $this->url->link(t('Add a screenshot'), 'BoardPopover', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<?php if ($task['is_active'] == 1): ?>
|
||||
<li><i class="fa fa-close fa-fw"></i> <?= $this->url->link(t('Close this task'), 'taskstatus', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-close fa-fw"></i> <?= $this->url->link(t('Close this task'), 'taskstatus', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<?php else: ?>
|
||||
<li><i class="fa fa-check-square-o fa-fw"></i> <?= $this->url->link(t('Open this task'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?></li>
|
||||
<li><i class="fa fa-check-square-o fa-fw"></i> <?= $this->url->link(t('Open this task'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
|
||||
<?php endif ?>
|
||||
</ul>
|
||||
</span>
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
<div class="page-header">
|
||||
<h2><?= t('Add a comment') ?></h2>
|
||||
</div>
|
||||
|
||||
<form method="post" action="<?= $this->url->href('comment', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'ajax' => $ajax)) ?>" autocomplete="off" class="form-comment">
|
||||
<form class="popover-form" method="post" action="<?= $this->url->href('comment', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off" class="form-comment">
|
||||
<?= $this->form->csrf() ?>
|
||||
<?= $this->form->hidden('task_id', $values) ?>
|
||||
<?= $this->form->hidden('user_id', $values) ?>
|
||||
|
|
@ -41,11 +40,7 @@
|
|||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?php if (! isset($skip_cancel)): ?>
|
||||
<?= t('or') ?>
|
||||
<?php if ($ajax): ?>
|
||||
<?= $this->url->link(t('cancel'), 'board', 'show', array('project_id' => $task['project_id'])) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
<?php endif ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
<div class="page-header">
|
||||
<h2><?= t('Forbidden') ?></h2>
|
||||
</div>
|
||||
|
||||
<p class="alert alert-error">
|
||||
<?= t('Only administrators or the creator of the comment can access to this page.') ?>
|
||||
</p>
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
<p id="screenshot-inner"><?= t('Take a screenshot and press CTRL+V or ⌘+V to paste here.') ?></p>
|
||||
</div>
|
||||
|
||||
<form action="<?= $this->url->href('file', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => $redirect)) ?>" method="post">
|
||||
<form class="popover-form" action="<?= $this->url->href('file', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post">
|
||||
<input type="hidden" name="screenshot"/>
|
||||
<?= $this->form->csrf() ?>
|
||||
<div class="form-actions">
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
),
|
||||
'errors' => array(),
|
||||
'task' => $task,
|
||||
'ajax' => $ajax,
|
||||
)) ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -42,5 +42,4 @@
|
|||
'comments' => $comments,
|
||||
'project' => $project,
|
||||
'editable' => $this->user->hasProjectAccess('comment', 'edit', $project['id']),
|
||||
'ajax' => $ajax,
|
||||
)) ?>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,8 @@
|
|||
<?php if (! $ajax): ?>
|
||||
<div class="page-header">
|
||||
<ul>
|
||||
<li><i class="fa fa-th fa-fw"></i><?= $this->url->link(t('Back to the board'), 'board', 'show', array('project_id' => $values['project_id'])) ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="page-header">
|
||||
<h2><?= t('New task') ?></h2>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<form id="task-form" class="popover-form" method="post" action="<?= $this->url->href('taskcreation', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
|
||||
<form class="popover-form" method="post" action="<?= $this->url->href('taskcreation', 'save', array('project_id' => $values['project_id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= $this->form->csrf() ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<h2><?= t('Add a new external link') ?></h2>
|
||||
</div>
|
||||
|
||||
<form class="popover-form" action="<?= $this->url->href('TaskExternalLink', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'ajax' => $ajax)) ?>" method="post" autocomplete="off">
|
||||
<form class="popover-form" action="<?= $this->url->href('TaskExternalLink', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post" autocomplete="off">
|
||||
<?= $this->render('task_external_link/form', array('task' => $task, 'dependencies' => $dependencies, 'values' => $values, 'errors' => $errors)) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<h2><?= t('Edit external link') ?></h2>
|
||||
</div>
|
||||
|
||||
<form class="popover-form" action="<?= $this->url->href('TaskExternalLink', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'ajax' => $ajax)) ?>" method="post" autocomplete="off">
|
||||
<form class="popover-form" action="<?= $this->url->href('TaskExternalLink', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post" autocomplete="off">
|
||||
<?= $this->render('task_external_link/form', array('task' => $task, 'dependencies' => $dependencies, 'values' => $values, 'errors' => $errors)) ?>
|
||||
|
||||
<div class="form-actions">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<h2><?= t('Add a new external link') ?></h2>
|
||||
</div>
|
||||
|
||||
<form class="popover-form" action="<?= $this->url->href('TaskExternalLink', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'ajax' => $ajax)) ?>" method="post" autocomplete="off">
|
||||
<form class="popover-form" action="<?= $this->url->href('TaskExternalLink', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post" autocomplete="off">
|
||||
<?= $this->form->csrf() ?>
|
||||
<?= $this->form->hidden('task_id', array('task_id' => $task['id'])) ?>
|
||||
|
||||
|
|
@ -23,10 +23,6 @@
|
|||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Next') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<?php if ($ajax): ?>
|
||||
<?= $this->url->link(t('cancel'), 'board', 'show', array('project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
<?php else: ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
<?php endif ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<h2><?= t('Edit the description') ?></h2>
|
||||
</div>
|
||||
|
||||
<form method="post" action="<?= $this->url->href('taskmodification', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'ajax' => $ajax)) ?>" autocomplete="off">
|
||||
<form class="popover-form" method="post" action="<?= $this->url->href('taskmodification', 'updateDescription', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= $this->form->csrf() ?>
|
||||
<?= $this->form->hidden('id', $values) ?>
|
||||
|
|
@ -39,10 +39,6 @@
|
|||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<?php if ($ajax): ?>
|
||||
<?= $this->url->link(t('cancel'), 'board', 'show', array('project_id' => $task['project_id'])) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
<?php endif ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<div class="page-header">
|
||||
<h2><?= t('Edit a task') ?></h2>
|
||||
</div>
|
||||
<form id="task-form" method="post" action="<?= $this->url->href('taskmodification', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
|
||||
<form class="popover-form" method="post" action="<?= $this->url->href('taskmodification', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= $this->form->csrf() ?>
|
||||
|
||||
|
|
@ -63,10 +63,6 @@
|
|||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue" tabindex="10">
|
||||
<?= t('or') ?>
|
||||
<?php if ($ajax): ?>
|
||||
<?= $this->url->link(t('cancel'), 'board', 'show', array('project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
<?php else: ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
<?php endif ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
</p>
|
||||
|
||||
<div class="form-actions">
|
||||
<?= $this->url->link(t('Yes'), 'taskstatus', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes', 'redirect' => $redirect), true, 'btn btn-red') ?>
|
||||
<?= $this->url->link(t('Yes'), 'taskstatus', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes'), true, 'btn btn-red popover-link') ?>
|
||||
<?= t('or') ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
</p>
|
||||
|
||||
<div class="form-actions">
|
||||
<?= $this->url->link(t('Yes'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes', 'redirect' => $redirect), true, 'btn btn-red') ?>
|
||||
<?= $this->url->link(t('Yes'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes'), true, 'btn btn-red popover-link') ?>
|
||||
<?= t('or') ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<h2><?= t('Add a new link') ?></h2>
|
||||
</div>
|
||||
|
||||
<form action="<?= $this->url->href('tasklink', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'ajax' => $ajax)) ?>" method="post" autocomplete="off">
|
||||
<form class="popover-form" action="<?= $this->url->href('tasklink', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" method="post" autocomplete="off">
|
||||
|
||||
<?= $this->form->csrf() ?>
|
||||
<?= $this->form->hidden('task_id', array('task_id' => $task['id'])) ?>
|
||||
|
|
@ -28,10 +28,6 @@
|
|||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<?php if ($ajax): ?>
|
||||
<?= $this->url->link(t('cancel'), 'board', 'show', array('project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
<?php else: ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||
<?php endif ?>
|
||||
<?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
|
||||
</div>
|
||||
</form>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -57,6 +57,7 @@ Popover.prototype.afterOpen = function() {
|
|||
var self = this;
|
||||
var popoverForm = $(".popover-form");
|
||||
|
||||
// Submit forms with Ajax request
|
||||
if (popoverForm) {
|
||||
popoverForm.on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
|
|
@ -66,18 +67,35 @@ Popover.prototype.afterOpen = function() {
|
|||
url: popoverForm.attr("action"),
|
||||
data: popoverForm.serialize(),
|
||||
success: function(data, textStatus, request) {
|
||||
var redirect = request.getResponseHeader("X-Ajax-Redirect");
|
||||
|
||||
if (redirect) {
|
||||
window.location = redirect === 'self' ? window.location.href : redirect;
|
||||
}
|
||||
else {
|
||||
$("#popover-content").html(data);
|
||||
$("input[autofocus]").focus();
|
||||
self.afterOpen();
|
||||
}
|
||||
self.afterSubmit(data, request, self);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Submit link with Ajax request
|
||||
$(document).on("click", ".popover-link", function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: $(this).attr("href"),
|
||||
success: function(data, textStatus, request) {
|
||||
self.afterSubmit(data, request, self);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Popover.prototype.afterSubmit = function(data, request, self) {
|
||||
var redirect = request.getResponseHeader("X-Ajax-Redirect");
|
||||
|
||||
if (redirect) {
|
||||
window.location = redirect === 'self' ? window.location.href : redirect;
|
||||
}
|
||||
else {
|
||||
$("#popover-content").html(data);
|
||||
$("input[autofocus]").focus();
|
||||
self.afterOpen();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue