diff --git a/ChangeLog b/ChangeLog
index e833f84c0..918d618fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@ Improvements:
* Display project analytics in modal box
* Display project exports in modal box
* Improve accordion component
+* Improve currencies pages navigation
* Offer the possibility to define version compatibility from plugins
Version 1.0.36 (Dec 30, 2016)
diff --git a/app/Controller/CurrencyController.php b/app/Controller/CurrencyController.php
index ad5900352..2b2275acd 100644
--- a/app/Controller/CurrencyController.php
+++ b/app/Controller/CurrencyController.php
@@ -11,21 +11,33 @@ namespace Kanboard\Controller;
class CurrencyController extends BaseController
{
/**
- * Display all currency rates and form
+ * Display all currency rates
+ *
+ * @access public
+ */
+ public function show()
+ {
+ $this->response->html($this->helper->layout->config('currency/show', array(
+ 'application_currency' => $this->configModel->get('application_currency'),
+ 'rates' => $this->currencyModel->getAll(),
+ 'currencies' => $this->currencyModel->getCurrencies(),
+ 'title' => t('Settings').' > '.t('Currency rates'),
+ )));
+ }
+
+ /**
+ * Add or change currency rate
*
* @access public
* @param array $values
* @param array $errors
*/
- public function index(array $values = array(), array $errors = array())
+ public function create(array $values = array(), array $errors = array())
{
- $this->response->html($this->helper->layout->config('currency/index', array(
- 'config_values' => array('application_currency' => $this->configModel->get('application_currency')),
+ $this->response->html($this->helper->layout->config('currency/create', array(
'values' => $values,
'errors' => $errors,
- 'rates' => $this->currencyModel->getAll(),
'currencies' => $this->currencyModel->getCurrencies(),
- 'title' => t('Settings').' > '.t('Currency rates'),
)));
}
@@ -34,7 +46,7 @@ class CurrencyController extends BaseController
*
* @access public
*/
- public function create()
+ public function save()
{
$values = $this->request->getValues();
list($valid, $errors) = $this->currencyValidator->validateCreation($values);
@@ -42,13 +54,34 @@ class CurrencyController extends BaseController
if ($valid) {
if ($this->currencyModel->create($values['currency'], $values['rate'])) {
$this->flash->success(t('The currency rate have been added successfully.'));
- return $this->response->redirect($this->helper->url->to('CurrencyController', 'index'));
+ $this->response->redirect($this->helper->url->to('CurrencyController', 'show'), true);
+ return;
} else {
$this->flash->failure(t('Unable to add this currency rate.'));
}
}
- return $this->index($values, $errors);
+ $this->create($values, $errors);
+ }
+
+ /**
+ * Change reference currency
+ *
+ * @access public
+ * @param array $values
+ * @param array $errors
+ */
+ public function change(array $values = array(), array $errors = array())
+ {
+ if (empty($values)) {
+ $values['application_currency'] = $this->configModel->get('application_currency');
+ }
+
+ $this->response->html($this->helper->layout->config('currency/change', array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'currencies' => $this->currencyModel->getCurrencies(),
+ )));
}
/**
@@ -56,7 +89,7 @@ class CurrencyController extends BaseController
*
* @access public
*/
- public function reference()
+ public function update()
{
$values = $this->request->getValues();
@@ -66,6 +99,6 @@ class CurrencyController extends BaseController
$this->flash->failure(t('Unable to save your settings.'));
}
- $this->response->redirect($this->helper->url->to('CurrencyController', 'index'));
+ $this->response->redirect($this->helper->url->to('CurrencyController', 'show'), true);
}
}
diff --git a/app/Template/config/sidebar.php b/app/Template/config/sidebar.php
index 239edc19e..f35efde08 100644
--- a/app/Template/config/sidebar.php
+++ b/app/Template/config/sidebar.php
@@ -24,8 +24,8 @@
app->checkMenuSelection('LinkController') ?>>
= $this->url->link(t('Link settings'), 'LinkController', 'index') ?>
- app->checkMenuSelection('CurrencyController', 'index') ?>>
- = $this->url->link(t('Currency rates'), 'CurrencyController', 'index') ?>
+ app->checkMenuSelection('CurrencyController', 'show') ?>>
+ = $this->url->link(t('Currency rates'), 'CurrencyController', 'show') ?>
app->checkMenuSelection('ConfigController', 'integrations') ?>>
= $this->url->link(t('Integrations'), 'ConfigController', 'integrations') ?>
diff --git a/app/Template/currency/change.php b/app/Template/currency/change.php
new file mode 100644
index 000000000..59a7ce375
--- /dev/null
+++ b/app/Template/currency/change.php
@@ -0,0 +1,9 @@
+
+
diff --git a/app/Template/currency/create.php b/app/Template/currency/create.php
new file mode 100644
index 000000000..578ece818
--- /dev/null
+++ b/app/Template/currency/create.php
@@ -0,0 +1,11 @@
+
+
diff --git a/app/Template/currency/index.php b/app/Template/currency/index.php
deleted file mode 100644
index db9b21afa..000000000
--- a/app/Template/currency/index.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
- | = t('Currency') ?> |
- = t('Rate') ?> |
-
-
-
- |
- = $this->text->e($rate['currency']) ?>
- |
-
- = n($rate['rate']) ?>
- |
-
-
-
-
-
-= t('Change reference currency') ?>
-
-
-
-
-= t('Add a new currency rate') ?>
-
diff --git a/app/Template/currency/show.php b/app/Template/currency/show.php
new file mode 100644
index 000000000..4b7f34bca
--- /dev/null
+++ b/app/Template/currency/show.php
@@ -0,0 +1,34 @@
+
+
+
+ = t('Reference currency: %s', $application_currency) ?>
+
+
+
+
+
+ | = t('Currency') ?> |
+ = t('Rate') ?> |
+
+
+
+ |
+ = $this->text->e($rate['currency']) ?>
+ |
+
+ = n($rate['rate']) ?>
+ |
+
+
+
+