diff --git a/pom.xml b/pom.xml
index 8309979..51e84a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
dev.fyloz.trial.colorrecipesexplorer
ColorRecipesExplorer
- 1.1.1
+ 1.1.2
Color Recipes Explorer
diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/RecipeExplorerController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/RecipeExplorerController.java
index 1e41a3b..5902c18 100644
--- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/RecipeExplorerController.java
+++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/RecipeExplorerController.java
@@ -66,11 +66,13 @@ public class RecipeExplorerController {
.build();
}
+ // TODO convertir form en DTO
@PostMapping(value = EXPLORER_RECIPE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map saveRecipeInformations(@RequestBody Map form) {
JSONResponseBuilder responseBuilder = new JSONResponseBuilder();
+
int recipeID = Integer.parseInt(form.get("recipeID").toString());
Map location = (Map) form.get("locations");
String note = form.get("note").toString();
diff --git a/src/main/resources/static/css/main.css b/src/main/resources/static/css/main.css
index 7bc0c8d..9c60191 100644
--- a/src/main/resources/static/css/main.css
+++ b/src/main/resources/static/css/main.css
@@ -7,6 +7,13 @@ td {
vertical-align: top;
}
+th {
+ background-color: black;
+ color: white;
+ font-weight: normal;
+ font-size: large;
+}
+
h1 {
text-decoration: underline;
}
@@ -49,6 +56,71 @@ nav a {
text-decoration: none;
}
+footer a {
+ color: white;
+ text-decoration: none;
+}
+
+button,
+select {
+ background-color: #d7dedc;
+ border-style: solid;
+ border-color: #d7dedc;
+ border-width: 1px;
+ padding: 2px 4px;
+ margin: 2px;
+}
+
+select {
+ padding: 1px 0;
+}
+
+select:after {
+ background-color: red;
+}
+
+button:hover {
+ background-color: #bec4c3;
+}
+
+input {
+ background-color: rgba(0, 0, 0, 0);
+ border-style: solid;
+ border-width: 1px;
+ border-color: #7a7a7a;
+}
+
+input[type=file] {
+ border-style: none;
+}
+
+input[disabled] {
+ border-style: none;
+ color: black;
+}
+
+input::-webkit-outer-spin-button,
+input::-webkit-inner-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+
+input[type=number] {
+ -moz-appearance: textfield;
+}
+
+table {
+ border-collapse: collapse;
+}
+
+textarea {
+ font-family: 'Open Sans', sans-serif;
+ background-color: #fafafa;
+ border-style: solid;
+ border-color: #7a7a7a;
+ border-width: 1px;
+}
+
.dropdown {
margin-top: 22px;
float: left;
@@ -120,6 +192,10 @@ nav a:hover, .dropdown:hover .dropbtn {
background-color: #ffc299;
}
+.nosimdut input:not(:disabled) {
+ background-color: #fafafa;
+}
+
.unapproved {
background-color: #fff0b3;
}
@@ -131,4 +207,71 @@ nav a:hover, .dropdown:hover .dropbtn {
#researchBox {
margin-top: 10px;
margin-right: 50px;
-}
\ No newline at end of file
+}
+
+.errorBox {
+ background-color: #ef9a9a;
+ color: #e53935;
+ font-weight: bold;
+}
+
+.successBox {
+ background-color: #a5d6a7;
+ color: #4caf50;
+ font-weight: bold;
+}
+
+.warningBox {
+ background-color: #fff59d;
+ color: #fdd835;
+ font-weight: bold;
+}
+
+.messageBox {
+ display: inline-block;
+ margin: 20px auto auto;
+}
+
+.messageBox .messageBoxContainer {
+ display: inline-block;
+ height: 24px;
+ padding: 16px;
+ text-align: left;
+}
+
+.messageBox .messageBoxInnerBox {
+ display: inline-block;
+ height: 24px;
+}
+
+.messageBox img {
+ float: left;
+}
+
+.messageBox p {
+ display: inline-block;
+ /*padding: 3px 0;*/
+ margin: 0 0 0 16px;
+ line-height: 24px;
+}
+
+/*.errorBox div {*/
+/* height: 24px;*/
+/* !*padding: 20px;*!*/
+/* margin: auto;*/
+/* vertical-align: middle;*/
+/*}*/
+
+/*.errorBox img {*/
+/* display: inline-block;*/
+/* float: left;*/
+/* height: 25px;*/
+/*}*/
+
+/*.errorBox p {*/
+/* !*float: left;*!*/
+/* display: inline-block;*/
+/* font-size: 18px;*/
+/* margin: auto;*/
+/* padding: 2px 0;*/
+/*}*/
diff --git a/src/main/resources/static/css/mix.css b/src/main/resources/static/css/mix.css
index dc687cb..ac7471f 100644
--- a/src/main/resources/static/css/mix.css
+++ b/src/main/resources/static/css/mix.css
@@ -34,4 +34,8 @@
.materialSelector p:hover {
background-color: #e6e6e6;
-}
\ No newline at end of file
+}
+
+.unitsColumn {
+ vertical-align: middle;
+}
diff --git a/src/main/resources/static/icons/error.svg b/src/main/resources/static/icons/error.svg
new file mode 100644
index 0000000..3eaebfb
--- /dev/null
+++ b/src/main/resources/static/icons/error.svg
@@ -0,0 +1,6 @@
+
+
+
diff --git a/src/main/resources/static/icons/success.svg b/src/main/resources/static/icons/success.svg
new file mode 100644
index 0000000..5894558
--- /dev/null
+++ b/src/main/resources/static/icons/success.svg
@@ -0,0 +1,5 @@
+
+
+
diff --git a/src/main/resources/static/icons/warning.svg b/src/main/resources/static/icons/warning.svg
new file mode 100644
index 0000000..0065683
--- /dev/null
+++ b/src/main/resources/static/icons/warning.svg
@@ -0,0 +1,5 @@
+
+
+
diff --git a/src/main/resources/static/js/main.js b/src/main/resources/static/js/main.js
index dd916f6..8d3c09c 100644
--- a/src/main/resources/static/js/main.js
+++ b/src/main/resources/static/js/main.js
@@ -1,6 +1,12 @@
const body = document.querySelector("body");
-const errorP = document.querySelector(".error");
+const errorMsgBox = document.querySelector(".errorBox");
+const errorMsgBoxText = errorMsgBox.querySelector("p");
+const warningMsgBox = document.querySelector(".warningBox");
+const warningMsgBoxText = warningMsgBox.querySelector("p");
+const successMsgBox = document.querySelector(".successBox");
+const successMsgBoxText = successMsgBox.querySelector("p");
+// Ne fonctionne pas dans window#load
(() => {
// Ajoute Axios
const axiosElement = document.createElement("script");
@@ -21,6 +27,12 @@ const errorP = document.querySelector(".error");
});
};
+ // Placé ici pour un chargement plus rapide
+ document.querySelectorAll(".messageBox").forEach(e => checkMessageBoxesDisplay(e));
+})();
+
+window.addEventListener("load", () => {
+
document.querySelectorAll(".returnIndex").forEach((e) => {
e.addEventListener("click", () => {
document.location.href = "/";
@@ -72,19 +84,29 @@ const errorP = document.querySelector(".error");
});
});
+ window.addEventListener("change", e => {
+ if (e.target) {
+ if (e.target.classList.contains("toSave")) {
+ // TODO traductions
+ warningMsgBoxText.innerText = "Des modifications ne sont pas été sauvegardées";
+ showElement(warningMsgBox);
+ }
+ }
+ });
+
// Ajoute le favicon
let faviconElement = document.createElement("link");
faviconElement.rel = "icon";
faviconElement.href = "/favicon.png";
document.querySelector("head").appendChild(faviconElement);
-})();
+});
function askDatabaseExport() {
return confirm("Voulez-vous vraiment exporter toutes les couleurs? Cela peut prendre un certain temps et ralentir l'application pendant un certain temps.");
}
-function checkPassword(form) {
- errorP.innerHTML = "";
+function checkPassword(form, callback) {
+ hideElement(errorMsgBox);
const password = prompt("Quel est votre mot de passe?");
@@ -94,18 +116,34 @@ function checkPassword(form) {
axios.post("/password/valid", data)
.then(r => {
if (r.data) {
- form.submit();
+ if (form != null) form.submit();
+ if (callback != null) callback();
return true;
} else {
- errorP.innerHTML = "Votre mot de passe n'est pas valide";
+ errorMsgBoxText.innerText = "Votre mot de passe n'est pas valide";
+ showElement(errorMsgBox);
+ return false;
}
})
.catch(e => {
- errorP.innerHTML = "Une erreur est survenue lors de l'envoie des informations vers le serveur.";
+ errorMsgBoxText.innerText = "Une erreur est survenue lors de l'envoie des informations vers le serveur.";
+ showElement(errorMsgBox);
console.log(e);
+ return false;
});
+}
- return false;
+function checkMessageBoxesDisplay(element) {
+ if (!element.querySelector("p").innerText) hideElement(element);
+ else showElement(element);
+}
+
+function hideElement(element) {
+ element.style.display = "none";
+}
+
+function showElement(element) {
+ element.style.display = "inline-block";
}
const lTomL = 1000;
@@ -146,4 +184,4 @@ function round(x) {
function percentageOf(percentage, number) {
return (percentage / 100) * number;
-}
\ No newline at end of file
+}
diff --git a/src/main/resources/static/js/mix.js b/src/main/resources/static/js/mix.js
index 52c1a81..8acd44f 100644
--- a/src/main/resources/static/js/mix.js
+++ b/src/main/resources/static/js/mix.js
@@ -16,7 +16,8 @@ window.addEventListener("load", () => {
init();
})
.catch(e => {
- errorP.innerHTML = "Une erreur est survenue lors de la récupération des produits";
+ errorMsgBoxText.innerText = "Une erreur est survenue lors de la récupération des produits";
+ showElement(errorMsgBox);
console.log(e);
});
});
@@ -44,13 +45,13 @@ document.querySelector("#materials button").addEventListener("click", () => {
function addMaterial(materialCode, quantity) {
let row = addRow();
- let materialSelectionColumn = addColumn(row);
- let quantityInputColumn = addColumn(row);
-
- let removeButtonColumn = addColumn(row);
+ let materialSelectionColumn = addColumn(row, null);
+ let quantityInputColumn = addColumn(row, null);
+ let unitsColumn = addColumn(row, "unitsColumn");
+ let removeButtonColumn = addColumn(row, null);
addInput(quantityInputColumn, quantity);
- addSpan(quantityInputColumn);
+ addSpan(unitsColumn);
addButton(removeButtonColumn);
materialSelectionColumn.innerHTML = materialSelectorHtml;
@@ -73,12 +74,13 @@ function addMaterial(materialCode, quantity) {
function addInput(parent, quantity) {
let input = document.createElement("input");
- if (quantity === null) quantity = 0;
+ if (quantity === null) quantity = 1;
input.type = "number";
input.name = "quantities";
input.value = quantity;
input.step = 0.001;
+ input.min = 0.001;
input.required = true;
parent.appendChild(input);
@@ -114,8 +116,9 @@ function addRow() {
return row;
}
-function addColumn(parent) {
+function addColumn(parent, className) {
let column = document.createElement("td");
+ if (className != null) column.className = className;
parent.appendChild(column);
return column;
@@ -165,4 +168,4 @@ function checkUnits(materialSelector, row) {
const quantityUnits = row.querySelector(".quantityUnit");
if (materialSelector.dataset.usepercentages === "true") quantityUnits.innerText = "%";
else quantityUnits.innerText = "mL";
-}
\ No newline at end of file
+}
diff --git a/src/main/resources/templates/company/creator.html b/src/main/resources/templates/company/creator.html
index 09bc65e..34eb105 100644
--- a/src/main/resources/templates/company/creator.html
+++ b/src/main/resources/templates/company/creator.html
@@ -12,7 +12,7 @@