| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace Atk4\Ui; |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | class TabsTab extends MenuItem |
| 11: | { |
| 12: | |
| 13: | public $path; |
| 14: | |
| 15: | |
| 16: | public $settings = []; |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | public function setPath($page) |
| 24: | { |
| 25: | $this->path = $this->getApp()->url($page) . '#'; |
| 26: | |
| 27: | return $this; |
| 28: | } |
| 29: | |
| 30: | #[\Override] |
| 31: | protected function renderView(): void |
| 32: | { |
| 33: | $this->settings = array_merge($this->settings, ['autoTabActivation' => false]); |
| 34: | |
| 35: | if ($this->path) { |
| 36: | $this->settings = array_merge_recursive($this->settings, [ |
| 37: | 'cache' => false, |
| 38: | 'auto' => true, |
| 39: | 'path' => $this->path, |
| 40: | 'apiSettings' => ['data' => ['__atk_tab' => 1]], |
| 41: | ]); |
| 42: | } |
| 43: | |
| 44: | $this->js(true)->tab($this->settings); |
| 45: | |
| 46: | if ($this->getOwner()->activeTabName === $this->name) { |
| 47: | $this->js(true)->click(); |
| 48: | } |
| 49: | |
| 50: | parent::renderView(); |
| 51: | } |
| 52: | } |
| 53: | |