Skip to content

Commit

Permalink
Use Fomantic UI "url" directly instead of "auto path" for Tab (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek authored Jan 31, 2025
1 parent a76998b commit 48213c1
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions js/src/Service/accordionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class AccordionService {
}

onOpening() {
if ($(this).data('path')) {
$(this).atkReloadView({ url: $(this).data('path'), urlOptions: { __atk_json: 1 } });
if ($(this).data('url')) {
$(this).atkReloadView({ url: $(this).data('url'), urlOptions: { __atk_json: 1 } });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ parameters:
-
path: 'src/Tabs.php'
identifier: method.notFound
message: '~^Call to an undefined method Atk4\\Ui\\View::setPath\(\)\.$~'
message: '~^Call to an undefined method Atk4\\Ui\\View::setUrl\(\)\.$~'
count: 2
-
path: 'src/Tabs.php'
Expand Down
4 changes: 2 additions & 2 deletions public/js/atkjs-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1985,9 +1985,9 @@ class AccordionService {
}];
}
onOpening() {
if (external_jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('path')) {
if (external_jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('url')) {
external_jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).atkReloadView({
url: external_jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('path'),
url: external_jquery__WEBPACK_IMPORTED_MODULE_0___default()(this).data('url'),
urlOptions: {
__atk_json: 1
}
Expand Down
2 changes: 1 addition & 1 deletion public/js/atkjs-ui.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/atkjs-ui.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/atkjs-ui.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/AccordionSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function renderView(): void

if ($this->virtualPage) {
$this->template->set('itemId', $this->virtualPage->name);
$this->template->set('path', $this->virtualPage->getJsUrl('cut'));
$this->template->set('url', $this->virtualPage->getJsUrl('cut'));
} else {
// TODO hack to prevent rendering 'id=""'
$this->template->set('itemId', $this->name . '-vp-unused');
Expand Down
4 changes: 2 additions & 2 deletions src/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function addTab($name, ?\Closure $callback = null, array $settings = [])
// if there is callback action, then use VirtualPage
if ($callback) {
$vp = VirtualPage::addTo($sub, ['ui' => '']);
$item->setPath($vp->getJsUrl('cut'));
$item->setUrl($vp->getJsUrl('cut'));

$vp->set($callback);
}
Expand All @@ -50,7 +50,7 @@ public function addTabUrl($name, $page, array $settings = []): void
$item = $this->addTabMenuItem($name, $settings);
$this->addSubView($item->name);

$item->setPath($page);
$item->setUrl($page);
}

/**
Expand Down
11 changes: 5 additions & 6 deletions src/TabsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class TabsTab extends MenuItem
{
/** @var string */
public $path;
public $url;

/** @var array<string, mixed> Tab settings */
public $settings = [];
Expand All @@ -20,9 +20,9 @@ class TabsTab extends MenuItem
*
* @return $this
*/
public function setPath($page)
public function setUrl($page)
{
$this->path = $this->getApp()->url($page) . '#';
$this->url = $this->getApp()->url($page);

return $this;
}
Expand All @@ -32,10 +32,9 @@ protected function renderView(): void
{
$this->settings = array_merge($this->settings, ['autoTabActivation' => false]);

if ($this->path) {
if ($this->url) {
$this->settings['cache'] = false;
$this->settings['auto'] = true;
$this->settings['path'] = $this->path;
$this->settings['apiSettings']['url'] = $this->url;
$this->settings['apiSettings']['data']['__atk_tab'] = 1;
}

Expand Down
2 changes: 1 addition & 1 deletion template/accordion-section.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<div class="title" {$attributes}><i class="{$icon} icon"></i>{title}Title{/}</div>
<div class="content ui basic segment" data-path="{$path}">
<div class="content ui basic segment" data-url="{$url}">
<div id="{$itemId}">{$Content}</div>
</div>
2 changes: 1 addition & 1 deletion template/accordion-section.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
div(class="title", {$attributes})
i(class="{$icon} icon")
| {title}Title{/}
div(class="content ui basic segment" data-path="{$path}")
div(class="content ui basic segment" data-url="{$url}")
div(id="{$itemId}")
| {$Content}
= "\n"

0 comments on commit 48213c1

Please sign in to comment.