Handle Ingredient Group display and save, shopcat finals

This commit is contained in:
Tim Holloway 2022-01-10 12:40:25 -05:00
parent 200317d177
commit 7d9ee67a86
6 changed files with 31 additions and 21 deletions

View File

@ -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;
}
}

View File

@ -204,7 +204,6 @@ public class RecipeDetailBean implements Serializable {
ingredients
.setWrappedData(new ArrayList<IngredientUI>(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<IngredientUI> 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<IngredientUI> 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<Ingredient> 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);

View File

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

View File

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

View File

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

View File

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