Handle Ingredient Group display and save, shopcat finals

version2
Tim Holloway 2 years ago
parent 200317d177
commit 7d9ee67a86
  1. 9
      src/main/java/com/mousetech/gourmetj/EditShopcatBean.java
  2. 19
      src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java
  3. 8
      src/main/resources/META-INF/resources/css/style.css
  4. 14
      src/main/resources/META-INF/resources/detailEdit.xhtml
  5. 1
      src/main/resources/META-INF/resources/editShopcat.xhtml
  6. 1
      src/main/resources/META-INF/resources/recipeDetails.xhtml

@ -123,13 +123,4 @@ public class EditShopcatBean implements Serializable {
public void ajaxShopcatSuggest(AjaxBehaviorEvent event) { public void ajaxShopcatSuggest(AjaxBehaviorEvent event) {
this.shopcatName = this.shopcatSuggestion; this.shopcatName = this.shopcatSuggestion;
} }
/**
* ValueChangeListener for shopcat editor.
*
* @param e Event, with new name in it.
*/
public void shopcatNameChanged(ValueChangeEvent e) {
this.changed = true;
}
} }

@ -204,7 +204,6 @@ public class RecipeDetailBean implements Serializable {
ingredients ingredients
.setWrappedData(new ArrayList<IngredientUI>(1)); .setWrappedData(new ArrayList<IngredientUI>(1));
} }
log.info("Ingredient size="+ingredients.getRowCount());
return ingredients; return ingredients;
} }
@ -390,6 +389,9 @@ public class RecipeDetailBean implements Serializable {
updateSelectionStatus(); updateSelectionStatus();
} }
/**
* Manage the ability buttons based on selections.
*/
private void updateSelectionStatus() { private void updateSelectionStatus() {
List<IngredientUI> ingList = getWrappedIngredients(); List<IngredientUI> ingList = getWrappedIngredients();
final int ingCount = ingList.size(); final int ingCount = ingList.size();
@ -411,6 +413,8 @@ public class RecipeDetailBean implements Serializable {
this.setMoveUpAble(moveUpable && selectable); this.setMoveUpAble(moveUpable && selectable);
this.setMoveDownAble(moveDownable && selectable); this.setMoveDownAble(moveDownable && selectable);
this.setSelectable(selectable); this.setSelectable(selectable);
auditRows(ingList);
} }
// --- // ---
@ -456,7 +460,7 @@ public class RecipeDetailBean implements Serializable {
} }
} }
this.setDirty(); this.setDirty();
auditRows(rows); updateSelectionStatus();
} }
private void auditRows(List<IngredientUI> rows) { private void auditRows(List<IngredientUI> rows) {
@ -488,7 +492,7 @@ public class RecipeDetailBean implements Serializable {
rows.add(i, r); rows.add(i, r);
} }
} }
auditRows(rows); updateSelectionStatus();
} }
public void ajaxDeleteItems() { public void ajaxDeleteItems() {
@ -506,7 +510,7 @@ public class RecipeDetailBean implements Serializable {
for (IngredientUI row : selectedRows) { for (IngredientUI row : selectedRows) {
rows.remove(row); rows.remove(row);
} }
auditRows(rows); updateSelectionStatus();
} }
// ===== // =====
@ -707,9 +711,14 @@ public class RecipeDetailBean implements Serializable {
List<Ingredient> iList = recipe.getIngredientHash(); List<Ingredient> iList = recipe.getIngredientHash();
iList.clear(); iList.clear();
for (IngredientUI iui : saveIng) { for (IngredientUI iui : saveIng) {
if ( iui.isIngGroup() ) {
// Ing group is an attribute of ingredients.
continue;
}
Ingredient ing = iui.getIngredient(); Ingredient ing = iui.getIngredient();
ing.setRecipe(recipe); ing.setRecipe(recipe);
if (!updateShopcat(iui)) { if (!updateShopcat(iui)) { // Obsolete???
log.info("Shopcat has not been updated" +iui);
return false; return false;
} }
iList.add(ing); iList.add(ing);

@ -2,3 +2,11 @@
color: red; color: red;
background-color: blue; background-color: blue;
} }
.editIngGroupRow {
background-color: aqua;
font-weight: bold;
}
.displayIngGroupRow {
background-color: aqua;
font-weight: bold;
}

@ -177,7 +177,7 @@
disabled="#{not recipeDetailBean.moveUpAble}" disabled="#{not recipeDetailBean.moveUpAble}"
id="ctlUp" id="ctlUp"
actionListener="#{recipeDetailBean.ajaxMoveUp}" actionListener="#{recipeDetailBean.ajaxMoveUp}"
update="ingredientTable" update="@this:@parent:@parent"
onerror="PF('opError').show()" onerror="PF('opError').show()"
/> />
<p:commandButton value="Down" <p:commandButton value="Down"
@ -185,7 +185,7 @@
id="ctlDown" id="ctlDown"
onerror="PF('opError').show()" onerror="PF('opError').show()"
actionListener="#{recipeDetailBean.ajaxMoveDown}" actionListener="#{recipeDetailBean.ajaxMoveDown}"
update="ingredientTable" update="@this:@parent:@parent"
/> />
<p:commandButton <p:commandButton
value="Add Group" value="Add Group"
@ -206,7 +206,7 @@
disabled="#{not recipeDetailBean.selectable}" disabled="#{not recipeDetailBean.selectable}"
onerror="PF('opError').show()" onerror="PF('opError').show()"
actionListener="#{recipeDetailBean.ajaxDeleteItems}" actionListener="#{recipeDetailBean.ajaxDeleteItems}"
update="ingredientTable" update="@this:@parent:@parent"
/> />
</h:panelGroup> </h:panelGroup>
<p:dataTable id="ingredientTable" <p:dataTable id="ingredientTable"
@ -214,6 +214,7 @@
value="#{recipeDetailBean.ingredients}" value="#{recipeDetailBean.ingredients}"
scrollable="true" scrollable="true"
scrollHeight="380" var="item" scrollHeight="380" var="item"
rowStyleClass="#{item.ingGroup ? 'editIngGroupRow' : null}"
> >
<p:column label="Sel." <p:column label="Sel."
align="center" align="center"
@ -223,9 +224,10 @@
id="selected" id="selected"
value="#{item.selected}" value="#{item.selected}"
> >
<f:ajax <p:ajax
listener="#{recipeDetailBean.ajaxSelectionListener}" listener="#{recipeDetailBean.ajaxSelectionListener}"
render=":form1:tabGroupClient:ingButtons" update=":form1:tabGroupClient:ingButtons"
onerror="PF('opError').show()"
/> />
</p:selectBooleanCheckbox> </p:selectBooleanCheckbox>
</p:column> </p:column>
@ -292,7 +294,7 @@
<f:ajax <f:ajax
event="change" event="change"
listener="#{recipeDetailBean.ajaxUpdateShopcat(item)}" listener="#{recipeDetailBean.ajaxUpdateShopcat(item)}"
render="shopCat" render="eShopcat shopCat"
/> />
</p:inputText> </p:inputText>
</p:column> </p:column>

@ -26,7 +26,6 @@
value="Category Name" /> value="Category Name" />
<p:inputText id="ctlShopcat" <p:inputText id="ctlShopcat"
value="#{editShopcatBean.shopcatName}" value="#{editShopcatBean.shopcatName}"
valueChangeListener="#{editShopcatBean.shopcatNameChanged}"
> >
</p:inputText> </p:inputText>
<h:outputText <h:outputText

@ -147,6 +147,7 @@
showDirectLinksArrows="true" showDirectLinksArrows="true"
value="#{recipeDetailBean.ingredients}" value="#{recipeDetailBean.ingredients}"
var="ingredient" var="ingredient"
rowStyleClass="#{item.ingGroup ? 'displayIngGroupRow' : null}"
> >
<f:facet name="header"> <f:facet name="header">
<h:outputText <h:outputText

Loading…
Cancel
Save