Skip to content

Commit

Permalink
RoleForm: Use the <details> tag
Browse files Browse the repository at this point in the history
(cherry picked from commit 5059a78)
  • Loading branch information
nilmerg committed Nov 4, 2022
1 parent 677b571 commit 93bb9b6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 42 deletions.
16 changes: 9 additions & 7 deletions application/forms/Security/RoleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function createInsertElements(array $formData = array())
$moduleName . '_header',
[
'decorators' => ['ViewHelper'],
'value' => '<h3>'
'value' => '<summary class="collapsible-control">'
. '<span>' . ($moduleName !== 'application'
? sprintf('%s <em>%s</em>', $moduleName, $this->translate('Module'))
: 'Icinga Web 2'
Expand All @@ -285,18 +285,20 @@ public function createInsertElements(array $formData = array())
: ''
)
. '</span>'
. '</h3>'
. new Icon('angles-down', ['class' => 'collapse-icon'])
. new Icon('angles-left', ['class' => 'expand-icon'])
. '</summary>'
]
);

$this->addDisplayGroup($elements, $moduleName . '_elements', [
'decorators' => [
'FormElements',
['Fieldset', [
'class' => 'collapsible',
'data-toggle-element' => 'h3',
'data-visible-height' => 0
]]
['HtmlTag', [
'tag' => 'details',
'class' => 'collapsible'
]],
['Fieldset']
]
]);
}
Expand Down
59 changes: 24 additions & 35 deletions public/css/icinga/widgets.less
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,30 @@ form.role-form {
display: inline-block;
}

h3 {
summary {
border-bottom: 1px solid @gray-light;
.user-select(none);
cursor: pointer;

font-weight: @font-weight-bold;
margin: 0.556em 0 0.333em;
font-size: 1.167em;

display: flex;
align-items: baseline;
.privilege-preview {
flex: 1 1 auto;
}

> :first-child {
display: inline-block;
width: 20em / 1.167em; // element label width / h3 font-size
width: 20em / 1.167em; // element label width / summary font-size
}

> :nth-last-child(1),
> :nth-last-child(2) {
font-size: .75em;
opacity: .6;
}

.privilege-preview .icon {
Expand All @@ -276,12 +296,8 @@ form.role-form {
}
}

fieldset.collapsible {
border: none;
padding: 0;
margin: 0;

h3 em {
.collapsible {
summary em {
font-size: .857em;
font-weight: normal;
color: @text-color-light;
Expand Down Expand Up @@ -309,33 +325,6 @@ form.role-form {
}
}
}

.collapsible-control {
border-bottom: 1px solid @gray-light;
cursor: pointer;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

.collapsible-control:after {
content: "\f103";
display: inline-block;
font-family: 'ifont';
font-weight: normal;
padding: 0 .25em;
margin-right: .25em;
width: 1em;
opacity: .6;
float: right;
}

&.collapsed .collapsible-control:after {
content: "\e87a";
}
}
}

Expand Down

0 comments on commit 93bb9b6

Please sign in to comment.