Skip to content
Snippets Groups Projects
Commit f88ee311 authored by Elmar Ludwig's avatar Elmar Ludwig Committed by Jan-Hendrik Willms
Browse files

add form to OptionsWidget and refactor code a bit, fixes #1474

Closes #1474

Merge request studip/studip!2044
parent c6fda0f6
No related branches found
No related tags found
No related merge requests found
...@@ -226,10 +226,9 @@ class LinkElement extends WidgetElement implements ArrayAccess ...@@ -226,10 +226,9 @@ class LinkElement extends WidgetElement implements ArrayAccess
protected function renderButton() protected function renderButton()
{ {
return sprintf( return sprintf(
'<form action="%1$s" method="post" %2$s>%3$s<button type="submit">%4$s</button></form>', '<button formaction="%s" class="as-link" %s>%s</button>',
htmlReady($this->url), htmlReady($this->url),
arrayToHtmlAttributes((array) $this->attributes), arrayToHtmlAttributes((array) $this->attributes),
CSRFProtection::tokenTag(),
htmlReady($this->label) htmlReady($this->label)
); );
} }
......
...@@ -34,7 +34,7 @@ class OptionsWidget extends ListWidget ...@@ -34,7 +34,7 @@ class OptionsWidget extends ListWidget
$toggle_url_off = isset($toggle_url_off) ? html_entity_decode($toggle_url_off) : null; $toggle_url_off = isset($toggle_url_off) ? html_entity_decode($toggle_url_off) : null;
$content = sprintf( $content = sprintf(
'<a href="%s" role="checkbox" aria-checked="%s" class="options-checkbox options-%s" %s>%s</a>', '<button formaction="%s" role="checkbox" aria-checked="%s" class="as-link options-checkbox options-%s" %s>%s</button>',
htmlReady($state && $toggle_url_off !== null ? $toggle_url_off : $toggle_url), htmlReady($state && $toggle_url_off !== null ? $toggle_url_off : $toggle_url),
$state ? 'true' : 'false', $state ? 'true' : 'false',
$state ? 'checked' : 'unchecked', $state ? 'checked' : 'unchecked',
...@@ -55,7 +55,7 @@ class OptionsWidget extends ListWidget ...@@ -55,7 +55,7 @@ class OptionsWidget extends ListWidget
$url = html_entity_decode($url); $url = html_entity_decode($url);
$content = sprintf( $content = sprintf(
'<a href="%s" role="radio" aria-checked="%s" class="options-radio options-%s" %s>%s</a>', '<button formaction="%s" role="radio" aria-checked="%s" class="as-link options-radio options-%s" %s>%s</button>',
htmlReady($url), htmlReady($url),
$checked ? 'true' : 'false', $checked ? 'true' : 'false',
$checked ? 'checked' : 'unchecked', $checked ? 'checked' : 'unchecked',
......
...@@ -142,12 +142,13 @@ button.styleless { ...@@ -142,12 +142,13 @@ button.styleless {
border: 0; border: 0;
} }
button.as-link { button.as-link {
background-color: transparent;
border: none; border: none;
padding: 0px; color: $base-color;
margin: 0px;
cursor: pointer; cursor: pointer;
background-color: transparent; margin: 0px;
padding: 0px;
&:hover { &:hover {
background-color: transparent; color: $active-color;
} }
} }
...@@ -123,6 +123,11 @@ ul.widget-list { ...@@ -123,6 +123,11 @@ ul.widget-list {
padding-left: 20px; padding-left: 20px;
word-wrap: break-word; word-wrap: break-word;
} }
button {
text-align: left;
width: 100%;
}
} }
div#sidebar-navigation { div#sidebar-navigation {
div.sidebar-widget-header { div.sidebar-widget-header {
...@@ -191,21 +196,6 @@ div#sidebar-navigation { ...@@ -191,21 +196,6 @@ div#sidebar-navigation {
} }
} }
} }
button {
background: transparent;
border: 0;
color: $base-color;
margin: 0;
padding: 0;
text-align: left;
width: 100%;
&:hover {
color: $active-color;
cursor: pointer;
}
}
} }
.sidebar-widget-cloud { .sidebar-widget-cloud {
......
<ul class="<?= implode(' ', $css_classes) ?>" aria-label="<?= htmlReady($title) ?>"> <form method="post">
<? foreach ($elements as $index => $element): ?> <?= CSRFProtection::tokenTag() ?>
<? if ($element instanceof LinkElement): ?> <ul class="<?= implode(' ', $css_classes) ?>" aria-label="<?= htmlReady($title) ?>">
<? $icon = $element->icon ?? null ?> <? foreach ($elements as $index => $element): ?>
<? if ($icon && $element->isDisabled()): ?> <? if ($element instanceof LinkElement): ?>
<? $icon = $icon->copyWithRole('inactive') ?> <? $icon = $element->icon ?? null ?>
<? if ($icon && $element->isDisabled()): ?>
<? $icon = $icon->copyWithRole('inactive') ?>
<? endif ?>
<? endif ?> <? endif ?>
<? endif ?> <li id="<?= htmlReady($index) ?>"
<li id="<?= htmlReady($index) ?>" <?= isset($icon) ? 'style="' . $icon->asCSS() .'"' : '' ?>
<?= isset($icon) ? 'style="' . $icon->asCSS() .'"' : '' ?> <?= !empty($element->active) ? 'class="active"' : '' ?>>
<?= !empty($element->active) ? 'class="active"' : '' ?>> <?= $element->render() ?>
<?= $element->render() ?> </li>
</li> <? endforeach; ?>
<? endforeach; ?> </ul>
</ul> </form>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment