Channel definition now stays open after edit

This commit is contained in:
Michael 2023-12-17 06:16:26 +00:00
parent 62386e4c9e
commit 0a0d2c98e8
2 changed files with 17 additions and 12 deletions

View File

@ -101,8 +101,6 @@ class Channels extends BaseSettings
$saved = $this->channel->save($channel); $saved = $this->channel->save($channel);
$this->logger->debug('Save channel', ['id' => $id, 'saved' => $saved]); $this->logger->debug('Save channel', ['id' => $id, 'saved' => $saved]);
} }
$this->baseUrl->redirect('/settings/channels');
} }
protected function content(array $request = []): string protected function content(array $request = []): string
@ -125,11 +123,19 @@ class Channels extends BaseSettings
$circles[$circle['id']] = $circle['name']; $circles[$circle['id']] = $circle['name'];
} }
$id = 0;
$channels = []; $channels = [];
foreach ($this->channel->selectByUid($uid) as $channel) { 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[] = [ $channels[] = [
'id' => ++$id, 'id' => $channel->code,
'open' => $open,
'label' => ["label[$channel->code]", $this->t('Label'), $channel->label, '', $this->t('Required')], 'label' => ["label[$channel->code]", $this->t('Label'), $channel->label, '', $this->t('Required')],
'description' => ["description[$channel->code]", $this->t("Description"), $channel->description], 'description' => ["description[$channel->code]", $this->t("Description"), $channel->description],
'access_key' => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey], 'access_key' => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey],

View File

@ -29,18 +29,18 @@
</form> </form>
{{if $entries}} {{if $entries}}
<form action="{{$baseurl}}/settings/channels" method="post">
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
{{foreach $entries as $e}} {{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"> <div class="section-subtitle-wrapper panel-heading" role="tab" id="{{$e.id}}-settings-title">
<h2> <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}} {{$e.label.2}}
</button> </button>
</h2> </h2>
</div> </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.label}}
{{include file="field_input.tpl" field=$e.description}} {{include file="field_input.tpl" field=$e.description}}
{{include file="field_input.tpl" field=$e.access_key}} {{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> <button type="submit" class="btn btn-primary" name="edit_channel" value="{{$l10n.savechanges}}">{{$l10n.savechanges}}</button>
</div> </div>
</div> </div>
</div> </form>
{{/foreach}} {{/foreach}}
{{/if}} {{/if}}
</form>
</div> </div>
</div> </div>