From f970e643e814a902465d13d2e1bcd2de0c2cd0f7 Mon Sep 17 00:00:00 2001 From: BrainFooLong Date: Mon, 8 Apr 2024 17:57:50 +0200 Subject: [PATCH] implemented JsRequestOptions->toDefaultAttrStr --- appdata/modules/Framelix/src/Html/Table.php | 2 +- .../src/Html/TypeDefs/JsRequestOptions.php | 14 +- .../Framelix/src/View/Backend/View.php | 299 +++++++++--------- .../FramelixDemo/src/StorableMeta/Invoice.php | 2 +- .../modules/FramelixDemo/src/View/Index.php | 8 +- .../modules/FramelixDemo/src/View/Reset.php | 12 +- .../FramelixDocs/src/View/Features/Layout.php | 143 +++++---- .../src/View/GetStarted/Issues.php | 57 ++-- .../src/View/GetStarted/Setup.php | 13 +- .../modules/FramelixDocs/src/View/View.php | 27 +- 10 files changed, 302 insertions(+), 275 deletions(-) diff --git a/appdata/modules/Framelix/src/Html/Table.php b/appdata/modules/Framelix/src/Html/Table.php index f317a6b..df1ecd8 100644 --- a/appdata/modules/Framelix/src/Html/Table.php +++ b/appdata/modules/Framelix/src/Html/Table.php @@ -335,7 +335,7 @@ public function setRowStorable(int $rowKey, Storable $storable, string $group = $cell = null; if($deleteUrl){ $requestOptions = new JsRequestOptions($deleteUrl); - $cell = TableCell::create(''); + $cell = TableCell::create('toDefaultAttrStr().'>'); } if (!in_array("_deletable", $this->columnOrder)) { array_unshift($this->columnOrder, "_deletable"); diff --git a/appdata/modules/Framelix/src/Html/TypeDefs/JsRequestOptions.php b/appdata/modules/Framelix/src/Html/TypeDefs/JsRequestOptions.php index d684ba3..09c7134 100644 --- a/appdata/modules/Framelix/src/Html/TypeDefs/JsRequestOptions.php +++ b/appdata/modules/Framelix/src/Html/TypeDefs/JsRequestOptions.php @@ -51,11 +51,10 @@ public function __construct( self::RENDER_TARGET_MODAL_NEW, self::RENDER_TARGET_CURRENT_CONTEXT, self::RENDER_TARGET_POPUP, - null + null, ])] public JsRenderTarget|string|null $renderTarget = null, - ) { - } + ) {} public function jsonSerialize(): array { @@ -66,4 +65,13 @@ public function jsonSerialize(): array return $data; } + /** + * Returns a request-options=attributeValue html string + * @return string + */ + public function toDefaultAttrStr(): string + { + return $this->toAttrValue('request-options'); + } + } \ No newline at end of file diff --git a/appdata/modules/Framelix/src/View/Backend/View.php b/appdata/modules/Framelix/src/View/Backend/View.php index 68611a4..e1657eb 100644 --- a/appdata/modules/Framelix/src/View/Backend/View.php +++ b/appdata/modules/Framelix/src/View/Backend/View.php @@ -161,33 +161,33 @@ public static function onJsCall(JsCall $jsCall): void $form->show(); ?> - + } + const darkModeToggle = FramelixFormField.getFieldByName(FramelixModal.modalsContainer, 'darkMode') + if (darkModeToggle) { + darkModeToggle.container.on(FramelixFormField.EVENT_CHANGE_USER, function () { + FramelixLocalStorage.set('framelix-darkmode', darkModeToggle.getValue() === '1') + FramelixDeviceDetection.updateAttributes() + }) + darkModeToggle.setValue(FramelixLocalStorage.get('framelix-darkmode')) + } + form.container.on('click', '.framelix_reset_alerts', function () { + FramelixCustomElementAlert.resetAllAlerts() + FramelixToast.success('__framelix_reset_alerts_done__') + }) + })() + '; echo '
'; ?> -
- -
- showTopBar) { - ?> -
- showSidebar) { - ?> - -
+ +
+ showTopBar) { + ?> +
+ showSidebar) { ?> -

getPageTitle(false) ?>

+ - - -
+ } + ?> +

getPageTitle(false) ?>

-
-
-
- -
-
-
+ if ($appIsSetup) { + ?> + + + + +
+
+
+ +
+
-
- +
+
+ '; echo HtmlUtils::getIncludeTagForUrl( @@ -387,85 +388,85 @@ public function showDefaultPageStartHtml(): void } } ?> - - - - metaRobots) { - echo ''; - } - ?> - <?= $this->getPageTitle(true) ?> - - - getGeneratedBundleUrl() - ); ?> - - - headHtml ?> - - headHtmlAfterInit ?> - + } + })() + + + getGeneratedBundleUrl() + ); ?> + + + headHtml ?> + + headHtmlAfterInit ?> + contentCallable = function () use ($message) { ?> - - - + + + showContentBasedOnRequestType(); diff --git a/appdata/modules/FramelixDemo/src/StorableMeta/Invoice.php b/appdata/modules/FramelixDemo/src/StorableMeta/Invoice.php index 6b7d8d2..8bfe377 100644 --- a/appdata/modules/FramelixDemo/src/StorableMeta/Invoice.php +++ b/appdata/modules/FramelixDemo/src/StorableMeta/Invoice.php @@ -77,7 +77,7 @@ protected function init(): void ['invoice' => $this->storable] ), new JsRenderTarget(modalOptions: new ModalShowOptions(maxWidth: 500)) ); - return TableCell::create(''); + return TableCell::create('toDefaultAttrStr() . '>'); }; if (!$isOffer) { diff --git a/appdata/modules/FramelixDemo/src/View/Index.php b/appdata/modules/FramelixDemo/src/View/Index.php index add0048..fb297ea 100644 --- a/appdata/modules/FramelixDemo/src/View/Index.php +++ b/appdata/modules/FramelixDemo/src/View/Index.php @@ -99,9 +99,11 @@ public function showContent(): void new password.

- ' - theme="primary" - icon="785">Reset password + toDefaultAttrStr() ?> + theme="primary" + icon="785"> + Reset password -

- ' - confirm-message="" - theme="primary" - icon="785"> +

+ toDefaultAttrStr() ?> + confirm-message="" + theme="primary" + icon="785"> -

- The layout you currently see is integrated in Framelix. - It has a dark mode support (Click at the right top corner icon). - The layout is self-made. It do not use external libraries like Bootstrap, Vue, or whatever. - It's all bare-metal and is just made to serve the things that are really required. - This reduce unused code and upgrade incompatibilites, as we are self responsible to keep the layout nice and - robust. -

-

- Even if this layout is the default, you can make pages without any default layout and starting from scratch. - This is often used to build a nice landing pages and frontend for the product and keep all specific data - management in the default layout. -

-

- The getLinkToInternalPage(Index::class) ?> landing page is an example for this. -

-

- All the features in the sidebar are made and displayed with the default layout. -

+

+ The layout you currently see is integrated in Framelix. + It has a dark mode support (Click at the right top corner icon). + The layout is self-made. It do not use external libraries like Bootstrap, Vue, or whatever. + It's all bare-metal and is just made to serve the things that are really required. + This reduce unused code and upgrade incompatibilites, as we are self responsible to keep the layout nice and + robust. +

+

+ Even if this layout is the default, you can make pages without any default layout and starting from scratch. + This is often used to build a nice landing pages and frontend for the product and keep all specific data + management in the default layout. +

+

+ The getLinkToInternalPage(Index::class) ?> landing page is an example for this. +

+

+ All the features in the sidebar are made and displayed with the default layout. +

getAnchoredTitle('components', 'Web Components - Custom Tags'); ?> -

- We have some custom web-components, all starting with <framelix- for the most common tasks, - like displaying a button that do things on-click. -

-

- A list of all web-components an there available attributes is - in getSourceFileLinkTag(["Framelix/dev/web-types/web-types.json"]) ?> -

-

- Here are a few examples. -

+

+ We have some custom web-components, all starting with <framelix- for the most common tasks, + like displaying a button that do things on-click. +

+

+ A list of all web-components an there available attributes is + in getSourceFileLinkTag(["Framelix/dev/web-types/web-types.json"]) ?> +

+

+ Here are a few examples. +

getAnchoredTitle('alert', 'Alert Box'); $this->addHtmlExecutableSnippet( @@ -95,7 +96,10 @@ public function showContent(): void toDefaultAttrStr() . ' block> There is some destructive action @@ -121,18 +125,18 @@ public function showContent(): void echo $this->getAnchoredTitle('icons', 'Icons (Microns)'); ?> -

- Framelix have a small icons font integrated, for the most commonly used icons. - It is small (7kb) compared to, for example, Material Icons (>150kb). - The icon set we use is called - getLinkToExternalPage('https://www.s-ings.com/projects/microns-icon-font/', 'Microns') ?> and is - also Open-Source. Thanks to the creator of this slick small icon set.
-

-

- You can use that icons with our handy custom tag ' - ) ?>. -

+

+ Framelix have a small icons font integrated, for the most commonly used icons. + It is small (7kb) compared to, for example, Material Icons (>150kb). + The icon set we use is called + getLinkToExternalPage('https://www.s-ings.com/projects/microns-icon-font/', 'Microns') ?> and is + also Open-Source. Thanks to the creator of this slick small icon set.
+

+

+ You can use that icons with our handy custom tag ' + ) ?>. +

showHtmlExecutableSnippetsCodeBlock(); ?> - - + }) + action === 'slack') { ?> -
- To join, please open this link
- https://join.slack.com/t/nullixat/shared_invite/zt-12elbg5rk-bZPR118cV1vzSw3pCWIUsw -
+
+ To join, please open this link
+ https://join.slack.com/t/nullixat/shared_invite/zt-12elbg5rk-bZPR118cV1vzSw3pCWIUsw +
-

- We know that being stuck at any point can be quite frustrating. There are some communication channels that - you can use to get in touch with the community. -

+

+ We know that being stuck at any point can be quite frustrating. There are some communication channels that + you can use to get in touch with the community. +

getAnchoredTitle('github', 'Forums (Recommended)') ?> -

- getLinkToExternalPage( - 'https://github.com/frmlx/framelix/discussions', - 'Github Discussions' - ) ?> - - There as a forums/discussion board where you can join. -

+

+ getLinkToExternalPage( + 'https://github.com/frmlx/framelix/discussions', + 'Github Discussions' + ) ?> + - There as a forums/discussion board where you can join. +

getAnchoredTitle('slack', 'Slack') ?> -

- Slack Members
- We also have a Slack channel. Click the button bellow to join. -

- ' icon="730" theme="primary"> - Join our Slack channel now - +

+ Slack Members
+ We also have a Slack channel. Click the button bellow to join. +

+ toDefaultAttrStr() ?> + icon="730" + theme="primary" + > + Join our Slack channel now + At first you need a docker-compose.yml. Click the button bellow to generate one

- ' theme="primary" - icon="798">Click here to create your docker-compose.yml + toDefaultAttrStr() ?> + theme="primary" + icon="798" + >Click here to create your docker-compose.yml getAnchoredTitle('start', 'Start container') ?> diff --git a/appdata/modules/FramelixDocs/src/View/View.php b/appdata/modules/FramelixDocs/src/View/View.php index 138fc19..ad0ab66 100644 --- a/appdata/modules/FramelixDocs/src/View/View.php +++ b/appdata/modules/FramelixDocs/src/View/View.php @@ -76,9 +76,9 @@ public static function onJsCall(JsCall $jsCall): void $view->addSourceFile($file); $view->showSourceFiles(); ?> - + action === 'phpCode') { @@ -331,13 +331,11 @@ public function showPhpExecutableMethodsCodeBlock(): void array_slice($lines, $method->getStartLine() + 1, $method->getEndLine() - $method->getStartLine()) ); $codeLanguage = "php"; - $buttonsHtml = ' $row['method']] - ), JsRequestOptions::RENDER_TARGET_MODAL_NEW - ) . '\' theme="primary" icon="789">Run the code bellow'; + $buttonsHtml = ' $row['method']]), + JsRequestOptions::RENDER_TARGET_MODAL_NEW))->toDefaultAttrStr() . ' + theme="primary" + icon="789">Run the code bellow'; Buffer::start(); if ($row['description']) { echo '

' . $row['description'] . '

'; @@ -459,14 +457,17 @@ public function getSourceFileLinkTag(array $files): string ) . ')'; continue; } - $tags[] = ' $relativePath], false, 0 - ), - JsRequestOptions::RENDER_TARGET_MODAL_NEW) . '\' title="Click to show complete source">' . $relativePath . ''; + ), JsRequestOptions::RENDER_TARGET_MODAL_NEW + ); + $tags[] = 'toDefaultAttrStr( + ) . ' title="Click to show complete source">' . $relativePath . ''; } if (count($tags) > 1) { $lastTag = array_pop($tags);