From ed074d176406ca3ce5ba8fa6e0c4511f729efa5b Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 28 May 2016 21:24:24 -0400 Subject: Move task import outside of project settings --- ChangeLog | 1 + app/Controller/TaskImportController.php | 33 +++++++++++++++---------------- app/ServiceProvider/RouteProvider.php | 4 +++- app/Template/export/sidebar.php | 8 ++++---- app/Template/project/sidebar.php | 5 +---- app/Template/project_header/dropdown.php | 9 ++++++++- app/Template/task_import/show.php | 34 ++++++++++++++++++++++++++++++++ app/Template/task_import/sidebar.php | 9 +++++++++ app/Template/task_import/step1.php | 34 -------------------------------- 9 files changed, 76 insertions(+), 61 deletions(-) create mode 100644 app/Template/task_import/show.php create mode 100644 app/Template/task_import/sidebar.php delete mode 100644 app/Template/task_import/step1.php 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 @@