From ca00b8cf532bd93419e3f4bc46f9dde5caa90eec Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 8 Jan 2017 15:31:33 -0500 Subject: Display project exports in modal box --- app/Controller/ExportController.php | 34 +++++++++++++++++--------------- app/Template/export/header.php | 17 ++++++++++++++++ app/Template/export/sidebar.php | 17 ---------------- app/Template/export/subtasks.php | 16 ++++++--------- app/Template/export/summary.php | 16 ++++++--------- app/Template/export/tasks.php | 16 ++++++--------- app/Template/export/transitions.php | 17 ++++++---------- app/Template/project_header/dropdown.php | 2 +- 8 files changed, 60 insertions(+), 75 deletions(-) create mode 100644 app/Template/export/header.php delete mode 100644 app/Template/export/sidebar.php (limited to 'app') diff --git a/app/Controller/ExportController.php b/app/Controller/ExportController.php index b7ac92aa..19f73a7c 100644 --- a/app/Controller/ExportController.php +++ b/app/Controller/ExportController.php @@ -24,27 +24,29 @@ class ExportController extends BaseController private function common($model, $method, $filename, $action, $page_title) { $project = $this->getProject(); - $from = $this->request->getStringParam('from'); - $to = $this->request->getStringParam('to'); - if ($from && $to) { - $data = $this->$model->$method($project['id'], $from, $to); - $this->response->withFileDownload($filename.'.csv'); - $this->response->csv($data); - } else { + if ($this->request->isPost()) { + $values = $this->request->getValues(); + $from = empty($values['from']) ? '' : $values['from']; + $to = empty($values['to']) ? '' : $values['to']; - $this->response->html($this->helper->layout->project('export/'.$action, array( - 'values' => array( - 'controller' => 'ExportController', - 'action' => $action, + if ($from && $to) { + $data = $this->$model->$method($project['id'], $from, $to); + $this->response->withFileDownload($filename.'.csv'); + $this->response->csv($data); + return; + } + } else { + $this->response->html($this->template->render('export/'.$action, array( + 'values' => array( 'project_id' => $project['id'], - 'from' => $from, - 'to' => $to, + 'from' => '', + 'to' => '', ), - 'errors' => array(), + 'errors' => array(), 'project' => $project, - 'title' => $page_title, - ), 'export/sidebar')); + 'title' => $page_title, + ))); } } diff --git a/app/Template/export/header.php b/app/Template/export/header.php new file mode 100644 index 00000000..35591352 --- /dev/null +++ b/app/Template/export/header.php @@ -0,0 +1,17 @@ + diff --git a/app/Template/export/sidebar.php b/app/Template/export/sidebar.php deleted file mode 100644 index 463c0cee..00000000 --- a/app/Template/export/sidebar.php +++ /dev/null @@ -1,17 +0,0 @@ - diff --git a/app/Template/export/subtasks.php b/app/Template/export/subtasks.php index 959f0e47..0e47772b 100644 --- a/app/Template/export/subtasks.php +++ b/app/Template/export/subtasks.php @@ -1,20 +1,16 @@ - +render('export/header', array('project' => $project, 'title' => $title)) ?>

-
- - form->hidden('controller', $values) ?> - form->hidden('action', $values) ?> + + form->csrf() ?> form->hidden('project_id', $values) ?> form->date(t('Start date'), 'from', $values) ?> form->date(t('End date'), 'to', $values) ?> -
-
- + + + url->link(t('cancel'), 'ExportController', 'subtasks', array('project_id' => $project['id']), false, 'js-modal-close') ?>
diff --git a/app/Template/export/summary.php b/app/Template/export/summary.php index a7483fcb..7dc7482f 100644 --- a/app/Template/export/summary.php +++ b/app/Template/export/summary.php @@ -1,20 +1,16 @@ - +render('export/header', array('project' => $project, 'title' => $title)) ?>

-
- form->hidden('controller', $values) ?> - form->hidden('action', $values) ?> + + form->csrf() ?> form->hidden('project_id', $values) ?> - form->date(t('Start date'), 'from', $values) ?> form->date(t('End date'), 'to', $values) ?> -
-
- + + + url->link(t('cancel'), 'ExportController', 'summary', array('project_id' => $project['id']), false, 'js-modal-close') ?>
diff --git a/app/Template/export/tasks.php b/app/Template/export/tasks.php index ce1c869e..232ff8eb 100644 --- a/app/Template/export/tasks.php +++ b/app/Template/export/tasks.php @@ -1,20 +1,16 @@ - +render('export/header', array('project' => $project, 'title' => $title)) ?>

-
- form->hidden('controller', $values) ?> - form->hidden('action', $values) ?> + + form->csrf() ?> form->hidden('project_id', $values) ?> - form->date(t('Start date'), 'from', $values) ?> form->date(t('End date'), 'to', $values) ?> -
-
- + + + url->link(t('cancel'), 'ExportController', 'tasks', array('project_id' => $project['id']), false, 'js-modal-close') ?>
diff --git a/app/Template/export/transitions.php b/app/Template/export/transitions.php index 7cd355db..4f3749b8 100644 --- a/app/Template/export/transitions.php +++ b/app/Template/export/transitions.php @@ -1,21 +1,16 @@ - +render('export/header', array('project' => $project, 'title' => $title)) ?>

-
- - form->hidden('controller', $values) ?> - form->hidden('action', $values) ?> + + form->csrf() ?> form->hidden('project_id', $values) ?> - form->date(t('Start date'), 'from', $values) ?> form->date(t('End date'), 'to', $values) ?> -
-
- + + + url->link(t('cancel'), 'ExportController', 'transitions', array('project_id' => $project['id']), false, 'js-modal-close') ?>
diff --git a/app/Template/project_header/dropdown.php b/app/Template/project_header/dropdown.php index 96b26890..83c2b97f 100644 --- a/app/Template/project_header/dropdown.php +++ b/app/Template/project_header/dropdown.php @@ -52,7 +52,7 @@ user->hasProjectAccess('ExportController', 'tasks', $project['id'])): ?>
  • - url->icon('upload', t('Exports'), 'ExportController', 'tasks', array('project_id' => $project['id'])) ?> + modal->medium('upload', t('Exports'), 'ExportController', 'tasks', array('project_id' => $project['id'])) ?>
  • -- cgit v1.2.3