]> git.mxchange.org Git - friendica.git/commitdiff
Channel definition now stays open after edit
authorMichael <heluecht@pirati.ca>
Sun, 17 Dec 2023 06:16:26 +0000 (06:16 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 17 Dec 2023 06:16:26 +0000 (06:16 +0000)
src/Module/Settings/Channels.php
view/theme/frio/templates/settings/channels.tpl

index 2595a84372afdf6fa1087d733792551c3035a356..557283fef30b4708926ebd857b6914091531e30f 100644 (file)
@@ -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],
index d4ef83fb431b1b42ec620ce68ca837883c1ca6a7..be11966842c30ca32e6aa216719284d8a3e5530c 100644 (file)
                </form>
 
                {{if $entries}}
-                       <form action="{{$baseurl}}/settings/channels" method="post">
-                       <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
                        {{foreach $entries as $e}}
-                               <div class="panel">
+                               <form class="panel" action="{{$baseurl}}/settings/channels" method="post">
                                        <div class="section-subtitle-wrapper panel-heading" role="tab" id="{{$e.id}}-settings-title">
                                                <h2>
-                                                       <button class="btn-link accordion-toggle collapsed" data-toggle="collapse" data-parent="#settings-channels" href="#{{$e.id}}-settings-content" aria-expanded="false" aria-controls="{{$e.id}}-settings-content">
+                                                       <button class="btn-link accordion-toggle{{if !$e.open}} collapsed{{/if}}" data-toggle="collapse" data-parent="#settings-channels" href="#{{$e.id}}-settings-content" aria-expanded="false" aria-controls="{{$e.id}}-settings-content">
                                                                {{$e.label.2}}
                                                        </button>
                                                </h2>
                                        </div>
-                                       <div id="{{$e.id}}-settings-content" class="panel-collapse collapse" role="tabpanel" aria-labelledby="{{$e.id}}-settings-title">
+                                       <div id="{{$e.id}}-settings-content" class="panel-collapse collapse{{if $e.open}} in{{/if}}" role="tabpanel" aria-labelledby="{{$e.id}}-settings-title">
+                                               <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
+                                               <input type="hidden" name="id" value="{{$e.id}}">
                                                {{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 @@
                                                        <button type="submit" class="btn btn-primary" name="edit_channel" value="{{$l10n.savechanges}}">{{$l10n.savechanges}}</button>
                                                </div>
                                        </div>
-                               </div>
+                               </form>
                        {{/foreach}}
-                       {{/if}}
-               </form>
+               {{/if}}
        </div>
 </div>