misc mainpage and detail edit cleanup
This commit is contained in:
parent
ce7576e459
commit
d4d3179017
|
@ -92,6 +92,7 @@ public class AdminMainBean implements Serializable {
|
|||
*/
|
||||
public void setSearchText(String searchText) {
|
||||
this.searchText = searchText;
|
||||
userSession.setLastSearch(searchText);
|
||||
}
|
||||
|
||||
/**/
|
||||
|
|
|
@ -159,6 +159,7 @@ public class RecipeDetailBean implements Serializable {
|
|||
|
||||
/**
|
||||
* @return the category as a comma-separated list.
|
||||
* @see #stringifyCategories(Recipe)
|
||||
*/
|
||||
public String getCategory() {
|
||||
return category;
|
||||
|
@ -241,6 +242,8 @@ public class RecipeDetailBean implements Serializable {
|
|||
|
||||
getIngredients().setWrappedData(
|
||||
buildIngredientFacade(recipe.getIngredientHash()));
|
||||
stringifyCategories(recipe);
|
||||
|
||||
log.info("Set recipe: " + this.recipe);
|
||||
}
|
||||
|
||||
|
@ -255,7 +258,19 @@ public class RecipeDetailBean implements Serializable {
|
|||
if (recipe == null) {
|
||||
return null;
|
||||
}
|
||||
stringifyCategories(recipe);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories are a Set attached to recipe. Build
|
||||
* a displayable comma-separated list of them.
|
||||
*
|
||||
* @param recipe Recipe to get categories from.
|
||||
*
|
||||
* @see #getCategory()
|
||||
*/
|
||||
private void stringifyCategories(Recipe recipe) {
|
||||
Set<Category> cList = recipe.getCategories();
|
||||
StringBuffer sb = new StringBuffer(35);
|
||||
boolean first = true;
|
||||
|
@ -268,7 +283,6 @@ public class RecipeDetailBean implements Serializable {
|
|||
sb.append(cat.getCategory());
|
||||
}
|
||||
this.category = sb.toString();
|
||||
return recipe;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -344,7 +358,8 @@ public class RecipeDetailBean implements Serializable {
|
|||
if (instructions == null) {
|
||||
return "";
|
||||
}
|
||||
String s = instructions.replace("\n\n", "<p/>");
|
||||
String s = instructions.replace("\r\n", "<p/>")
|
||||
.replace("\n\n", "<p/>");
|
||||
s = s.replace("\n", "<br/>");
|
||||
return s;
|
||||
}
|
||||
|
@ -413,11 +428,11 @@ public class RecipeDetailBean implements Serializable {
|
|||
this.setMoveUpAble(moveUpable && selectable);
|
||||
this.setMoveDownAble(moveDownable && selectable);
|
||||
this.setSelectable(selectable);
|
||||
|
||||
|
||||
auditRows(ingList);
|
||||
}
|
||||
|
||||
// ---
|
||||
// ---
|
||||
public void setMoveUpAble(boolean moveUpable) {
|
||||
this.moveUpable = moveUpable;
|
||||
}
|
||||
|
@ -464,11 +479,11 @@ public class RecipeDetailBean implements Serializable {
|
|||
}
|
||||
|
||||
private void auditRows(List<IngredientUI> rows) {
|
||||
log.info("=== AUDIT ROWS ===");
|
||||
for ( IngredientUI row : rows ) {
|
||||
log.info((row.isSelected() ? "[X]" : "[ ]" ) +" ROW="+row);
|
||||
}
|
||||
log.info("=== DONE ===");
|
||||
// log.info("=== AUDIT ROWS ===");
|
||||
// for ( IngredientUI row : rows ) {
|
||||
// log.info((row.isSelected() ? "[X]" : "[ ]" ) +" ROW="+row);
|
||||
// }
|
||||
// log.info("=== DONE ===");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -527,21 +542,21 @@ public class RecipeDetailBean implements Serializable {
|
|||
* Invoked when the "E"(dit" button for Ingkey shopping
|
||||
* category has been clicked.
|
||||
*
|
||||
* @param item The item whose ingredient key will
|
||||
* have its shopping category edited. Resets the dialog
|
||||
* backing bean internal state.
|
||||
* @param item The item whose ingredient key will have its
|
||||
* shopping category edited. Resets the dialog
|
||||
* backing bean internal state.
|
||||
*/
|
||||
public void ajaxEditShopcat(IngredientUI item) {
|
||||
editShopcatBean.beginEdit(item.getIngkey(),
|
||||
editShopcatBean.beginEdit(item.getIngkey(),
|
||||
item.getShopCat());
|
||||
}
|
||||
|
||||
/**
|
||||
* On "OK" for edit shopcat where shopcat has changed,
|
||||
* update the shopcat Entity and the ingredients.
|
||||
* On "OK" for edit shopcat where shopcat has changed, update
|
||||
* the shopcat Entity and the ingredients.
|
||||
*/
|
||||
public void doUpdateShopcat() {
|
||||
|
||||
|
||||
final String key = editShopcatBean.getIngkey();
|
||||
if (StringUtils.isBlank(key)) {
|
||||
return; // Do not set category if no ingKey
|
||||
|
@ -555,20 +570,20 @@ public class RecipeDetailBean implements Serializable {
|
|||
sc = new Shopcat();
|
||||
sc.setIngkey(key);
|
||||
} else {
|
||||
if ( StringUtils.equals(sc.getShopcategory(), catname) ) {
|
||||
if (StringUtils.equals(sc.getShopcategory(),
|
||||
catname)) {
|
||||
return; // No change
|
||||
}
|
||||
}
|
||||
}
|
||||
sc.setShopcategory(catname);
|
||||
|
||||
/*
|
||||
* Because the database does not have a UNIQUE
|
||||
* constraint on ingkeys, we must delete old
|
||||
* shopcat(s) for this key before adding (updating)
|
||||
* the new shopcat.
|
||||
/*
|
||||
* Because the database does not have a UNIQUE constraint
|
||||
* on ingkeys, we must delete old shopcat(s) for this key
|
||||
* before adding (updating) the new shopcat.
|
||||
*/
|
||||
this.recipeService.deleteShopcatByIngKey(key);
|
||||
if (! StringUtils.isBlank(catname)) {
|
||||
if (!StringUtils.isBlank(catname)) {
|
||||
this.recipeService.saveShopcat(sc);
|
||||
}
|
||||
updateDisplayedShopcats(key, sc);
|
||||
|
@ -711,14 +726,14 @@ public class RecipeDetailBean implements Serializable {
|
|||
List<Ingredient> iList = recipe.getIngredientHash();
|
||||
iList.clear();
|
||||
for (IngredientUI iui : saveIng) {
|
||||
if ( iui.isIngGroup() ) {
|
||||
if (iui.isIngGroup()) {
|
||||
// Ing group is an attribute of ingredients.
|
||||
continue;
|
||||
}
|
||||
Ingredient ing = iui.getIngredient();
|
||||
ing.setRecipe(recipe);
|
||||
if (!updateShopcat(iui)) { // Obsolete???
|
||||
log.info("Shopcat has not been updated" +iui);
|
||||
log.info("Shopcat has not been updated" + iui);
|
||||
return false;
|
||||
}
|
||||
iList.add(ing);
|
||||
|
@ -769,7 +784,7 @@ public class RecipeDetailBean implements Serializable {
|
|||
ing.setShopCat(scat);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse out the comma-separated category text control and
|
||||
* post the results as children of the recipe
|
||||
|
@ -798,7 +813,7 @@ public class RecipeDetailBean implements Serializable {
|
|||
cat.setId(ocat.getId());
|
||||
}
|
||||
}
|
||||
recipe.setCategories(new HashSet(newList));
|
||||
recipe.setCategories(new HashSet<Category>(newList));
|
||||
}
|
||||
|
||||
private Category searchCategory(Set<Category> oldList,
|
||||
|
@ -978,7 +993,7 @@ public class RecipeDetailBean implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the suggestCategory
|
||||
* @return the suggestCategory List
|
||||
*/
|
||||
public List<String> getSuggestCategory() {
|
||||
if (suggestCategory == null) {
|
||||
|
|
|
@ -54,9 +54,6 @@
|
|||
</h:form>
|
||||
<!-- -->
|
||||
<h:form id="frmOpErr">
|
||||
<p:commandButton type="button"
|
||||
onclick="PF('opError').show()"
|
||||
/>
|
||||
<p:confirmDialog
|
||||
message="Session may have expired."
|
||||
header="Error"
|
||||
|
|
|
@ -2,11 +2,18 @@
|
|||
color: red;
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
.editIngGroupRow {
|
||||
background-color: aqua;
|
||||
background-color: aqua;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.displayIngGroupRow {
|
||||
background-color: aqua;
|
||||
font-weight: bold;
|
||||
background-color: aqua;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
textarea {
|
||||
font-family: 'latoregular', 'Trebuchet MS,Arial,Helvetica,sans-serif';
|
||||
font-size: 1em
|
||||
}
|
|
@ -359,9 +359,9 @@
|
|||
>
|
||||
<p:panel header="Instructions">
|
||||
<div id="insection">
|
||||
<p:textEditor
|
||||
<h:inputTextarea
|
||||
id="ctlInstructions"
|
||||
height="320"
|
||||
rows="30" cols="120"
|
||||
escape="false"
|
||||
value="#{recipeDetailBean.recipe.instructions}"
|
||||
/>
|
||||
|
@ -370,8 +370,9 @@
|
|||
</p:tab>
|
||||
<p:tab id="notesTab" title="Notes">
|
||||
<p:panel header="Notes">
|
||||
<p:textEditor id="ctlNotes"
|
||||
height="320" escape="false"
|
||||
<h:inputTextarea id="ctlNotes"
|
||||
rows="30" cols="120"
|
||||
escape="false"
|
||||
value="#{recipeDetailBean.recipe.modifications}"
|
||||
/>
|
||||
</p:panel>
|
||||
|
@ -386,6 +387,11 @@
|
|||
ajax="false" immediate="true"
|
||||
action="recipeDetails.jsf"
|
||||
/>
|
||||
<p:commandButton id="doHome" value="Home"
|
||||
icon="ui-icon-home"
|
||||
ajax="false" immediate="true"
|
||||
action="home"
|
||||
/>
|
||||
</h:form>
|
||||
</p:panel>
|
||||
<p:dialog id="addGroupDlg" widgetVar="addGroupDlg">
|
||||
|
|
|
@ -7,24 +7,23 @@
|
|||
>
|
||||
<ui:define name="title">Gourmet Recipe Manager</ui:define>
|
||||
<ui:define name="content">
|
||||
<h:messages/>
|
||||
<h:messages />
|
||||
<h:form id="form1">
|
||||
<div>
|
||||
<span class="ui-input-icon-left"> <i
|
||||
class="pi pi-search"
|
||||
/> <p:inputText id="searchFor" size="45"
|
||||
placeholder="Recipe title, (todo cuisine, etc.)"
|
||||
value="#{adminMainBean.searchText}"
|
||||
>
|
||||
<f:ajax event="change" execute="@this"
|
||||
render="form2:table1"
|
||||
listener="#{adminMainBean.ajaxUpdateList}"
|
||||
/>
|
||||
</p:inputText>
|
||||
</span>
|
||||
<p:inputText id="searchFor" size="45"
|
||||
placeholder="Recipe title/cuisine/category, etc.)"
|
||||
value="#{adminMainBean.searchText}"
|
||||
>
|
||||
<f:ajax event="change" execute="@this"
|
||||
render="form2:table1"
|
||||
listener="#{adminMainBean.ajaxUpdateList}"
|
||||
/>
|
||||
</p:inputText>
|
||||
<p:defaultCommand target="find" />
|
||||
<p:commandButton id="find" value="Find"
|
||||
icon="ui-icon-search" defaultCommand="true"
|
||||
icon="ui-icon-search"
|
||||
action="#{adminMainBean.doFind}"
|
||||
update=":form2:table1"
|
||||
/>
|
||||
<p:outputLabel for="@next" value="Search for " />
|
||||
<p:selectOneMenu id="ctlSearchType"
|
||||
|
@ -34,17 +33,16 @@
|
|||
<f:selectItems
|
||||
value="#{userSession.searchTypeList}"
|
||||
/>
|
||||
<p:ajax/>
|
||||
<p:ajax />
|
||||
</p:selectOneMenu>
|
||||
<p:commandButton id="ctlClear" value="Clear"
|
||||
immediate="true" icon="ui-icon-close"
|
||||
update="form1:searchFor form2:table1"
|
||||
icon="ui-icon-close"
|
||||
update="@form:searchFor :form2:table1"
|
||||
action="#{adminMainBean.ajaxClearList}"
|
||||
/>
|
||||
<p:commandButton value="New Recipe"
|
||||
action="#{adminMainBean.doNewRecipe}"
|
||||
/>
|
||||
<p:defaultCommand target="find" />
|
||||
</div>
|
||||
</h:form>
|
||||
<h:form id="form2">
|
||||
|
|
Loading…
Reference in New Issue
Block a user