Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPS-112018 Remove <clay:button> and use hardcoded markup #460

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,26 @@ protected void setAttributes(HttpServletRequest httpServletRequest) {
httpServletRequest.setAttribute(
"liferay-ratings:ratings:classPK", String.valueOf(_classPK));

boolean inTrash = _isInTrash();

RatingsStats ratingsStats = _getRatingsStats();

int positiveVotes = (int)Math.round(_getTotalScore(ratingsStats));

ThemeDisplay themeDisplay =
(ThemeDisplay)httpServletRequest.getAttribute(
WebKeys.THEME_DISPLAY);

RatingsEntry ratingsEntry = _getRatingsEntry(
ratingsStats, themeDisplay);

int positiveVotes = (int)Math.round(_getTotalScore());
double userScore = _getUserScore(ratingsEntry);

boolean thumbUp = _isThumbUp(userScore);

int totalEntries = _getTotalEntries(ratingsStats);

String url = _getURL(themeDisplay);

httpServletRequest.setAttribute(
"liferay-ratings:ratings:data",
Expand All @@ -165,46 +175,44 @@ protected void setAttributes(HttpServletRequest httpServletRequest) {
).put(
"classPK", _classPK
).put(
"enabled", _isEnabled(themeDisplay)
"enabled", _isEnabled(themeDisplay, isInTrash())
).put(
"initialAverageScore", _getInitialAverageScore(ratingsStats)
).put(
"initialLiked", _isThumbUp(_getUserScore(ratingsEntry))
"initialLiked", thumbUp
).put(
"initialNegativeVotes",
_getTotalEntries(ratingsStats) - positiveVotes
"initialNegativeVotes", totalEntries - positiveVotes
).put(
"initialPositiveVotes", positiveVotes
).put(
"initialTotalEntries", _getTotalEntries(ratingsStats)
"initialTotalEntries", totalEntries
).put(
"inTrash", _isInTrash()
"inTrash", inTrash
).put(
"numberOfStars", getNumberOfStars()
).put(
"positiveVotes", positiveVotes
).put(
"signedIn", themeDisplay.isSignedIn()
).put(
"thumbDown", _isThumbDown(_getUserScore(ratingsEntry))
"thumbDown", _isThumbDown(userScore)
).put(
"thumbUp", _isThumbUp(_getUserScore(ratingsEntry))
"thumbUp", thumbUp
).put(
"url", _getURL(themeDisplay)
"url", url
).put(
"userScore", _getUserScore(ratingsEntry)
"userScore", userScore
).build());

httpServletRequest.setAttribute(
"liferay-ratings:ratings:inTrash", _isInTrash());
"liferay-ratings:ratings:inTrash", inTrash);
httpServletRequest.setAttribute(
"liferay-ratings:ratings:ratingsEntry", ratingsEntry);
httpServletRequest.setAttribute(
"liferay-ratings:ratings:ratingsStats", ratingsStats);
httpServletRequest.setAttribute(
"liferay-ratings:ratings:type", _getType(httpServletRequest));
httpServletRequest.setAttribute(
"liferay-ratings:ratings:url", _getURL(themeDisplay));
httpServletRequest.setAttribute("liferay-ratings:ratings:url", url);
}
catch (Exception exception) {
_log.error(exception, exception);
Expand Down Expand Up @@ -249,10 +257,7 @@ private int _getTotalEntries(RatingsStats ratingsStats) {
return totalEntries;
}

private double _getTotalScore() {
RatingsStats ratingsStats = RatingsStatsLocalServiceUtil.fetchStats(
_className, _classPK);

private double _getTotalScore(RatingsStats ratingsStats) {
if (ratingsStats != null) {
return ratingsStats.getTotalScore();
}
Expand Down Expand Up @@ -316,10 +321,8 @@ private double _getUserScore(RatingsEntry ratingsEntry) {
return userScore;
}

private boolean _isEnabled(ThemeDisplay themeDisplay)
throws PortalException {

if (!_isInTrash()) {
private boolean _isEnabled(ThemeDisplay themeDisplay, boolean inTrash) {
if (!inTrash) {
Group group = themeDisplay.getSiteGroup();

if (!group.isStagingGroup() && !group.isStagedRemotely()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://liferay.com/tld/clay" prefix="clay" %><%@
taglib uri="http://liferay.com/tld/frontend" prefix="liferay-frontend" %><%@
<%@ taglib uri="http://liferay.com/tld/frontend" prefix="liferay-frontend" %><%@
taglib uri="http://liferay.com/tld/react" prefix="react" %><%@
taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %><%@
taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %><%@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ String type = GetterUtil.getString((String)request.getAttribute("liferay-ratings
<c:choose>
<c:when test="<%= type.equals(RatingsType.LIKE.getValue()) %>">
<div>
<clay:button
disabled="<%= true %>"
elementClasses="btn-outline-borderless btn-outline-secondary btn-sm"
icon="heart"
/>
<button class="btn btn-outline-borderless btn-outline-secondary btn-sm" disabled type="button">
<svg class="lexicon-icon lexicon-icon-heart">
<use xlink:href="<%= themeDisplay.getPathThemeImages() %>/lexicon/icons.svg#heart" />
</svg>
</button>

<react:component
data="<%= data %>"
Expand All @@ -49,17 +49,17 @@ String type = GetterUtil.getString((String)request.getAttribute("liferay-ratings
</c:when>
<c:when test="<%= type.equals(RatingsType.THUMBS.getValue()) %>">
<div>
<clay:button
disabled="<%= true %>"
elementClasses="btn-outline-borderless btn-outline-secondary btn-sm"
icon="thumbs-up"
/>
<button class="btn btn-outline-borderless btn-outline-secondary btn-sm" disabled type="button">
<svg class="lexicon-icon lexicon-icon-thumbs-up">
<use xlink:href="<%= themeDisplay.getPathThemeImages() %>/lexicon/icons.svg#thumbs-up" />
</svg>
</button>

<clay:button
disabled="<%= true %>"
elementClasses="btn-outline-borderless btn-outline-secondary btn-sm"
icon="thumbs-down"
/>
<button class="btn btn-outline-borderless btn-outline-secondary btn-sm" disabled type="button">
<svg class="lexicon-icon lexicon-icon-thumbs-down">
<use xlink:href="<%= themeDisplay.getPathThemeImages() %>/lexicon/icons.svg#thumbs-down" />
</svg>
</button>

<react:component
data="<%= data %>"
Expand All @@ -72,20 +72,20 @@ String type = GetterUtil.getString((String)request.getAttribute("liferay-ratings
<div class="autofit-row autofit-row-center ratings ratings-stars">
<div class="autofit-col">
<div class="dropdown">
<clay:button
disabled="<%= true %>"
elementClasses="btn btn-outline-borderless btn-outline-secondary btn-sm dropdown-toggle"
icon="star-o"
label="-"
/>
<button class="btn btn-outline-borderless btn-outline-secondary dropdown-toggle btn-sm" disabled type="button">
<svg class="lexicon-icon lexicon-icon-star-o">
<use xlink:href="<%= themeDisplay.getPathThemeImages() %>/lexicon/icons.svg#star-o" />
</svg>

<span>-</span>
</button>
</div>
</div>

<div class="autofit-col">
<clay:icon
elementClasses="ratings-stars-average-icon"
symbol="star"
/>
<svg class="lexicon-icon lexicon-icon-star ratings-stars-average-icon">
<use xlink:href="<%= themeDisplay.getPathThemeImages() %>/lexicon/icons.svg#star" />
</svg>
</div>
</div>

Expand Down