From 7d9ee67a863588e499feba8d48f15b6b96d8f2ae Mon Sep 17 00:00:00 2001 From: Tim Holloway Date: Mon, 10 Jan 2022 12:40:25 -0500 Subject: [PATCH] Handle Ingredient Group display and save, shopcat finals --- .../mousetech/gourmetj/EditShopcatBean.java | 9 --------- .../mousetech/gourmetj/RecipeDetailBean.java | 19 ++++++++++++++----- .../META-INF/resources/css/style.css | 8 ++++++++ .../META-INF/resources/detailEdit.xhtml | 14 ++++++++------ .../META-INF/resources/editShopcat.xhtml | 1 - .../META-INF/resources/recipeDetails.xhtml | 1 + 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/mousetech/gourmetj/EditShopcatBean.java b/src/main/java/com/mousetech/gourmetj/EditShopcatBean.java index d82e896..ce8629a 100644 --- a/src/main/java/com/mousetech/gourmetj/EditShopcatBean.java +++ b/src/main/java/com/mousetech/gourmetj/EditShopcatBean.java @@ -123,13 +123,4 @@ public class EditShopcatBean implements Serializable { public void ajaxShopcatSuggest(AjaxBehaviorEvent event) { this.shopcatName = this.shopcatSuggestion; } - - /** - * ValueChangeListener for shopcat editor. - * - * @param e Event, with new name in it. - */ - public void shopcatNameChanged(ValueChangeEvent e) { - this.changed = true; - } } diff --git a/src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java b/src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java index d276eb2..e77eef9 100644 --- a/src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java +++ b/src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java @@ -204,7 +204,6 @@ public class RecipeDetailBean implements Serializable { ingredients .setWrappedData(new ArrayList(1)); } - log.info("Ingredient size="+ingredients.getRowCount()); return ingredients; } @@ -390,6 +389,9 @@ public class RecipeDetailBean implements Serializable { updateSelectionStatus(); } + /** + * Manage the ability buttons based on selections. + */ private void updateSelectionStatus() { List ingList = getWrappedIngredients(); final int ingCount = ingList.size(); @@ -411,6 +413,8 @@ public class RecipeDetailBean implements Serializable { this.setMoveUpAble(moveUpable && selectable); this.setMoveDownAble(moveDownable && selectable); this.setSelectable(selectable); + + auditRows(ingList); } // --- @@ -456,7 +460,7 @@ public class RecipeDetailBean implements Serializable { } } this.setDirty(); - auditRows(rows); + updateSelectionStatus(); } private void auditRows(List rows) { @@ -488,7 +492,7 @@ public class RecipeDetailBean implements Serializable { rows.add(i, r); } } - auditRows(rows); + updateSelectionStatus(); } public void ajaxDeleteItems() { @@ -506,7 +510,7 @@ public class RecipeDetailBean implements Serializable { for (IngredientUI row : selectedRows) { rows.remove(row); } - auditRows(rows); + updateSelectionStatus(); } // ===== @@ -707,9 +711,14 @@ public class RecipeDetailBean implements Serializable { List iList = recipe.getIngredientHash(); iList.clear(); for (IngredientUI iui : saveIng) { + if ( iui.isIngGroup() ) { + // Ing group is an attribute of ingredients. + continue; + } Ingredient ing = iui.getIngredient(); ing.setRecipe(recipe); - if (!updateShopcat(iui)) { + if (!updateShopcat(iui)) { // Obsolete??? + log.info("Shopcat has not been updated" +iui); return false; } iList.add(ing); diff --git a/src/main/resources/META-INF/resources/css/style.css b/src/main/resources/META-INF/resources/css/style.css index 135bc8c..a89a4be 100644 --- a/src/main/resources/META-INF/resources/css/style.css +++ b/src/main/resources/META-INF/resources/css/style.css @@ -2,3 +2,11 @@ color: red; background-color: blue; } +.editIngGroupRow { + background-color: aqua; + font-weight: bold; +} +.displayIngGroupRow { + background-color: aqua; + font-weight: bold; +} \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/detailEdit.xhtml b/src/main/resources/META-INF/resources/detailEdit.xhtml index 5525b04..a2fa85a 100644 --- a/src/main/resources/META-INF/resources/detailEdit.xhtml +++ b/src/main/resources/META-INF/resources/detailEdit.xhtml @@ -177,7 +177,7 @@ disabled="#{not recipeDetailBean.moveUpAble}" id="ctlUp" actionListener="#{recipeDetailBean.ajaxMoveUp}" - update="ingredientTable" + update="@this:@parent:@parent" onerror="PF('opError').show()" /> - @@ -292,7 +294,7 @@ diff --git a/src/main/resources/META-INF/resources/editShopcat.xhtml b/src/main/resources/META-INF/resources/editShopcat.xhtml index d8e917e..0b370ca 100644 --- a/src/main/resources/META-INF/resources/editShopcat.xhtml +++ b/src/main/resources/META-INF/resources/editShopcat.xhtml @@ -26,7 +26,6 @@ value="Category Name" />