diff --git a/.gitignore b/.gitignore index a547bf3..b6fe1e1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ node_modules dist dist-ssr *.local +target # Editor directories and files .vscode/* diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7034292 --- /dev/null +++ b/pom.xml @@ -0,0 +1,119 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 4.1.1 + + + de.timaldinger + einkaufsliste + 0.0.1-SNAPSHOT + + + + + + + + + + + + + + + + + 25 + + + + org.springframework.boot + spring-boot-starter-data-rest + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-webmvc + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.springframework.boot + spring-boot-starter-data-rest-test + test + + + org.springframework.boot + spring-boot-starter-thymeleaf-test + test + + + org.springframework.boot + spring-boot-starter-webmvc-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + compile + + compile + + + + + org.projectlombok + lombok + + + + + + default-testCompile + test-compile + + testCompile + + + + + org.projectlombok + lombok + + + + + + + + + + diff --git a/src/main/java/de/timaldinger/einkaufsliste/EinkaufslisteApplication.java b/src/main/java/de/timaldinger/einkaufsliste/EinkaufslisteApplication.java new file mode 100644 index 0000000..f9b4bbd --- /dev/null +++ b/src/main/java/de/timaldinger/einkaufsliste/EinkaufslisteApplication.java @@ -0,0 +1,13 @@ +package de.timaldinger.einkaufsliste; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class EinkaufslisteApplication { + + public static void main(String[] args) { + SpringApplication.run(EinkaufslisteApplication.class, args); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..bc95103 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=einkaufsliste diff --git a/src/main/resources/static/assets/index-DaqKi9ke.js b/src/main/resources/static/assets/index-DaqKi9ke.js new file mode 100644 index 0000000..47ed72b --- /dev/null +++ b/src/main/resources/static/assets/index-DaqKi9ke.js @@ -0,0 +1 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=class{constructor(e,t,n){this.itemName=e,this.itemAmount=t,this.isEditing=!1,this.isDone=!1,this.remove=!1,this.onChange=n}render(){let e;return e=this.isEditing?this.#e():this.#t(),e}#e(){let e=document.createElement(`li`),t=document.createElement(`form`),n=document.createElement(`input`),r=document.createElement(`input`),i=document.createElement(`button`),a=document.createElement(`button`);return n.setAttribute(`name`,`newItemName`),n.setAttribute(`value`,this.itemName),r.setAttribute(`itemName`,`newItemAmount`),r.setAttribute(`value`,this.itemAmount),a.textContent=`Abbrechen`,a.addEventListener(`click`,e=>{e.preventDefault(),this.isEditing=!1,this.onChange()}),i.textContent=`Speichern`,t.addEventListener(`submit`,e=>{e.preventDefault();let n=Object.fromEntries(new FormData(t));(n.newItemName||n.newItemAmount)&&(this.itemName=n.newItemName,this.itemAmount=n.newItemAmount,this.isEditing=!1,this.onChange())}),t.appendChild(n),t.appendChild(r),t.appendChild(i),t.appendChild(a),e.appendChild(t),e}#t(){let e=document.createElement(`li`),t=document.createElement(`span`),n=document.createElement(`button`),r=document.createElement(`input`);return r.setAttribute(`type`,`checkbox`),r.addEventListener(`change`,()=>{this.isDone=!0,e.classList.toggle(`displayedList__item--checked`)}),t.addEventListener(`click`,()=>{this.isEditing=!0,this.onChange()}),n.textContent=`Löschen`,n.addEventListener(`click`,()=>{this.remove=!0,this.onChange()}),t.textContent=this.itemName+` `+this.itemAmount,e.appendChild(r),e.appendChild(t),e.appendChild(n),e}},t=class{constructor(e,t,n){this.categoryName=e,this.itemsInCategory=[],this.remove=!1,this.isEditing=!1,this.onDelete=t,this.onUpdate=n}render(){let e,t=document.createElement(`li`);return e=this.isEditing?this.#e():this.#t(),t.append(e),t}#e(){let e=document.createElement(`form`),t=document.createElement(`input`),n=document.createElement(`button`),r=document.createElement(`button`);return t.setAttribute(`name`,`newCategoryName`),t.setAttribute(`value`,this.categoryName),r.textContent=`Abbrechen`,r.addEventListener(`click`,e=>{e.preventDefault(),this.isEditing=!1,this.onUpdate()}),n.textContent=`Speichern`,e.addEventListener(`submit`,t=>{t.preventDefault();let n=Object.fromEntries(new FormData(e));n.newCategoryName&&(this.categoryName=n.newCategoryName,this.isEditing=!1,this.onUpdate(),this.onDelete())}),e.appendChild(t),e.appendChild(n),e.appendChild(r),e}#t(){let e=document.createElement(`span`),t=document.createElement(`button`),n=document.createElement(`input`),r=document.createElement(`span`),i=document.createElement(`ul`),a=this.itemsInCategory.filter(e=>!e.remove);return e.textContent=this.categoryName,e.classList.add(`category__name--big`,`category__name--bold`),e.addEventListener(`click`,()=>{this.isEditing=!0,this.onUpdate()}),n.setAttribute(`type`,`checkbox`),r.textContent=`Alle Gegenstände in dieser Kategorie löschen? :`,t.textContent=`Löschen`,t.addEventListener(`click`,()=>{this.remove=!0,n.checked||this.itemsInCategory.forEach(e=>{c(e.itemName,e.itemAmount,``)}),this.onUpdate(),this.onDelete()}),i.appendChild(e),i.appendChild(t),i.appendChild(r),i.appendChild(n),a.forEach((e,t)=>{i.append(e.render())}),i}addItem(e){this.itemsInCategory.push(e)}},n=document.querySelector(`.addItemForm`),r=document.querySelector(`.addCategoryForm`),i=document.querySelector(`.displayedList`),a=document.querySelector(`.deleteAllDoneItemsButton`),o=[];function s(e){return o.push(new t(e,d,l)),l(),0}function c(n,r,i){return i?(i=o.find(e=>e instanceof t&&e.categoryName==i),i.addItem(new e(n,r,l))):o.push(new e(n,r,l)),l(),0}function l(){o=o.filter(e=>!e.remove),i.innerHTML=``,o.forEach((e,t)=>{i.appendChild(e.render(t))})}function u(){o.forEach((e,n)=>{e instanceof t&&(e.itemsInCategory=e.itemsInCategory.filter(e=>!e.isDone))}),o=o.filter(e=>!e.isDone),l()}function d(){let e=document.querySelector(`.addItemForm__categorySelect`),n=o.filter(e=>e instanceof t),r=document.createElement(`option`);r.setAttribute(`value`,``),r.selected=!0,r.textContent=`Keine`,e.innerHTML=``,e.appendChild(r),n.forEach(t=>{let n=document.createElement(`option`);n.setAttribute(`value`,t.categoryName),n.textContent=t.categoryName,e.appendChild(n)})}function f(){d(),n.addEventListener(`submit`,e=>{if(!n.checkValidity())return;e.preventDefault();let t=Object.fromEntries(new FormData(n));c(t.itemName,t.itemAmount,t.itemCategory)}),r.addEventListener(`submit`,e=>{r.checkValidity()&&(e.preventDefault(),s(Object.fromEntries(new FormData(r)).categoryName),d())}),a.addEventListener(`click`,e=>{u()})}f(); \ No newline at end of file diff --git a/src/main/resources/static/assets/index-Dk1Kzh8u.css b/src/main/resources/static/assets/index-Dk1Kzh8u.css new file mode 100644 index 0000000..e34206d --- /dev/null +++ b/src/main/resources/static/assets/index-Dk1Kzh8u.css @@ -0,0 +1 @@ +li.displayedList__item--checked{text-decoration:line-through}.category__name--big{font-size:2rem;font-weight:700} diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css new file mode 100644 index 0000000..66e9c74 --- /dev/null +++ b/src/main/resources/static/css/style.css @@ -0,0 +1,12 @@ +li.displayedList__item--checked{ + text-decoration: line-through; +} + +.category__name--big{ + font-weight: bold; +} + + +.category__name--big{ + font-size: 2rem; +} diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html new file mode 100644 index 0000000..92b03a2 --- /dev/null +++ b/src/main/resources/static/index.html @@ -0,0 +1,39 @@ + + + + + + Einkaufsliste + + + + +
+

Einkaufsliste

+
+ +
+
+ Neue Kategorie hinzufügen: + + +
+ +
+ +
+ Neuen Gegenstand hinzufügen: + + + + +
+ + + + +
+ + diff --git a/src/main/resources/templates/einkaufsliste.html b/src/main/resources/templates/einkaufsliste.html new file mode 100644 index 0000000..305a19a --- /dev/null +++ b/src/main/resources/templates/einkaufsliste.html @@ -0,0 +1,10 @@ + + + + + niggas + + + + + \ No newline at end of file diff --git a/src/test/java/de/timaldinger/einkaufsliste/EinkaufslisteApplicationTests.java b/src/test/java/de/timaldinger/einkaufsliste/EinkaufslisteApplicationTests.java new file mode 100644 index 0000000..5a25c38 --- /dev/null +++ b/src/test/java/de/timaldinger/einkaufsliste/EinkaufslisteApplicationTests.java @@ -0,0 +1,13 @@ +package de.timaldinger.einkaufsliste; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class EinkaufslisteApplicationTests { + + @Test + void contextLoads() { + } + +}