summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-28 21:24:24 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-28 21:24:24 -0400
commited074d176406ca3ce5ba8fa6e0c4511f729efa5b (patch)
treec5bafd1a6226cf441cfbbaf56be80479260d254a
parent14d6affe2e42fc86a86fbe5e624dbaacf6b8223c (diff)
Move task import outside of project settings
-rw-r--r--ChangeLog1
-rw-r--r--app/Controller/TaskImportController.php33
-rw-r--r--app/ServiceProvider/RouteProvider.php4
-rw-r--r--app/Template/export/sidebar.php8
-rw-r--r--app/Template/project/sidebar.php5
-rw-r--r--app/Template/project_header/dropdown.php9
-rw-r--r--app/Template/task_import/show.php (renamed from app/Template/task_import/step1.php)2
-rw-r--r--app/Template/task_import/sidebar.php9
8 files changed, 43 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 639b6505..ae028de1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@ New features:
Improvements:
+* Move task import to a separate section
* Mark web notification as read when clicking on it
* Support strtotime strings for date search
* Reset failed login counter and unlock user when changing password
diff --git a/app/Controller/TaskImportController.php b/app/Controller/TaskImportController.php
index a4c39f84..aff2d390 100644
--- a/app/Controller/TaskImportController.php
+++ b/app/Controller/TaskImportController.php
@@ -19,11 +19,11 @@ class TaskImportController extends BaseController
* @param array $errors
* @throws \Kanboard\Core\Controller\PageNotFoundException
*/
- public function step1(array $values = array(), array $errors = array())
+ public function show(array $values = array(), array $errors = array())
{
$project = $this->getProject();
- $this->response->html($this->helper->layout->project('task_import/step1', array(
+ $this->response->html($this->helper->layout->project('task_import/show', array(
'project' => $project,
'values' => $values,
'errors' => $errors,
@@ -31,36 +31,35 @@ class TaskImportController extends BaseController
'delimiters' => Csv::getDelimiters(),
'enclosures' => Csv::getEnclosures(),
'title' => t('Import tasks from CSV file'),
- )));
+ ), 'task_import/sidebar'));
}
/**
* Process CSV file
- *
*/
- public function step2()
+ public function save()
{
$project = $this->getProject();
$values = $this->request->getValues();
$filename = $this->request->getFilePath('file');
if (! file_exists($filename)) {
- $this->step1($values, array('file' => array(t('Unable to read your file'))));
- }
+ $this->show($values, array('file' => array(t('Unable to read your file'))));
+ } else {
+ $this->taskImport->projectId = $project['id'];
- $this->taskImport->projectId = $project['id'];
+ $csv = new Csv($values['delimiter'], $values['enclosure']);
+ $csv->setColumnMapping($this->taskImport->getColumnMapping());
+ $csv->read($filename, array($this->taskImport, 'import'));
- $csv = new Csv($values['delimiter'], $values['enclosure']);
- $csv->setColumnMapping($this->taskImport->getColumnMapping());
- $csv->read($filename, array($this->taskImport, 'import'));
+ if ($this->taskImport->counter > 0) {
+ $this->flash->success(t('%d task(s) have been imported successfully.', $this->taskImport->counter));
+ } else {
+ $this->flash->failure(t('Nothing have been imported!'));
+ }
- if ($this->taskImport->counter > 0) {
- $this->flash->success(t('%d task(s) have been imported successfully.', $this->taskImport->counter));
- } else {
- $this->flash->failure(t('Nothing have been imported!'));
+ $this->response->redirect($this->helper->url->to('TaskImportController', 'show', array('project_id' => $project['id'])));
}
-
- $this->response->redirect($this->helper->url->to('TaskImportController', 'step1', array('project_id' => $project['id'])));
}
/**
diff --git a/app/ServiceProvider/RouteProvider.php b/app/ServiceProvider/RouteProvider.php
index 2e36e425..3d1391df 100644
--- a/app/ServiceProvider/RouteProvider.php
+++ b/app/ServiceProvider/RouteProvider.php
@@ -58,7 +58,6 @@ class RouteProvider implements ServiceProviderInterface
$container['route']->addRoute('project/:project_id/integrations', 'ProjectViewController', 'integrations');
$container['route']->addRoute('project/:project_id/duplicate', 'ProjectViewController', 'duplicate');
$container['route']->addRoute('project/:project_id/permissions', 'ProjectPermissionController', 'index');
- $container['route']->addRoute('project/:project_id/import', 'TaskImportController', 'step1');
$container['route']->addRoute('project/:project_id/activity', 'ActivityController', 'project');
// Project Overview
@@ -89,6 +88,9 @@ class RouteProvider implements ServiceProviderInterface
// Category routes
$container['route']->addRoute('project/:project_id/categories', 'CategoryController', 'index');
+ // Import routes
+ $container['route']->addRoute('project/:project_id/import', 'TaskImportController', 'show');
+
// Task routes
$container['route']->addRoute('project/:project_id/task/:task_id', 'TaskViewController', 'show');
$container['route']->addRoute('t/:task_id', 'TaskViewController', 'show');
diff --git a/app/Template/export/sidebar.php b/app/Template/export/sidebar.php
index c9d4d0a3..55fbaeef 100644
--- a/app/Template/export/sidebar.php
+++ b/app/Template/export/sidebar.php
@@ -1,16 +1,16 @@
<div class="sidebar">
<h2><?= t('Exports') ?></h2>
<ul>
- <li <?= $this->app->getRouterAction() === 'tasks' ? 'class="active"' : '' ?>>
+ <li <?= $this->app->checkMenuSelection('ExportController', 'tasks') ?>>
<?= $this->url->link(t('Tasks'), 'ExportController', 'tasks', array('project_id' => $project['id'])) ?>
</li>
- <li <?= $this->app->getRouterAction() === 'subtasks' ? 'class="active"' : '' ?>>
+ <li <?= $this->app->checkMenuSelection('ExportController', 'subtasks') ?>>
<?= $this->url->link(t('Subtasks'), 'ExportController', 'subtasks', array('project_id' => $project['id'])) ?>
</li>
- <li <?= $this->app->getRouterAction() === 'transitions' ? 'class="active"' : '' ?>>
+ <li <?= $this->app->checkMenuSelection('ExportController', 'transitions') ?>>
<?= $this->url->link(t('Task transitions'), 'ExportController', 'transitions', array('project_id' => $project['id'])) ?>
</li>
- <li <?= $this->app->getRouterAction() === 'summary' ? 'class="active"' : '' ?>>
+ <li <?= $this->app->checkMenuSelection('ExportController', 'summary') ?>>
<?= $this->url->link(t('Daily project summary'), 'ExportController', 'summary', array('project_id' => $project['id'])) ?>
</li>
<?= $this->hook->render('template:export:sidebar') ?>
diff --git a/app/Template/project/sidebar.php b/app/Template/project/sidebar.php
index 3fac3fd1..9bc0c9c4 100644
--- a/app/Template/project/sidebar.php
+++ b/app/Template/project/sidebar.php
@@ -29,7 +29,7 @@
<li <?= $this->app->checkMenuSelection('SwimlaneController') ?>>
<?= $this->url->link(t('Swimlanes'), 'SwimlaneController', 'index', array('project_id' => $project['id'])) ?>
</li>
- <li <?= $this->app->checkMenuSelection('category') ?>>
+ <li <?= $this->app->checkMenuSelection('CategoryController') ?>>
<?= $this->url->link(t('Categories'), 'CategoryController', 'index', array('project_id' => $project['id'])) ?>
</li>
<?php if ($project['is_private'] == 0): ?>
@@ -51,9 +51,6 @@
<?= $this->url->link(t('Enable'), 'ProjectStatusController', 'confirmEnable', array('project_id' => $project['id']), false, 'popover') ?>
<?php endif ?>
</li>
- <li <?= $this->app->checkMenuSelection('TaskImportController') ?>>
- <?= $this->url->link(t('Import'), 'TaskImportController', 'step1', array('project_id' => $project['id'])) ?>
- </li>
<?php if ($this->user->hasProjectAccess('ProjectStatusController', 'remove', $project['id'])): ?>
<li>
<?= $this->url->link(t('Remove'), 'ProjectStatusController', 'confirmRemove', array('project_id' => $project['id']), false, 'popover') ?>
diff --git a/app/Template/project_header/dropdown.php b/app/Template/project_header/dropdown.php
index 6b5c51a6..79a1b389 100644
--- a/app/Template/project_header/dropdown.php
+++ b/app/Template/project_header/dropdown.php
@@ -67,11 +67,18 @@
<?php if ($this->user->hasProjectAccess('ExportController', 'tasks', $project['id'])): ?>
<li>
- <i class="fa fa-download fa-fw"></i>
+ <i class="fa fa-upload fa-fw"></i>
<?= $this->url->link(t('Exports'), 'ExportController', 'tasks', array('project_id' => $project['id'])) ?>
</li>
<?php endif ?>
+ <?php if ($this->user->hasProjectAccess('TaskImportController', 'tasks', $project['id'])): ?>
+ <li>
+ <i class="fa fa-download fa-fw"></i>
+ <?= $this->url->link(t('Imports'), 'TaskImportController', 'show', array('project_id' => $project['id'])) ?>
+ </li>
+ <?php endif ?>
+
<?php if ($this->user->hasProjectAccess('ProjectEditController', 'edit', $project['id'])): ?>
<li>
<i class="fa fa-cog fa-fw"></i>
diff --git a/app/Template/task_import/step1.php b/app/Template/task_import/show.php
index 23fcc11c..cc6a7b3a 100644
--- a/app/Template/task_import/step1.php
+++ b/app/Template/task_import/show.php
@@ -1,7 +1,7 @@
<div class="page-header">
<h2><?= t('Tasks Importation') ?></h2>
</div>
-<form action="<?= $this->url->href('TaskImportController', 'step2', array('project_id' => $project['id'])) ?>" method="post" enctype="multipart/form-data">
+<form action="<?= $this->url->href('TaskImportController', 'save', array('project_id' => $project['id'])) ?>" method="post" enctype="multipart/form-data">
<?= $this->form->csrf() ?>
<?= $this->form->label(t('Delimiter'), 'delimiter') ?>
diff --git a/app/Template/task_import/sidebar.php b/app/Template/task_import/sidebar.php
new file mode 100644
index 00000000..4cd92af8
--- /dev/null
+++ b/app/Template/task_import/sidebar.php
@@ -0,0 +1,9 @@
+<div class="sidebar">
+ <h2><?= t('Imports') ?></h2>
+ <ul>
+ <li <?= $this->app->checkMenuSelection('TaskImportController', 'show') ?>>
+ <?= $this->url->link(t('Tasks').' (CSV)', 'TaskImportController', 'show', array('project_id' => $project['id'])) ?>
+ </li>
+ <?= $this->hook->render('template:task-import:sidebar') ?>
+ </ul>
+</div>