From 7719b8c2a06bd76c1ba8f78efbec7e4dd052aa49 Mon Sep 17 00:00:00 2001 From: gdamms Date: Wed, 1 Jun 2022 15:22:50 +0200 Subject: [PATCH] fix: colorpicker --- .../com/pixels/services/PixelService.java | 4 +- src/main/webapp/index.html | 46 ++----------------- src/main/webapp/js/loaded.js | 9 ---- src/main/webapp/js/pixels.js | 15 +----- 4 files changed, 8 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/pixels/services/PixelService.java b/src/main/java/com/pixels/services/PixelService.java index db7f12f..d2ca227 100644 --- a/src/main/java/com/pixels/services/PixelService.java +++ b/src/main/java/com/pixels/services/PixelService.java @@ -92,7 +92,7 @@ public class PixelService { @Path("{id}/modify/") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void modify(@PathParam("id") Long id, @CookieParam("JSESSIONID") Cookie cookie, - @FormParam("red") int red, @FormParam("green") int green, @FormParam("blue") int blue,@FormParam("color") String color, + @FormParam("color") String color, @FormParam("price") int price, @FormParam("description") String description) { // on récupère le pixel de la db via son id Pixel pixel = em.find(Pixel.class, id); @@ -103,7 +103,7 @@ public class PixelService { if (user.equals(pixel.getOwner())) { pixel.setPrice(price); pixel.setDescription(description); - //pixel.setColor(String.format("%02X%02X%02X", red, green, blue)); + String colorDisplay = color.substring(1,color.length()); pixel.setColor(colorDisplay); diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index 7de0f11..cbdd4d5 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -10,8 +10,6 @@ - - @@ -141,48 +139,12 @@ required /> - -
- - + +
+ +
-
- - -
- -
- - -
- - -
{ - // console.log('New color', event.detail.color); - // }); - - document.forms["pay-form"].addEventListener("submit", (event) => { event.preventDefault(); fetch(event.target.action, { diff --git a/src/main/webapp/js/pixels.js b/src/main/webapp/js/pixels.js index fc8c0b5..1de5195 100644 --- a/src/main/webapp/js/pixels.js +++ b/src/main/webapp/js/pixels.js @@ -80,19 +80,8 @@ function updateModifyForm(pixel) { let price = document.getElementById("modify-price"); price.value = pixel.price; - let colorpicker = document.getElementById("colorpicker") - colorpicker.value = "#" + pixel.color - - let color = hexToRgb(pixel.color); - - let red = document.getElementById("modify-red"); - red.value = color.r; - - let green = document.getElementById("modify-green"); - green.value = color.g; - - let blue = document.getElementById("modify-blue"); - blue.value = color.b; + let colorpicker = document.getElementById("colorpicker"); + colorpicker.value = "#" + pixel.color; let description = document.getElementById("modify-description"); description.value = pixel.description;