WIP feature/listedArticles #15
@ -27,10 +27,10 @@ public class InternArticleController {
 | 
				
			|||||||
	@GetMapping("/")
 | 
						@GetMapping("/")
 | 
				
			||||||
	public String internListedArticles(Model model) {
 | 
						public String internListedArticles(Model model) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		List<ListedArticlesListTotals> totals = new ArrayList<ListedArticlesListTotals>();
 | 
							List<UImodelArticles> totals = new ArrayList<UImodelArticles>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (Article article : articleRepository.findAll()) {
 | 
							for (Article article : articleRepository.findAll()) {
 | 
				
			||||||
			ListedArticlesListTotals tmp = new ListedArticlesListTotals();
 | 
								UImodelArticles tmp = new UImodelArticles();
 | 
				
			||||||
			tmp.addListedArticle(article, warehouseEntryRepository.getArticleStock(article.id).orElse(0));
 | 
								tmp.addListedArticle(article, warehouseEntryRepository.getArticleStock(article.id).orElse(0));
 | 
				
			||||||
			totals.add(tmp);
 | 
								totals.add(tmp);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -44,16 +44,10 @@ public class InternArticleController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		int articleid = Integer.parseInt(id);
 | 
							int articleid = Integer.parseInt(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ListedArticlesListIdTotal total = new ListedArticlesListIdTotal();
 | 
							UImodelArticle total = new UImodelArticle();
 | 
				
			||||||
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		total.addArticle(articleRepository.findArticleById(articleid),
 | 
							total.addArticle(articleRepository.findArticleById(articleid),
 | 
				
			||||||
				warehouseEntryRepository.getArticleStock(articleid).orElse(0));
 | 
									warehouseEntryRepository.getArticleStock(articleid).orElse(0));
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	//	System.out.println("GETshouldReorder: " + articleRepository.findArticleById(articleid).shouldReorder);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		model.addAttribute("ArticleID", total);
 | 
							model.addAttribute("ArticleID", total);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -61,36 +55,42 @@ public class InternArticleController {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@PostMapping("/{id}/saveChanges")
 | 
						@PostMapping("/{id}/saveChanges")
 | 
				
			||||||
	public RedirectView saveChanges(@ModelAttribute ListedArticlesListIdTotal changedArticleTotal) {
 | 
						public RedirectView saveChanges(
 | 
				
			||||||
 | 
								@ModelAttribute UImodelArticle changedArticleTotal,
 | 
				
			||||||
 | 
								@RequestParam("units-per-slot") String sWarehouseUnitsPerSlot,
 | 
				
			||||||
 | 
								@RequestParam("price_netto") String sPrice_netto, 
 | 
				
			||||||
 | 
								@RequestParam("reorderMaxPrice") String sReorderMaxPrice,
 | 
				
			||||||
 | 
								@RequestParam("autobuy") String sShouldReorder, 
 | 
				
			||||||
 | 
								@RequestParam("categories") String sCategories) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Article oldArticle = articleRepository.findArticleById(changedArticleTotal.id);
 | 
							Article oldArticle = articleRepository.findArticleById(changedArticleTotal.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//TODO img
 | 
							// TODO img
 | 
				
			||||||
		//TODO price
 | 
							// TODO categories
 | 
				
			||||||
		//TODO reorder price
 | 
							/*
 | 
				
			||||||
		//TODO categories
 | 
							 * String separatedCategories[] = sCategories.split("\\r?\\n");
 | 
				
			||||||
		
 | 
							 * 
 | 
				
			||||||
		
 | 
							 * 
 | 
				
			||||||
		
 | 
							 * for (int i = 0; i < separatedCategories.length; i++) {
 | 
				
			||||||
| 
							
							
								
									
	
	
	
	
	
	
	
	 | 
					|||||||
		// oldArticle.shopPricePerUnitNetCent = changedArticleTotal.price_netto;
 | 
							 * 
 | 
				
			||||||
		// System.out.println("netto: " + changedArticleTotal.price_netto);
 | 
							 * oldArticle.categories.add(separatedCategories[i]);
 | 
				
			||||||
		
 | 
							 * 
 | 
				
			||||||
		//System.out.println("POSTshouldReorder: " + oldArticle.shouldReorder);
 | 
							 * }
 | 
				
			||||||
		//oldArticle.shouldReorder = changedArticleTotal.shouldReorder;
 | 
							 */
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		System.out.println("POSTwarehouseUnitsPerSlot: " + oldArticle.warehouseUnitsPerSlot);
 | 
							oldArticle.shouldReorder = (sShouldReorder.equals("true")) ? true : false; 
 | 
				
			||||||
		
 | 
							oldArticle.reorderMaxPrice = (int) (Float.parseFloat(sReorderMaxPrice) * 100); 
 | 
				
			||||||
		//oldArticle.warehouseUnitsPerSlot = Integer.parseInt(changedArticleTotal.warehouseUnitsPerSlot);
 | 
							oldArticle.shopPricePerUnitNetCent = (int) (Float.parseFloat(sPrice_netto) * 100);
 | 
				
			||||||
		
 | 
							oldArticle.warehouseUnitsPerSlot = Integer.parseInt(sWarehouseUnitsPerSlot);
 | 
				
			||||||
		
 | 
							oldArticle.title = changedArticleTotal.title;
 | 
				
			||||||
		oldArticle.title = changedArticleTotal.title; //works
 | 
							oldArticle.description = changedArticleTotal.description;
 | 
				
			||||||
		oldArticle.description = changedArticleTotal.description; //works
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		articleRepository.save(oldArticle); // save updated article
 | 
							articleRepository.save(oldArticle); // save updated article
 | 
				
			||||||
		return new RedirectView("../");
 | 
							return new RedirectView("../"); //return to overview page
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static class ListedArticlesListTotals {
 | 
						
 | 
				
			||||||
 | 
						public static class UImodelArticles {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public String imgPath;
 | 
							public String imgPath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -120,7 +120,7 @@ public class InternArticleController {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static class ListedArticlesListIdTotal {
 | 
						public static class UImodelArticle {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public String getImgPath() {
 | 
							public String getImgPath() {
 | 
				
			||||||
			return imgPath;
 | 
								return imgPath;
 | 
				
			||||||
@ -154,11 +154,11 @@ public class InternArticleController {
 | 
				
			|||||||
			this.price_netto = price_netto;
 | 
								this.price_netto = price_netto;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public int getReorderMaxPrice() {
 | 
							public String getReorderMaxPrice() {
 | 
				
			||||||
			return reorderMaxPrice;
 | 
								return reorderMaxPrice;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public void setReorderMaxPrice(int reorderMaxPrice) {
 | 
							public void setReorderMaxPrice(String reorderMaxPrice) {
 | 
				
			||||||
			this.reorderMaxPrice = reorderMaxPrice;
 | 
								this.reorderMaxPrice = reorderMaxPrice;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -222,7 +222,7 @@ public class InternArticleController {
 | 
				
			|||||||
		public String title;
 | 
							public String title;
 | 
				
			||||||
		public String price;
 | 
							public String price;
 | 
				
			||||||
		public String price_netto;
 | 
							public String price_netto;
 | 
				
			||||||
		public int reorderMaxPrice;
 | 
							public String reorderMaxPrice;
 | 
				
			||||||
		public String categorie;
 | 
							public String categorie;
 | 
				
			||||||
		public int stock;
 | 
							public int stock;
 | 
				
			||||||
		public long offer_id;
 | 
							public long offer_id;
 | 
				
			||||||
@ -240,7 +240,7 @@ public class InternArticleController {
 | 
				
			|||||||
			this.stock = stock;
 | 
								this.stock = stock;
 | 
				
			||||||
			this.offer_id = article.related.id;
 | 
								this.offer_id = article.related.id;
 | 
				
			||||||
| 
						
							
	
	
	
	
	
	
	
	 
				
					
						Seil0
						commented  
			
		Variablen Dekleration vor setter/getter? (Ich hab keine Ahnung ob wir da was ausgemacht haben) Variablen Dekleration vor setter/getter? (Ich hab keine Ahnung ob wir da was ausgemacht haben) 
			
			
		
				
					
						localhorst
						commented  
			
		ist ja ne ui model klasse die nur in diesem controller gebraucht wird. Wenn es keine Getter+Setter gibt werden die auch nicht gebraucht. ist ja ne ui model klasse die nur in diesem controller gebraucht wird. Wenn es keine Getter+Setter gibt werden die auch nicht gebraucht. 
			
			
		
				
					
						Seil0
						commented  
			
		Dann passt's so Dann passt's so 
			
			
		
				
					
						localhorst
						commented  
			
		fixed with  fixed with https://git.mosad.xyz/localhorst/e-commerce/commit/b1840dd84529acb8d4949913b35e1c1aea821b00 
			
			
		 | 
				|||||||
			this.id = article.id;
 | 
								this.id = article.id;
 | 
				
			||||||
			this.reorderMaxPrice = article.reorderMaxPrice;
 | 
								this.reorderMaxPrice = String.format("%.2f", ((float) article.reorderMaxPrice / 100));
 | 
				
			||||||
			this.shouldReorder = article.shouldReorder;
 | 
								this.shouldReorder = article.shouldReorder;
 | 
				
			||||||
			this.warehouseUnitsPerSlot = String.valueOf(article.warehouseUnitsPerSlot);
 | 
								this.warehouseUnitsPerSlot = String.valueOf(article.warehouseUnitsPerSlot);
 | 
				
			||||||
			this.description = article.description;
 | 
								this.description = article.description;
 | 
				
			||||||
 | 
				
			|||||||
@ -42,6 +42,7 @@ public class Article
 | 
				
			|||||||
	@JoinTable(name = "article_categories_bindings")
 | 
						@JoinTable(name = "article_categories_bindings")
 | 
				
			||||||
	public Set<Category> categories = new HashSet<>();
 | 
						public Set<Category> categories = new HashSet<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// returns all categories as string
 | 
				
			||||||
	public String getCategories()
 | 
						public String getCategories()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		StringBuilder result = new StringBuilder();
 | 
							StringBuilder result = new StringBuilder();
 | 
				
			||||||
 | 
				
			|||||||
@ -52,14 +52,14 @@
 | 
				
			|||||||
            <div class="s">
 | 
					            <div class="s">
 | 
				
			||||||
                <p>
 | 
					                <p>
 | 
				
			||||||
                    <label for="price">Preis (Netto)</label>
 | 
					                    <label for="price">Preis (Netto)</label>
 | 
				
			||||||
                    <input class="" type="number" step="0.01" name="price" th:value="${ArticleID.price_netto}"/> EUR <br/>
 | 
					                    <input class="" type="number" step="0.01" name="price_netto" th:value="${ArticleID.price_netto}"/> EUR <br/>
 | 
				
			||||||
                    (19% Mwst.)
 | 
					                    (19% Mwst.)
 | 
				
			||||||
                    <!-- Info von article ref--> <br/>
 | 
					                    <!-- Info von article ref--> <br/>
 | 
				
			||||||
                    = <span th:text="${ArticleID.price}"></span> EUR Brutto
 | 
					                    = <span th:text="${ArticleID.price}"></span> EUR Brutto
 | 
				
			||||||
                </p>
 | 
					                </p>
 | 
				
			||||||
                <p>
 | 
					                <p>
 | 
				
			||||||
                    <label for="max-price-buy">Maximaler Einkaufspreis (Netto)</label>
 | 
					                    <label for="max-price-buy">Maximaler Einkaufspreis (Netto)</label>
 | 
				
			||||||
                    <input class="" type="number" step="0.01" name="price" th:value="${ArticleID.reorderMaxPrice}"/> EUR
 | 
					                    <input class="" type="number" step="0.01" name="reorderMaxPrice" th:value="${ArticleID.reorderMaxPrice}"/> EUR
 | 
				
			||||||
                </p>
 | 
					                </p>
 | 
				
			||||||
                <div>
 | 
					                <div>
 | 
				
			||||||
                    <fieldset>
 | 
					                    <fieldset>
 | 
				
			||||||
@ -76,7 +76,7 @@
 | 
				
			|||||||
                <p>
 | 
					                <p>
 | 
				
			||||||
                    Bitte jede Kategorien in eine eigene Zeile
 | 
					                    Bitte jede Kategorien in eine eigene Zeile
 | 
				
			||||||
                </p>
 | 
					                </p>
 | 
				
			||||||
                <textarea name="tags" class="full-width" rows="6"th:inline="text">[[${ArticleID.categorie}]]
 | 
					                <textarea name="categories" class="full-width" rows="6"th:inline="text">[[${ArticleID.categorie}]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
               </textarea>
 | 
					               </textarea>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
@ -84,7 +84,7 @@
 | 
				
			|||||||
            <div class="s">
 | 
					            <div class="s">
 | 
				
			||||||
                <p>
 | 
					                <p>
 | 
				
			||||||
                    <label for="price">Einheiten pro Lagerplatz</label>
 | 
					                    <label for="price">Einheiten pro Lagerplatz</label>
 | 
				
			||||||
                    <input class="" type="number" name="units-per-slot" th:field="${ArticleID.warehouseUnitsPerSlot}"/>                    
 | 
					                    <input class="" type="number" name="units-per-slot" th:value="${ArticleID.warehouseUnitsPerSlot}"/>                    
 | 
				
			||||||
                </p>
 | 
					                </p>
 | 
				
			||||||
                <p>
 | 
					                <p>
 | 
				
			||||||
                    <b>Lagerbestand: <span th:text="${ArticleID.stock}"></span></b>
 | 
					                    <b>Lagerbestand: <span th:text="${ArticleID.stock}"></span></b>
 | 
				
			||||||
 | 
				
			|||||||
String[] separatedCategories
fixed with
a98782bc01