Save with bad ingkey, print page fixes
This commit is contained in:
parent
bc368f084c
commit
af7c49713a
|
@ -5,9 +5,6 @@ import com.mousetech.gourmetj.persistence.model.IngredientIF;
|
||||||
import com.mousetech.gourmetj.persistence.model.Recipe;
|
import com.mousetech.gourmetj.persistence.model.Recipe;
|
||||||
import com.mousetech.gourmetj.persistence.model.Shopcat;
|
import com.mousetech.gourmetj.persistence.model.Shopcat;
|
||||||
|
|
||||||
import net.bytebuddy.asm.Advice.This;
|
|
||||||
|
|
||||||
import com.mousetech.gourmetj.IngredientDigester;
|
|
||||||
import com.mousetech.gourmetj.IngredientDigester.IngredientAmountFormat;
|
import com.mousetech.gourmetj.IngredientDigester.IngredientAmountFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,9 +23,13 @@ public class IngredientUI implements IngredientIF {
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param ingredient
|
* @param ingredient Ingredient that we facade. If null,
|
||||||
|
* constructs a dummy Ingredient (example, for group item).
|
||||||
*/
|
*/
|
||||||
public IngredientUI(Ingredient ingredient) {
|
public IngredientUI(Ingredient ingredient) {
|
||||||
|
if ( ingredient == null ) {
|
||||||
|
ingredient = new Ingredient();
|
||||||
|
}
|
||||||
this.ingredient = ingredient;
|
this.ingredient = ingredient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,17 @@ public class JSFUtils {
|
||||||
.getExternalContext().getFlash());
|
.getExternalContext().getFlash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look in Flash scope for item.
|
||||||
|
*
|
||||||
|
* @param key Item to retrieve
|
||||||
|
* @return Item, or null if not in Flash OR Flash not active
|
||||||
|
*/
|
||||||
public static Object getFlash(String key) {
|
public static Object getFlash(String key) {
|
||||||
|
Flash flash = flashScope();
|
||||||
|
if ( flash == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return flashScope().get(key);
|
return flashScope().get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ public class RecipeDetailBean implements Serializable {
|
||||||
*/
|
*/
|
||||||
if (this.recipe == null) {
|
if (this.recipe == null) {
|
||||||
Long rid =
|
Long rid =
|
||||||
(Long) JSFUtils.flashScope().get("recipeID");
|
(Long) JSFUtils.getFlash("recipeID");
|
||||||
if (rid != null) {
|
if (rid != null) {
|
||||||
this.recipe = loadRecipe(rid);
|
this.recipe = loadRecipe(rid);
|
||||||
} else {
|
} else {
|
||||||
|
@ -704,7 +704,7 @@ public class RecipeDetailBean implements Serializable {
|
||||||
JSFUtils.addErrorMessage(
|
JSFUtils.addErrorMessage(
|
||||||
"No Shopping Category is defined for Ingredient Key "
|
"No Shopping Category is defined for Ingredient Key "
|
||||||
+ ingKey);
|
+ ingKey);
|
||||||
return false;
|
//return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
ing.setShopCat(scat);
|
ing.setShopCat(scat);
|
||||||
|
@ -1008,4 +1008,35 @@ public class RecipeDetailBean implements Serializable {
|
||||||
long now = new java.util.Date().getTime();
|
long now = new java.util.Date().getTime();
|
||||||
return String.valueOf(now);
|
return String.valueOf(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//*** Add Group
|
||||||
|
|
||||||
|
private String newGroupName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the newGroupName
|
||||||
|
*/
|
||||||
|
public String getNewGroupName() {
|
||||||
|
return newGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param newGroupName the newGroupName to set
|
||||||
|
*/
|
||||||
|
public void setNewGroupName(String newGroupName) {
|
||||||
|
this.newGroupName = newGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new group to bottom of model as AJAX operation.
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public String doAddGroup() {
|
||||||
|
IngredientUI iui = new IngredientUI(null);
|
||||||
|
iui.setIngGroup(true);
|
||||||
|
iui.setItem(this.getNewGroupName());
|
||||||
|
List<IngredientUI> ingUIList = this.getWrappedIngredients();
|
||||||
|
ingUIList.add(iui);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,8 +165,9 @@
|
||||||
render="ingredientTable"
|
render="ingredientTable"
|
||||||
/>
|
/>
|
||||||
</p:commandButton>
|
</p:commandButton>
|
||||||
<p:button value="Add Group"
|
<p:commandButton
|
||||||
disabled="true"
|
value="Add Group"
|
||||||
|
onclick="PF('addGroupDlg').show()"
|
||||||
/>
|
/>
|
||||||
<p:button
|
<p:button
|
||||||
value="Add Recipe As Ingredient"
|
value="Add Recipe As Ingredient"
|
||||||
|
@ -255,6 +256,7 @@
|
||||||
id="ingOpt"
|
id="ingOpt"
|
||||||
value="#{item.optionalCB}"
|
value="#{item.optionalCB}"
|
||||||
rendered="#{not item.ingGroup}"
|
rendered="#{not item.ingGroup}"
|
||||||
|
title="Optional item"
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column style="width: 13em">
|
<p:column style="width: 13em">
|
||||||
|
@ -274,9 +276,7 @@
|
||||||
/>
|
/>
|
||||||
</p:inputText>
|
</p:inputText>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column
|
<p:column style="width: 2em">
|
||||||
style="width: 2em"
|
|
||||||
>
|
|
||||||
<f:facet name="header">
|
<f:facet name="header">
|
||||||
E
|
E
|
||||||
</f:facet>
|
</f:facet>
|
||||||
|
@ -287,6 +287,7 @@
|
||||||
update="editShopcatDlg"
|
update="editShopcatDlg"
|
||||||
oncomplete="PF('editShopcatDlg').show()"
|
oncomplete="PF('editShopcatDlg').show()"
|
||||||
title="Edit the shopping category for ing. key"
|
title="Edit the shopping category for ing. key"
|
||||||
|
rendered="#{not item.ingGroup}"
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column>
|
<p:column>
|
||||||
|
@ -351,6 +352,7 @@
|
||||||
</p:tab>
|
</p:tab>
|
||||||
</p:tabView>
|
</p:tabView>
|
||||||
<p:commandButton id="doSave" value="Save"
|
<p:commandButton id="doSave" value="Save"
|
||||||
|
icon="pi pi-check"
|
||||||
disabled="{not recipeDetailBean.dirty}"
|
disabled="{not recipeDetailBean.dirty}"
|
||||||
action="#{recipeDetailBean.doSave}"
|
action="#{recipeDetailBean.doSave}"
|
||||||
/>
|
/>
|
||||||
|
@ -359,6 +361,32 @@
|
||||||
/>
|
/>
|
||||||
</h:form>
|
</h:form>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
|
<p:dialog id="addGroupDlg" widgetVar="addGroupDlg">
|
||||||
|
<h:form id="frmAddGroup">
|
||||||
|
<p:panelGrid columns="1">
|
||||||
|
<p:outputLabel for="@next"
|
||||||
|
value="Group Name"
|
||||||
|
/>
|
||||||
|
<p:inputText id="ctlNewGroupName"
|
||||||
|
value="#{recipeDetailBean.newGroupName}"
|
||||||
|
/>
|
||||||
|
<p:panelGrid columns="2"
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<p:commandButton id="agDlgOK"
|
||||||
|
value="OK" style="width: 6em"
|
||||||
|
action="#{recipeDetailBean.doAddGroup}"
|
||||||
|
update="form1:tabGroupClient:ingredientTable"
|
||||||
|
oncomplete="PF('addGroupDlg').hide()"
|
||||||
|
/>
|
||||||
|
<p:commandButton id="agDlgCan"
|
||||||
|
value="Cancel" style="width: 6em"
|
||||||
|
onclick="PF('addGroupDlg').hide()"
|
||||||
|
/>
|
||||||
|
</p:panelGrid>
|
||||||
|
</p:panelGrid>
|
||||||
|
</h:form>
|
||||||
|
</p:dialog>
|
||||||
<p:dialog id="editShopcatDlg"
|
<p:dialog id="editShopcatDlg"
|
||||||
widgetVar="editShopcatDlg"
|
widgetVar="editShopcatDlg"
|
||||||
>
|
>
|
||||||
|
|
|
@ -9,15 +9,29 @@
|
||||||
<!-- Print Recipe -->
|
<!-- Print Recipe -->
|
||||||
<ui:define name="title">Gourmet Recipe Manager</ui:define>
|
<ui:define name="title">Gourmet Recipe Manager</ui:define>
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
|
<h:form id="printForm">
|
||||||
<h:messages />
|
<h:messages />
|
||||||
|
<p:panelGrid
|
||||||
|
style="margin-bottom: 5px; border-style: none"
|
||||||
|
>
|
||||||
|
<p:column>
|
||||||
<img id="bigpix"
|
<img id="bigpix"
|
||||||
SRC="/img/picture/#{recipeDetailBean.recipe.id}"
|
SRC="/img/picture/#{recipeDetailBean.recipe.id}"
|
||||||
/>
|
/>
|
||||||
<p:commandButton value="<- Back" action="main.jsf" />
|
</p:column>
|
||||||
|
<p:column
|
||||||
|
style="vertical-align: middle; text-align: left; border: none"
|
||||||
|
>
|
||||||
|
<p:commandButton value="<- Back"
|
||||||
|
style="margin-left: 2em" immediate="true"
|
||||||
|
action="/main.jsf"
|
||||||
|
/>
|
||||||
|
</p:column>
|
||||||
|
</p:panelGrid>
|
||||||
<p:panelGrid columns="2">
|
<p:panelGrid columns="2">
|
||||||
<h:outputLabel for="@next" value="Category: " />
|
<h:outputLabel for="@next" value="Category: " />
|
||||||
<h:outputText
|
<h:outputText
|
||||||
value="#{adminMainBean.formatCategories(recipeDetailBean.recipe)}"
|
value="#{userSession.formatCategories(recipeDetailBean.recipe)}"
|
||||||
/>
|
/>
|
||||||
<h:outputLabel for="@next" value="Cuisine: " />
|
<h:outputLabel for="@next" value="Cuisine: " />
|
||||||
<h:outputText
|
<h:outputText
|
||||||
|
@ -33,34 +47,55 @@
|
||||||
/>
|
/>
|
||||||
</p:panelGrid>
|
</p:panelGrid>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<p:panelGrid columns="1" id="ingredientsc">
|
<p:panelGrid id="ingredientsc">
|
||||||
<f:facet name="header">
|
<f:facet name="header">
|
||||||
<h:outputText styleClass="subtitle"
|
<h:outputText styleClass="subtitle"
|
||||||
value="Ingredients"
|
value="Ingredients"
|
||||||
/>
|
/>
|
||||||
</f:facet>
|
</f:facet>
|
||||||
|
<p:column style="padding: 0px 4px">
|
||||||
<p:dataTable id="ingredients"
|
<p:dataTable id="ingredients"
|
||||||
showDirectLinksArrows="true"
|
showDirectLinksArrows="true"
|
||||||
value="#{recipeDetailBean.ingredients}"
|
value="#{recipeDetailBean.ingredients}"
|
||||||
var="ingredient"
|
var="ingredient"
|
||||||
>
|
>
|
||||||
<p:column label="Amt" style="text-align: right">
|
<p:column
|
||||||
|
style="text-align: right; width: 2em"
|
||||||
|
>
|
||||||
|
<f:facet name="header">
|
||||||
|
Amt.
|
||||||
|
</f:facet>
|
||||||
<h:outputText
|
<h:outputText
|
||||||
value="#{ingredient.displayAmount}"
|
value="#{ingredient.displayAmount}"
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column label="Units">
|
<p:column style="width: 6em">
|
||||||
<h:outputText value="#{ingredient.unit}" />
|
<f:facet name="header">Units</f:facet>
|
||||||
|
<h:outputText
|
||||||
|
value="#{ingredient.unit}"
|
||||||
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column label="Item">
|
<p:column>
|
||||||
<h:outputText value="#{ingredient.item}" />
|
<f:facet name="header">
|
||||||
|
Item
|
||||||
|
</f:facet>
|
||||||
|
<h:outputText
|
||||||
|
value="#{ingredient.item}"
|
||||||
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
<p:column label="Optional" align="center">
|
<p:column align="center"
|
||||||
<p:selectBooleanCheckbox readonly="true"
|
style="width: 2em"
|
||||||
|
>
|
||||||
|
<f:facet name="header">
|
||||||
|
Opt.
|
||||||
|
</f:facet>
|
||||||
|
<p:selectBooleanCheckbox
|
||||||
|
readonly="true"
|
||||||
value="#{ingredient.optionalCB}"
|
value="#{ingredient.optionalCB}"
|
||||||
/>
|
/>
|
||||||
</p:column>
|
</p:column>
|
||||||
</p:dataTable>
|
</p:dataTable>
|
||||||
|
</p:column>
|
||||||
</p:panelGrid>
|
</p:panelGrid>
|
||||||
<h:outputText
|
<h:outputText
|
||||||
value="Recipe ID: #{recipeDetailBean.recipe.id}"
|
value="Recipe ID: #{recipeDetailBean.recipe.id}"
|
||||||
|
@ -78,11 +113,14 @@
|
||||||
</p:panelGrid>
|
</p:panelGrid>
|
||||||
<p:panelGrid columns="1">
|
<p:panelGrid columns="1">
|
||||||
<f:facet name="header">
|
<f:facet name="header">
|
||||||
<h:outputText styleClass="subtitle" value="Notes" />
|
<h:outputText styleClass="subtitle"
|
||||||
|
value="Notes"
|
||||||
|
/>
|
||||||
</f:facet>
|
</f:facet>
|
||||||
<h:outputText escape="false"
|
<h:outputText escape="false"
|
||||||
value="#{recipeDetailBean.modifications}"
|
value="#{recipeDetailBean.modifications}"
|
||||||
/>
|
/>
|
||||||
</p:panelGrid>
|
</p:panelGrid>
|
||||||
|
</h:form>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
</ui:composition>
|
</ui:composition>
|
Loading…
Reference in New Issue
Block a user