Config Controller and Template
This commit is contained in:
45
Controller/ConfigController.php
Normal file
45
Controller/ConfigController.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Plugin\ShrinkVertically\Controller;
|
||||
|
||||
use Kanboard\Controller\BaseController;
|
||||
|
||||
/**
|
||||
* Settings page for the ShrinkVertically plugin: configure how many pixels are
|
||||
* reserved around the vertically collapsed board columns.
|
||||
*/
|
||||
class ConfigController extends BaseController
|
||||
{
|
||||
const DEFAULT_OFFSET = 240;
|
||||
const MIN_OFFSET = 0;
|
||||
const MAX_OFFSET = 2000;
|
||||
|
||||
public function show()
|
||||
{
|
||||
$offset = (int) $this->configModel->get('shrink_vertically_offset', self::DEFAULT_OFFSET);
|
||||
|
||||
$this->response->html($this->helper->layout->config('shrinkVertically:config/show', array(
|
||||
'title' => t('Settings').' > '.t('Shrink Vertically'),
|
||||
'values' => array(
|
||||
'shrink_vertically_offset' => $offset,
|
||||
),
|
||||
'errors' => array(),
|
||||
)));
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$values = $this->request->getValues();
|
||||
|
||||
$offset = isset($values['shrink_vertically_offset']) ? (int) $values['shrink_vertically_offset'] : self::DEFAULT_OFFSET;
|
||||
$offset = max(self::MIN_OFFSET, min(self::MAX_OFFSET, $offset));
|
||||
|
||||
if ($this->configModel->save(array('shrink_vertically_offset' => $offset))) {
|
||||
$this->flash->success(t('Settings saved successfully.'));
|
||||
} else {
|
||||
$this->flash->failure(t('Unable to save your settings.'));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('ConfigController', 'show', array('plugin' => 'ShrinkVertically')));
|
||||
}
|
||||
}
|
||||
19
Template/config/show.php
Normal file
19
Template/config/show.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="page-header">
|
||||
<h2><?= t('Shrink Vertically') ?></h2>
|
||||
</div>
|
||||
|
||||
<form method="post" action="<?= $this->url->href('ConfigController', 'save', array('plugin' => 'ShrinkVertically')) ?>" autocomplete="off">
|
||||
<?= $this->form->csrf() ?>
|
||||
|
||||
<fieldset>
|
||||
<?= $this->form->label(t('Vertical offset in pixels'), 'shrink_vertically_offset') ?>
|
||||
<?= $this->form->number('shrink_vertically_offset', $values, $errors) ?>
|
||||
<p class="form-help">
|
||||
<?= t('Pixels reserved above and below the vertically collapsed board columns (page header, column header and the horizontal scrollbar). A larger value makes the columns shorter. Default: 240.') ?>
|
||||
</p>
|
||||
</fieldset>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||
</div>
|
||||
</form>
|
||||
3
Template/config/sidebar.php
Normal file
3
Template/config/sidebar.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<li <?= $this->app->checkMenuSelection('ConfigController', 'show', 'ShrinkVertically') ?>>
|
||||
<?= $this->url->link(t('Shrink Vertically'), 'ConfigController', 'show', array('plugin' => 'ShrinkVertically')) ?>
|
||||
</li>
|
||||
3
Template/layout/variable.php
Normal file
3
Template/layout/variable.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<style type="text/css">
|
||||
:root { --sv-shrink-offset: <?= (int) $this->app->config('shrink_vertically_offset', 240) ?>px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user