From dd2254ab87d76549dfafda5587aa5bd31ca07e1d Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Thu, 7 Sep 2023 08:55:44 -0400 Subject: [PATCH 1/3] Update Page.php --- src/Page.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Page.php b/src/Page.php index c831318..43ef18c 100644 --- a/src/Page.php +++ b/src/Page.php @@ -28,16 +28,20 @@ class Page extends View public string $title = ''; protected ?Layout $layout = null; + /** Used a specific js package version or leave empty for latest. ex: '1.5.0' */ + public string $fohnJsVersion = ''; + public string $jQueryVersion = ''; + public ?string $toastSelector = '#fohn-toast'; public string $jsBundleLocation = '/public'; /** An array of Js packages to include in Page. */ public array $jsPackages = [ 'jquery' => [ - 'url' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js', + 'url' => 'https://unpkg.com/jquery', ], 'fohn-js' => [ - 'url' => 'https://unpkg.com/fohn-ui@1.5.0/dist/fohn-ui.min.js', + 'url' => 'https://unpkg.com/fohn-ui', ], ]; @@ -60,6 +64,14 @@ protected function initRenderTree(): void { parent::initRenderTree(); + if ($this->fohnJsVersion) { + $this->includeJsPackage('fohn-js', 'https://unpkg.com/fohn-ui@' . $this->fohnJsVersion); + } + + if ($this->jQueryVersion) { + $this->includeJsPackage('jquery', 'https://unpkg.com/jquery@' . $this->jQueryVersion); + } + Ui::theme()::styleAs(Base::PAGE, [$this]); } From c43aca70df05b5f3e92131d368cf2efe219a62db Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Thu, 7 Sep 2023 09:26:39 -0400 Subject: [PATCH 2/3] fix entity->isLoaded --- src/Service/Atk/FormControlFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Service/Atk/FormControlFactory.php b/src/Service/Atk/FormControlFactory.php index efcd4da..19bef42 100644 --- a/src/Service/Atk/FormControlFactory.php +++ b/src/Service/Atk/FormControlFactory.php @@ -220,7 +220,7 @@ protected function factorySelect(Field $field): Control $control->onSetValue(function ($value) use ($refModel) { if ($value) { $refEntity = $refModel->tryLoad($value); - if ($refEntity->isLoaded()) { + if ($refEntity) { $selectableItems[$value] = $refEntity->get($refEntity->titleField); } } @@ -236,7 +236,7 @@ protected function factorySelect(Field $field): Control $items = self::getSelectItems($refModel); if ($value && !in_array($value, array_column($items, Control\Select::KEY), true)) { $refEntity = $refModel->tryLoad($value); - if ($refEntity->isLoaded()) { + if ($refEntity) { $newItems = [Control\Select::KEY => $value, Control\Select::LABEL => $refEntity->get($refEntity->titleField)]; array_unshift($items, $newItems); } From 5812f5304b40d7604a000a48a85c89074dbe4362 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Thu, 7 Sep 2023 09:40:06 -0400 Subject: [PATCH 3/3] use wildcard in version --- src/Page.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Page.php b/src/Page.php index 43ef18c..6977116 100644 --- a/src/Page.php +++ b/src/Page.php @@ -28,9 +28,9 @@ class Page extends View public string $title = ''; protected ?Layout $layout = null; - /** Used a specific js package version or leave empty for latest. ex: '1.5.0' */ - public string $fohnJsVersion = ''; - public string $jQueryVersion = ''; + /** Used a specific js package version, ex: '1.5.0', a wildcard or leave empty for latest. */ + public string $fohnJsVersion = '^1'; + public string $jQueryVersion = '^3'; public ?string $toastSelector = '#fohn-toast'; public string $jsBundleLocation = '/public';