Skip to content

Commit

Permalink
[BUGFIX] Add severity classes to flash messages (#76)
Browse files Browse the repository at this point in the history
Fixes: #75
Releases: master, 9.1, 9.0, 8.7
  • Loading branch information
benjaminkott committed May 3, 2019
1 parent 473940a commit 2adfc55
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
10 changes: 10 additions & 0 deletions Configuration/TypoScript/Static/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ plugin.tx_blog {
pageInfo.sharingEnabled {
data = page:sharing_enabled
}
_CSS_DEFAULT_STYLE (
.alert__title {
font-weight: bold;
}
.alert__list {
margin: 0;
padding: 0;
list-style: none;
}
)
}

lib.blog.pageInfo < plugin.tx_blog.pageInfo
Expand Down
14 changes: 11 additions & 3 deletions Resources/Private/Partials/General/FlashMessages.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<f:flashMessages as="flashMessages">
<f:for each="{flashMessages}" as="flashMessage">
<div class="alert {flashMessage.class}" role="alert">
<strong>{flashMessage.title}</strong> {flashMessage.message}
<f:switch expression="{flashMessage.severity}">
<f:case value="-1"><f:variable name="class" value="info" /></f:case>
<f:case value="0"><f:variable name="class" value="success" /></f:case>
<f:case value="1"><f:variable name="class" value="warning" /></f:case>
<f:case value="2"><f:variable name="class" value="danger" /></f:case>
<f:defaultCase><f:variable name="class" value="notice" /></f:defaultCase>
</f:switch>
<div class="alert alert-{class}" role="alert">
<div class="alert__title">{flashMessage.title}</div>
<div class="alert__message">{flashMessage.message}</div>
</div>
</f:for>
</f:flashMessages>
</f:flashMessages>
22 changes: 13 additions & 9 deletions Resources/Private/Partials/General/FormErrors.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<f:form.validationResults>
<f:if condition="{validationResults.flattenedErrors}">
<dl class="errors">
<f:for each="{validationResults.flattenedErrors}" as="errors" key="propertyPath">
<dd class="alert alert-danger" role="alert"><!-- {propertyPath} -->
<f:for each="{errors}" as="error">
<!-- {error.code}: -->{error}
<div class="errors">
<f:for each="{validationResults.flattenedErrors}" as="errors" key="propertyPath">
<div class="alert alert-danger" role="alert">
<div class="alert__message">
<ul class="alert__list">
<f:for each="{errors}" as="error">
<li><span>{error}</span></li>
</f:for>
</ul>
</div>
</div>
</f:for>
</dd>
</f:for>
</dl>
</div>
</f:if>
</f:form.validationResults>
</f:form.validationResults>
9 changes: 1 addition & 8 deletions Resources/Private/Templates/Comment/AddComment.html
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
<f:flashMessages as="flashMessages">
<f:for each="{flashMessages}" as="flashMessage">
<div class="alert alert-{flashMessage.class}" role="alert">
<strong>{flashMessage.title}</strong> {flashMessage.message}
</div>
</f:for>
</f:flashMessages>

<f:render partial="General/FlashMessages"/>

0 comments on commit 2adfc55

Please sign in to comment.