Make project creation form a inline popup

This commit is contained in:
Frederic Guillot 2016-01-31 20:14:51 -05:00
parent 0bc51620c7
commit 271543431e
7 changed files with 40 additions and 11 deletions

View File

@ -189,10 +189,9 @@ abstract class Base extends \Kanboard\Core\Base
*/
protected function taskLayout($template, array $params)
{
$params['ajax'] = $this->request->isAjax();
$content = $this->template->render($template, $params);
if ($params['ajax']) {
if ($this->request->isAjax()) {
return $content;
}

View File

@ -20,8 +20,7 @@ class ProjectCreation extends Base
$is_private = isset($values['is_private']) && $values['is_private'] == 1;
$projects_list = array(0 => t('Do not duplicate anything')) + $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$this->response->html($this->template->layout('project_creation/create', array(
'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
$this->response->html($this->helper->layout->app('project_creation/create', array(
'values' => $values,
'errors' => $errors,
'is_private' => $is_private,

View File

@ -20,6 +20,7 @@ use Pimple\Container;
* @property \Helper\Text $text
* @property \Helper\Url $url
* @property \Helper\User $user
* @property \Helper\Layout $layout
*/
class Helper
{

32
app/Helper/Layout.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace Kanboard\Helper;
use Kanboard\Core\Base;
/**
* Layout helpers
*
* @package helper
* @author Frederic Guillot
*/
class Layout extends Base
{
/**
* Render a template without the layout if Ajax request
*
* @access public
* @param string $template Template name
* @param array $params Template parameters
* @return string
*/
public function app($template, array $params = array())
{
if ($this->request->isAjax()) {
return $this->template->render($template, $params);
}
$params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
return $this->template->layout($template, $params);
}
}

View File

@ -4,12 +4,12 @@
<?php if ($this->user->hasAccess('ProjectCreation', 'create')): ?>
<li>
<i class="fa fa-plus fa-fw"></i>
<?= $this->url->link(t('New project'), 'ProjectCreation', 'create') ?>
<?= $this->url->link(t('New project'), 'ProjectCreation', 'create', array(), false, 'popover') ?>
</li>
<?php endif ?>
<li>
<i class="fa fa-lock fa-fw"></i>
<?= $this->url->link(t('New private project'), 'ProjectCreation', 'createPrivate') ?>
<?= $this->url->link(t('New private project'), 'ProjectCreation', 'createPrivate', array(), false, 'popover') ?>
</li>
<li>
<i class="fa fa-search fa-fw"></i>

View File

@ -42,10 +42,10 @@
<a href="#" class="dropdown-menu dropdown-menu-link-icon"><i class="fa fa-plus fa-fw"></i><i class="fa fa-caret-down"></i></a>
<ul>
<?php if ($this->user->hasAccess('ProjectCreation', 'create')): ?>
<li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New project'), 'ProjectCreation', 'create') ?></li>
<li><i class="fa fa-plus fa-fw"></i><?= $this->url->link(t('New project'), 'ProjectCreation', 'create', array(), false, 'popover') ?></li>
<?php endif ?>
<li>
<i class="fa fa-lock fa-fw"></i><?= $this->url->link(t('New private project'), 'ProjectCreation', 'createPrivate') ?>
<i class="fa fa-lock fa-fw"></i><?= $this->url->link(t('New private project'), 'ProjectCreation', 'createPrivate', array(), false, 'popover') ?>
</li>
</ul>
</div>

View File

@ -1,8 +1,6 @@
<section id="main">
<div class="page-header">
<ul>
<li><i class="fa fa-folder fa-fw"></i><?= $this->url->link(t('All projects'), 'project', 'index') ?></li>
</ul>
<h2><?= $title ?></h2>
</div>
<form class="form-popover" id="project-creation-form" method="post" action="<?= $this->url->href('ProjectCreation', 'save') ?>" autocomplete="off">