From d9c86e92baf9c9ba67049a412a6122452bef88f0 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Tue, 25 Jul 2023 09:52:46 -0400 Subject: [PATCH 01/37] fix component form method name --- src/Component/Form.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Component/Form.php b/src/Component/Form.php index a9b03a5..51c9933 100644 --- a/src/Component/Form.php +++ b/src/Component/Form.php @@ -186,7 +186,7 @@ public function addControl(Form\Control $control, string $layoutName = self::MAI protected function registerControl(Control $control): void { - $this->assertControlAsName($control->getControlName()); + $this->assertControlHasName($control->getControlName()); $this->assertControlIsUnique($control->getControlName()); $control->formStoreId = $this->getPiniaStoreId(self::PINIA_PREFIX); $this->controls[$control->getControlName()] = $control; @@ -282,7 +282,7 @@ private function assertControlIsUnique(string $controlName): void } } - private function assertControlAsName(string $controlName): void + private function assertControlHasName(string $controlName): void { if (!$controlName) { throw new Exception('Trying to add a form control without name.'); From bb174e926b492223d422c3647a82e0ccf01adaea Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Tue, 25 Jul 2023 09:53:11 -0400 Subject: [PATCH 02/37] fix form component template --- template/tailwind/vue-component/form.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/template/tailwind/vue-component/form.html b/template/tailwind/vue-component/form.html index aed6a44..640e9a4 100644 --- a/template/tailwind/vue-component/form.html +++ b/template/tailwind/vue-component/form.html @@ -6,7 +6,9 @@ :can-leave="{$canLeave}" :submit-url="{$submitUrl}" :values-url="{$valuesUrl}" - #default="@{isSubmitting, canLeave, formErrors, submitForm, setControlValue, isDirty, storeId}" ref="root" class="invisible"> + #default="@{isSubmitting, canLeave, formErrors, submitForm, setControlValue, isDirty, storeId}" + ref="root" + class="invisible">
{$Layouts}
From d89d16e05f34fe3b915d8994cfffa196cb81ea16 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Tue, 25 Jul 2023 09:53:24 -0400 Subject: [PATCH 03/37] Create tab.html --- template/tailwind/vue-component/tabs/tab.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 template/tailwind/vue-component/tabs/tab.html diff --git a/template/tailwind/vue-component/tabs/tab.html b/template/tailwind/vue-component/tabs/tab.html new file mode 100644 index 0000000..7188ba1 --- /dev/null +++ b/template/tailwind/vue-component/tabs/tab.html @@ -0,0 +1,15 @@ + + +
{$Content}
+
+
From a9c6fbaf25f6f4c6f12d1226749bd15a4d09eb35 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Tue, 25 Jul 2023 09:53:28 -0400 Subject: [PATCH 04/37] Create tabs.html --- template/tailwind/vue-component/tabs.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 template/tailwind/vue-component/tabs.html diff --git a/template/tailwind/vue-component/tabs.html b/template/tailwind/vue-component/tabs.html new file mode 100644 index 0000000..9811dc8 --- /dev/null +++ b/template/tailwind/vue-component/tabs.html @@ -0,0 +1,22 @@ +
+ +
From a0d2916380fb0a8639c748c08f605fa49cf47100 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Tue, 25 Jul 2023 09:53:38 -0400 Subject: [PATCH 05/37] Create Tabs.php --- src/Component/Tabs.php | 93 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/Component/Tabs.php diff --git a/src/Component/Tabs.php b/src/Component/Tabs.php new file mode 100644 index 0000000..68fcfd8 --- /dev/null +++ b/src/Component/Tabs.php @@ -0,0 +1,93 @@ + */ + protected array $tabs = []; + + protected function initRenderTree(): void + { + parent::initRenderTree(); + } + + public function addTab(Tab $tab): Tab + { + $this->registerTab($tab); + $this->addView($tab, self::TAB_REGION_NAME); + + return $tab; + } + + protected function registerTab(Tab $tab): void + { + $this->assertTabHasName($tab->getName()); + $this->assertTabIsUnique($tab->getName()); + + if (!$tab->getCaption()) { + $tab->setCaption(ucfirst($tab->getName())); + } + + $tab->tabStoreId = $this->getPiniaStoreId(self::PINIA_PREFIX); + $this->tabs[$tab->getName()] = $tab; + } + + private function assertTabHasName(string $tabName): void + { + if (!$tabName) { + throw new Exception('Tab must have a name.'); + } + } + + private function assertTabIsUnique(string $tabName): void + { + if (array_key_exists($tabName, $this->tabs)) { + throw (new Exception('This tab name is already added.')) + ->addMoreInfo('Tab name:', $tabName); + } + } + + protected function setTemplateProps(): void + { + $props['storeId'] = $this->getPiniaStoreId(self::PINIA_PREFIX); + + $tabList = []; + foreach ($this->tabs as $tab) { + $tabList[] = ['name' => $tab->getName(), 'caption' => $tab->getCaption()]; + } + $props['tabList'] = $tabList; + + foreach ($props as $key => $value) { + $this->getTemplate()->setJs($key, Type::factory($value)); + } + } + + protected function beforeHtmlRender(): void + { + // todo move into props + $this->setTemplateProps(); + + $this->createVueApp(self::COMP_NAME, [], $this->getDefaultSelector()); + parent::beforeHtmlRender(); + } +} From e9475896fcf8ffb5faeb5f29e5b8b84550862043 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Tue, 25 Jul 2023 09:53:45 -0400 Subject: [PATCH 06/37] Create Tab.php --- src/Component/Tab/Tab.php | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/Component/Tab/Tab.php diff --git a/src/Component/Tab/Tab.php b/src/Component/Tab/Tab.php new file mode 100644 index 0000000..9eefc2e --- /dev/null +++ b/src/Component/Tab/Tab.php @@ -0,0 +1,64 @@ +name; + } + + public function getCaption(): string + { + return $this->caption; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + public function setCaption(string $caption): self + { + $this->caption = $caption; + + return $this; + } + + protected function beforeHtmlRender(): void + { + $this->getTemplate()->trySetJs('tabName', Js::string($this->getName())); + $this->getTemplate()->trySetJs('tabStoreId', Js::string($this->tabStoreId)); + + + parent::beforeHtmlRender(); + } + +} From 907834fd91b00a7eb652c85ca6cd2bf27539107d Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Tue, 25 Jul 2023 09:54:30 -0400 Subject: [PATCH 07/37] add demo --- app-test/interactive/tabs.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app-test/interactive/tabs.php diff --git a/app-test/interactive/tabs.php b/app-test/interactive/tabs.php new file mode 100644 index 0000000..dee1f75 --- /dev/null +++ b/app-test/interactive/tabs.php @@ -0,0 +1,23 @@ +addTab(new Tab(['name' => 'home'])); + +$tab->addView((new View())->setTextContent('This is home tab')); + +$tab = $tabs->addTab(new Tab(['name' => 'profile'])); + + +$tab->addView((new View())->setTextContent('This is profile tab')); + +Ui::viewDump($tabs, 'tab'); From 4453fceebbac29e7f05c0cf81f6dc24bdb7485b8 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Wed, 26 Jul 2023 13:51:16 -0400 Subject: [PATCH 08/37] remove root ref from template --- template/tailwind/vue-component/form.html | 4 +--- template/tailwind/vue-component/navigation.html | 3 +-- template/tailwind/vue-component/tabs.html | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/template/tailwind/vue-component/form.html b/template/tailwind/vue-component/form.html index 640e9a4..ff49153 100644 --- a/template/tailwind/vue-component/form.html +++ b/template/tailwind/vue-component/form.html @@ -6,9 +6,7 @@ :can-leave="{$canLeave}" :submit-url="{$submitUrl}" :values-url="{$valuesUrl}" - #default="@{isSubmitting, canLeave, formErrors, submitForm, setControlValue, isDirty, storeId}" - ref="root" - class="invisible"> + #default="@{isSubmitting, canLeave, formErrors, submitForm, setControlValue, isDirty, storeId}">
{$Layouts}
diff --git a/template/tailwind/vue-component/navigation.html b/template/tailwind/vue-component/navigation.html index 2b835bc..7a368cf 100644 --- a/template/tailwind/vue-component/navigation.html +++ b/template/tailwind/vue-component/navigation.html @@ -5,8 +5,7 @@ menu-width="{width}52{/width}" break-point="{breakPoint}lg{/breakPoint}" #default="@{title, icons, groups, navigationCss, isOpen, inMobileMode, fn}" - class="fohn-admin-side-navigation text-sm invisible" - ref="root"> + class="fohn-admin-side-navigation text-sm">
diff --git a/template/tailwind/vue-component/tabs.html b/template/tailwind/vue-component/tabs.html index 9811dc8..4400cfb 100644 --- a/template/tailwind/vue-component/tabs.html +++ b/template/tailwind/vue-component/tabs.html @@ -2,9 +2,7 @@
- +