mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Merge pull request #115 from cheapy-ispp/023-Añadir-estrellas-a-reseñas#72
Añadido las estrellas a las reseñas
This commit is contained in:
commit
3c6d98b14e
8 changed files with 111 additions and 12 deletions
|
@ -145,13 +145,6 @@ public class Client extends BaseEntity {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public Municipio getMunicipio() {
|
||||
return municipio;
|
||||
}
|
||||
|
||||
public void setMunicipio(Municipio municipio) {
|
||||
this.municipio = municipio;
|
||||
}
|
||||
|
||||
public Code getCode() {
|
||||
return cod;
|
||||
|
|
|
@ -642,3 +642,4 @@ hr {
|
|||
@import "typography.less";
|
||||
@import "header.less";
|
||||
@import "responsive.less";
|
||||
@import "starRating.less"
|
||||
|
|
40
src/main/less/starRating.less
Normal file
40
src/main/less/starRating.less
Normal file
|
@ -0,0 +1,40 @@
|
|||
.rating {
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
justify-content: flex-end
|
||||
}
|
||||
|
||||
.rating>input {
|
||||
display: none
|
||||
}
|
||||
|
||||
.rating>label {
|
||||
position: relative;
|
||||
width: 1em;
|
||||
font-size: 200%;
|
||||
color: #FFD600;
|
||||
cursor: pointer
|
||||
}
|
||||
|
||||
.rating>label::before {
|
||||
content: "\2605";
|
||||
position: absolute;
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
.rating>label:hover:before,
|
||||
.rating>label:hover~label:before {
|
||||
opacity: 1 !important
|
||||
}
|
||||
|
||||
.rating>input:checked~label:before {
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
.rating:hover>input:checked~label:before {
|
||||
opacity: 0.4
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -14,7 +14,8 @@
|
|||
<div class="form-group has-feedback">
|
||||
<form:hidden path="id"/>
|
||||
<cheapy:textAreaField label="Opinión" name="opinion"/>
|
||||
<cheapy:inputField label="Estrellas" name="stars"/>
|
||||
<!-- <cheapy:inputField label="Estrellas" name="stars"/> -->
|
||||
<cheapy:ratingStar label="Valoración" name="stars" disabled="false"></cheapy:ratingStar>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="reviews">
|
||||
|
@ -26,6 +27,7 @@
|
|||
</c:when>
|
||||
<c:otherwise>
|
||||
<c:forEach items="${reviewsLs}" var="review">
|
||||
|
||||
<tr>
|
||||
<!-- <td> -->
|
||||
<%-- <c:out value="nombre por definir"/> <!-- ${review.usuario.nombre},${review.usuario.apellidos} --> --%>
|
||||
|
@ -34,7 +36,10 @@
|
|||
<c:out value="${review.escritor.username}"/>
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${review.stars}"/>
|
||||
|
||||
<!--<c:out value="${review.stars}"/> -->
|
||||
<cheapy:showStars value='${review.stars}'></cheapy:showStars>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<c:out value="${review.opinion}"/>
|
||||
|
@ -51,6 +56,7 @@
|
|||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</c:forEach>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
|
|
@ -6,25 +6,28 @@
|
|||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
|
||||
<cheapy:layout pageName="review">
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="review"/></h2>
|
||||
<form:form modelAttribute="review" class="form-horizontal" id="add-review-form">
|
||||
|
||||
|
||||
<table class="table table-striped" id="review-table">
|
||||
<tr>
|
||||
<th><fmt:message key="stars"/></th>
|
||||
<td><c:out value="${review.stars}"/></td>
|
||||
<!-- <td><c:out value="${review.stars}"/></td>-->
|
||||
<td><cheapy:ratingStar label="" name="stars" disabled="true"></cheapy:ratingStar></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><fmt:message key="opinion"/></th>
|
||||
<td><c:out value="${review.opinion}"/></td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
</form:form>
|
||||
|
||||
<sec:authentication var="principal" property="principal" />
|
||||
<div class="btns-edit">
|
||||
|
|
37
src/main/webapp/WEB-INF/tags/ratingStar.tag
Normal file
37
src/main/webapp/WEB-INF/tags/ratingStar.tag
Normal file
|
@ -0,0 +1,37 @@
|
|||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %>
|
||||
<%@ attribute name="name" required="true" rtexprvalue="true"
|
||||
description="Name of corresponding property in bean object" %>
|
||||
<%@ attribute name="disabled" required="false" rtexprvalue="true"
|
||||
description="Disable the input" %>
|
||||
<%@ attribute name="label" required="true" rtexprvalue="true"
|
||||
description="Label appears in red color if input is considered as invalid after submission" %>
|
||||
<%@ attribute name="placeholder" required="false" rtexprvalue="true"
|
||||
description="Example for input field" %>
|
||||
|
||||
<spring:bind path="${name}">
|
||||
<c:set var="cssGroup" value="form-group ${status.error ? 'has-error' : '' }"/>
|
||||
<c:set var="valid" value="${not status.error and not empty status.actualValue}"/>
|
||||
<div class="${cssGroup}">
|
||||
<c:if test="${fn:length(label)!=0}">
|
||||
<label class="col-sm-2 control-label">${label}</label>
|
||||
</c:if>
|
||||
<div class="col-sm-10">
|
||||
<div class="rating">
|
||||
<form:radiobutton class="form-control" disabled="${disabled}" name="rating" value="5" id="5" path="${name}"/><label for="5"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
<form:radiobutton class="form-control" disabled="${disabled}" name="rating" value="4" id="4" path="${name}"/><label for="4"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
<form:radiobutton class="form-control" disabled="${disabled}" name="rating" value="3" id="3" path="${name}"/><label for="3"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
<form:radiobutton class="form-control" disabled="${disabled}" name="rating" value="2" id="2" path="${name}"/><label for="2"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
<form:radiobutton class="form-control" disabled="${disabled}" name="rating" value="1" id="1" path="${name}"/><label for="1"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
|
||||
</div>
|
||||
|
||||
<c:if test="${status.error}">
|
||||
<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>
|
||||
<span class="help-inline">${status.errorMessage}</span>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
</spring:bind>
|
18
src/main/webapp/WEB-INF/tags/showStars.tag
Normal file
18
src/main/webapp/WEB-INF/tags/showStars.tag
Normal file
|
@ -0,0 +1,18 @@
|
|||
<%@tag import="com.sun.org.apache.xalan.internal.xsltc.compiler.sym"%>
|
||||
<%@ tag language="java" pageEncoding="ISO-8859-1"%>
|
||||
<%@ attribute name="value" required="true" rtexprvalue="true" type="Integer"
|
||||
description="Number of starts" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||
<form>
|
||||
|
||||
|
||||
<div class="rating">
|
||||
<input type="radio" class="form-control" disabled name="rating" value="5" id="5" <%= value.equals(5) ?"checked='checked'" : ""%> /><label for="5"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
<input type="radio" class="form-control" disabled name="rating" value="4" id="4" <%= value.equals(4) ? "checked='checked'" : "" %> /><label for="4"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
<input type="radio" class="form-control" disabled name="rating" value="3" id="3" <%= value.equals(3) ? "checked='checked'" : "" %>/><label for="3"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
<input type="radio" class="form-control" disabled name="rating" value="2" id="2" <%= value.equals(2) ? "checked='checked'" : "" %>/><label for="2"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
<input type="radio" class="form-control" disabled name="rating" value="1" id="1" <%= value.equals(1) ? "checked='checked'" : "" %>/><label for="1"><span style="font-size: 100%" class="estrella_vacia">☆</span></label>
|
||||
</div>
|
||||
|
||||
</form>
|
Loading…
Reference in a new issue