Enh #4216: Added humhub\modules\ui\filter\widgets\DropdownFilterInput in order to support dropdown stream filters

This commit is contained in:
buddh4 2020-07-10 17:48:22 +02:00
parent 90f5b630e8
commit 9764c8106b
4 changed files with 81 additions and 0 deletions

View File

@ -17,3 +17,4 @@ HumHub Change Log
- Enh: Added `humhub\modules\ui\form\widgets\ActiveField:preventRendering` to manage render state within field classes - Enh: Added `humhub\modules\ui\form\widgets\ActiveField:preventRendering` to manage render state within field classes
- Enh: Added `humhub\modules\ui\form\widgets\JsInputWidget:emptyResult()` helper to manage render state of JsInputWidget - Enh: Added `humhub\modules\ui\form\widgets\JsInputWidget:emptyResult()` helper to manage render state of JsInputWidget
- Enh: Added `humhub\modules\ui\form\widgets\JsInputWidget:field` in order to access ActiveField instances within JsInputWidget - Enh: Added `humhub\modules\ui\form\widgets\JsInputWidget:field` in order to access ActiveField instances within JsInputWidget
- Enh #4216: Added `humhub\modules\ui\filter\widgets\DropdownFilterInput` in order to support dropdown stream filters

View File

@ -156,6 +156,7 @@ humhub.module('ui.filter', function(module, require, $) {
'checkbox': CheckBoxInput, 'checkbox': CheckBoxInput,
'radio': RadioInput, 'radio': RadioInput,
'picker': PickerInput, 'picker': PickerInput,
'dropdown': TextInput, // don't need a custom input type here
'text': TextInput 'text': TextInput
}; };

View File

@ -0,0 +1,61 @@
<?php
/**
* Created by PhpStorm.
* User: kingb
* Date: 05.10.2018
* Time: 21:14
*/
namespace humhub\modules\ui\filter\widgets;
use humhub\modules\ui\filter\widgets\FilterInput;
use humhub\libs\Html;
/**
* Dropdown stream filter input type.
*
* @package humhub\modules\ui\filter\widgets
*/
class DropdownFilterInput extends FilterInput
{
/**
* @inheritdoc
*/
public $view = 'dropdownInput';
/**
* @inheritdoc
*/
public $type = 'dropdown';
/**
* @var array dropdown selection
*/
public $selection = [];
/**
* @var array dropdown items
*/
public $items = [];
/**
* @inheritdoc
*/
public function prepareOptions()
{
parent::prepareOptions();
$this->options['data-action-change'] = 'inputChange';
Html::addCssClass($this->options, 'form-control');
}
/**
* @inheritdoc
*/
protected function getWidgetOptions()
{
return array_merge(parent::getWidgetOptions(), [
'selection' => $this->selection,
'items' => $this->items
]);
}
}

View File

@ -0,0 +1,18 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*
*/
use yii\bootstrap\Html;
/* @var $this \humhub\components\View */
/* @var $options [] */
/* @var $selection [] */
/* @var $items [] */
?>
<div class="form-group">
<?= Html::dropDownList(null, $selection, $items, $options) ?>
</div>