From 62386e4c9e43537b6b2122b95bee61587c6b490e Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 16 Dec 2023 21:43:01 +0000 Subject: [PATCH 1/3] Frio: Improved user defined channel page --- src/Module/Settings/Channels.php | 8 ++- .../frio/templates/settings/channels.tpl | 64 +++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 view/theme/frio/templates/settings/channels.tpl diff --git a/src/Module/Settings/Channels.php b/src/Module/Settings/Channels.php index 5c638c8508..2595a84372 100644 --- a/src/Module/Settings/Channels.php +++ b/src/Module/Settings/Channels.php @@ -125,9 +125,11 @@ class Channels extends BaseSettings $circles[$circle['id']] = $circle['name']; } - $blocklistform = []; + $id = 0; + $channels = []; foreach ($this->channel->selectByUid($uid) as $channel) { - $blocklistform[] = [ + $channels[] = [ + 'id' => ++$id, 'label' => ["label[$channel->code]", $this->t('Label'), $channel->label, '', $this->t('Required')], 'description' => ["description[$channel->code]", $this->t("Description"), $channel->description], 'access_key' => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey], @@ -166,7 +168,7 @@ class Channels extends BaseSettings 'delentry' => $this->t('Delete entry from the channel list'), 'confirm_delete' => $this->t('Delete entry from the channel list?'), ], - '$entries' => $blocklistform, + '$entries' => $channels, '$baseurl' => $this->baseUrl, '$form_security_token' => self::getFormSecurityToken('settings_channels'), diff --git a/view/theme/frio/templates/settings/channels.tpl b/view/theme/frio/templates/settings/channels.tpl new file mode 100644 index 0000000000..d4ef83fb43 --- /dev/null +++ b/view/theme/frio/templates/settings/channels.tpl @@ -0,0 +1,64 @@ +
+

{{$l10n.title}}

+

{{$l10n.intro}}

+
+
+ +
+ + {{include file="field_input.tpl" field=$label}} + {{include file="field_input.tpl" field=$description}} + {{include file="field_input.tpl" field=$access_key}} + {{include file="field_select.tpl" field=$circle}} + {{include file="field_textarea.tpl" field=$include_tags}} + {{include file="field_textarea.tpl" field=$exclude_tags}} + {{include file="field_textarea.tpl" field=$text_search}} + {{include file="field_checkbox.tpl" field=$image}} + {{include file="field_checkbox.tpl" field=$video}} + {{include file="field_checkbox.tpl" field=$audio}} +
+ +
+
+
+ + {{if $entries}} +
+ + {{foreach $entries as $e}} +
+ +
+ {{include file="field_input.tpl" field=$e.label}} + {{include file="field_input.tpl" field=$e.description}} + {{include file="field_input.tpl" field=$e.access_key}} + {{include file="field_select.tpl" field=$e.circle}} + {{include file="field_textarea.tpl" field=$e.include_tags}} + {{include file="field_textarea.tpl" field=$e.exclude_tags}} + {{include file="field_textarea.tpl" field=$e.text_search}} + {{include file="field_checkbox.tpl" field=$e.image}} + {{include file="field_checkbox.tpl" field=$e.video}} + {{include file="field_checkbox.tpl" field=$e.audio}} + {{include file="field_checkbox.tpl" field=$e.delete}} +
+ +
+
+
+ {{/foreach}} + {{/if}} +
+
+
From 0a0d2c98e8f48681d691ab293f3df6360ee84845 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 17 Dec 2023 06:16:26 +0000 Subject: [PATCH 2/3] Channel definition now stays open after edit --- src/Module/Settings/Channels.php | 14 ++++++++++---- view/theme/frio/templates/settings/channels.tpl | 15 +++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Module/Settings/Channels.php b/src/Module/Settings/Channels.php index 2595a84372..557283fef3 100644 --- a/src/Module/Settings/Channels.php +++ b/src/Module/Settings/Channels.php @@ -101,8 +101,6 @@ class Channels extends BaseSettings $saved = $this->channel->save($channel); $this->logger->debug('Save channel', ['id' => $id, 'saved' => $saved]); } - - $this->baseUrl->redirect('/settings/channels'); } protected function content(array $request = []): string @@ -125,11 +123,19 @@ class Channels extends BaseSettings $circles[$circle['id']] = $circle['name']; } - $id = 0; $channels = []; foreach ($this->channel->selectByUid($uid) as $channel) { + if (!empty($request['id'])) { + $open = $channel->code == $request['id']; + } elseif (!empty($request['new_label'])) { + $open = $channel->label == $request['new_label']; + } else { + $open = false; + } + $channels[] = [ - 'id' => ++$id, + 'id' => $channel->code, + 'open' => $open, 'label' => ["label[$channel->code]", $this->t('Label'), $channel->label, '', $this->t('Required')], 'description' => ["description[$channel->code]", $this->t("Description"), $channel->description], 'access_key' => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey], diff --git a/view/theme/frio/templates/settings/channels.tpl b/view/theme/frio/templates/settings/channels.tpl index d4ef83fb43..be11966842 100644 --- a/view/theme/frio/templates/settings/channels.tpl +++ b/view/theme/frio/templates/settings/channels.tpl @@ -29,18 +29,18 @@ {{if $entries}} -
- {{foreach $entries as $e}} -
+ -
+
+ + {{include file="field_input.tpl" field=$e.label}} {{include file="field_input.tpl" field=$e.description}} {{include file="field_input.tpl" field=$e.access_key}} @@ -56,9 +56,8 @@
-
+
{{/foreach}} - {{/if}} - + {{/if}} From 8de58aa39d61e338c40e09873825f755251c107a Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 17 Dec 2023 06:41:19 +0000 Subject: [PATCH 3/3] open channel settings when empty --- src/Module/Settings/Channels.php | 1 + view/theme/frio/templates/settings/channels.tpl | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Module/Settings/Channels.php b/src/Module/Settings/Channels.php index 557283fef3..5e45b2cbb4 100644 --- a/src/Module/Settings/Channels.php +++ b/src/Module/Settings/Channels.php @@ -152,6 +152,7 @@ class Channels extends BaseSettings $t = Renderer::getMarkupTemplate('settings/channels.tpl'); return Renderer::replaceMacros($t, [ + 'open' => count($channels) == 0, 'label' => ["new_label", $this->t('Label'), '', $this->t('Short name for the channel. It is displayed on the channels widget.'), $this->t('Required')], 'description' => ["new_description", $this->t("Description"), '', $this->t('This should describe the content of the channel in a few word.')], 'access_key' => ["new_access_key", $this->t("Access Key"), '', $this->t('When you want to access this channel via an access key, you can define it here. Pay attention to not use an already used one.')], diff --git a/view/theme/frio/templates/settings/channels.tpl b/view/theme/frio/templates/settings/channels.tpl index be11966842..7ed2b1cc5d 100644 --- a/view/theme/frio/templates/settings/channels.tpl +++ b/view/theme/frio/templates/settings/channels.tpl @@ -5,12 +5,12 @@
-
+
{{include file="field_input.tpl" field=$label}} {{include file="field_input.tpl" field=$description}}