mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Merge branch 'develop' into 039-fixVistas
This commit is contained in:
commit
a7b4c29455
8 changed files with 142 additions and 22 deletions
|
@ -2,7 +2,6 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -114,6 +113,17 @@ public class OfertaController {
|
|||
|
||||
@GetMapping("/offersByPlace")
|
||||
public String processFindFormByPlace(final Map<String, Object> model, final HttpServletRequest request) {
|
||||
|
||||
if (request.getParameter("municipio").equals("") || request.getParameter("municipio").equals(null)) {
|
||||
// Añade la lista de municipios al desplegable
|
||||
model.put("municipios", Municipio.values());
|
||||
|
||||
//Se añade formateador de fecha al modelo
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
return "redirect:/offers/";
|
||||
}
|
||||
|
||||
Municipio mun = Municipio.valueOf(request.getParameter("municipio"));
|
||||
|
||||
List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferByClientPlace(mun);
|
||||
|
@ -161,30 +171,30 @@ public class OfertaController {
|
|||
|
||||
return "offers/offersCreate";
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/offersRecord")
|
||||
public String processOffersRecordForm(final Map<String, Object> model) {
|
||||
|
||||
|
||||
Pageable p = PageRequest.of(0, 3);
|
||||
|
||||
|
||||
Map<Offer, String> datos = new HashMap<Offer, String>();
|
||||
|
||||
for(Offer of:this.foodOfferService.findAllFoodOffer(p)) {
|
||||
|
||||
for (Offer of : this.foodOfferService.findAllFoodOffer(p)) {
|
||||
datos.put(of, "food");
|
||||
}
|
||||
|
||||
for(Offer of:this.nuOfferService.findAllNuOffer(p)) {
|
||||
|
||||
for (Offer of : this.nuOfferService.findAllNuOffer(p)) {
|
||||
datos.put(of, "nu");
|
||||
}
|
||||
|
||||
for(Offer of:this.speedOfferService.findAllSpeedOffer(p)) {
|
||||
|
||||
for (Offer of : this.speedOfferService.findAllSpeedOffer(p)) {
|
||||
datos.put(of, "speed");
|
||||
}
|
||||
|
||||
for(Offer of:this.timeOfferService.findAllTimeOffer(p)) {
|
||||
|
||||
for (Offer of : this.timeOfferService.findAllTimeOffer(p)) {
|
||||
datos.put(of, "time");
|
||||
}
|
||||
|
||||
|
||||
model.put("datos", datos);
|
||||
|
||||
//Se añade formateador de fecha al modelo
|
||||
|
@ -192,7 +202,7 @@ public class OfertaController {
|
|||
|
||||
return "offers/offersRecordList";
|
||||
}
|
||||
|
||||
|
||||
// @GetMapping("/owners/{ownerId}/edit")
|
||||
// public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||
// Owner owner = this.ownerService.findOwnerById(ownerId);
|
||||
|
|
|
@ -696,3 +696,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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -10,13 +10,14 @@
|
|||
|
||||
<cheapy:layout pageName="reviewsN">
|
||||
<h2 style="font-family: 'Lobster'; text-align:center; font-size:200%; color: rgb(0, 64, 128); padding:10px">
|
||||
<c:if test="${review['new']}">Nueva </c:if> Reseña
|
||||
<c:if test="${review['new']}">Nueva </c:if> Reseña
|
||||
</h2>
|
||||
<form:form modelAttribute="review" class="form-horizontal" id="add-review-form">
|
||||
<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">
|
||||
|
@ -25,10 +26,10 @@
|
|||
<c:when test="${review['new']}">
|
||||
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
|
||||
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
|
||||
Crear reseña</button>
|
||||
Crear reseña</button>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<button class="btn btn-default" type="submit">Modificar Reseña</button>
|
||||
<button class="btn btn-default" type="submit">Modificar Reseña</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
<%@ 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" %>
|
||||
<%@ page contentType="text/html; charset=UTF-8" %>
|
||||
|
||||
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
|
||||
|
||||
<cheapy:layout pageName="reviews">
|
||||
|
@ -27,6 +29,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} --> --%>
|
||||
|
@ -35,7 +38,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}"/>
|
||||
|
@ -52,6 +58,7 @@
|
|||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</c:forEach>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
|
|
@ -7,25 +7,31 @@
|
|||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
|
||||
<%@ page contentType="text/html; charset=UTF-8" %>
|
||||
<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="font-family: 'Lobster'; text-align:center; font-size:200%; color: rgb(0, 64, 128); padding:10px"><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