Config Controller and Template

This commit is contained in:
2026-06-28 17:03:37 -03:00
parent e6479c9ed9
commit fa23d7a64c
4 changed files with 70 additions and 0 deletions

View 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').' &gt; '.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
View 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>

View File

@@ -0,0 +1,3 @@
<li <?= $this->app->checkMenuSelection('ConfigController', 'show', 'ShrinkVertically') ?>>
<?= $this->url->link(t('Shrink Vertically'), 'ConfigController', 'show', array('plugin' => 'ShrinkVertically')) ?>
</li>

View File

@@ -0,0 +1,3 @@
<style type="text/css">
:root { --sv-shrink-offset: <?= (int) $this->app->config('shrink_vertically_offset', 240) ?>px; }
</style>