| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace Atk4\Ui; |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | class JsSearch extends View |
| 12: | { |
| 13: | public $ui = 'left icon action transparent input'; |
| 14: | public $defaultTemplate = 'js-search.html'; |
| 15: | |
| 16: | |
| 17: | public $reload; |
| 18: | |
| 19: | |
| 20: | public $args = []; |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | public $autoQuery = false; |
| 29: | |
| 30: | |
| 31: | public $placeHolder = 'Search'; |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | public $initValue; |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | |
| 53: | public $useAjax = true; |
| 54: | |
| 55: | |
| 56: | public $button = 'ui mini transparent basic button'; |
| 57: | |
| 58: | public $filterIcon = 'filter'; |
| 59: | |
| 60: | public $buttonSearchIcon = 'search'; |
| 61: | |
| 62: | public $buttonRemoveIcon = 'red remove'; |
| 63: | |
| 64: | public $buttonStyle; |
| 65: | |
| 66: | #[\Override] |
| 67: | protected function init(): void |
| 68: | { |
| 69: | parent::init(); |
| 70: | } |
| 71: | |
| 72: | #[\Override] |
| 73: | protected function renderView(): void |
| 74: | { |
| 75: | if ($this->placeHolder) { |
| 76: | $this->template->trySet('Placeholder', $this->placeHolder); |
| 77: | } |
| 78: | |
| 79: | if ($this->buttonStyle) { |
| 80: | $this->template->trySet('buttonStyle', $this->buttonStyle); |
| 81: | } |
| 82: | |
| 83: | $this->template->set('Button', $this->button); |
| 84: | $this->template->set('FilterIcon', $this->filterIcon); |
| 85: | $this->template->set('ButtonSearchIcon', $this->buttonSearchIcon); |
| 86: | $this->template->set('ButtonRemoveIcon', $this->buttonRemoveIcon); |
| 87: | |
| 88: | $this->js(true)->atkJsSearch([ |
| 89: | 'url' => $this->reload->jsUrl(), |
| 90: | 'urlOptions' => array_merge(['__atk_reload' => $this->reload->name], $this->args), |
| 91: | 'urlQueryKey' => $this->name . '_q', |
| 92: | 'autoQuery' => $this->autoQuery, |
| 93: | 'q' => $this->initValue, |
| 94: | 'useAjax' => $this->useAjax, |
| 95: | ]); |
| 96: | |
| 97: | parent::renderView(); |
| 98: | } |
| 99: | } |
| 100: | |