misc mainpage and detail edit cleanup

This commit is contained in:
Tim Holloway 2022-01-10 19:43:10 -05:00
parent ce7576e459
commit d4d3179017
6 changed files with 81 additions and 57 deletions

View File

@ -92,6 +92,7 @@ public class AdminMainBean implements Serializable {
*/ */
public void setSearchText(String searchText) { public void setSearchText(String searchText) {
this.searchText = searchText; this.searchText = searchText;
userSession.setLastSearch(searchText);
} }
/**/ /**/

View File

@ -159,6 +159,7 @@ public class RecipeDetailBean implements Serializable {
/** /**
* @return the category as a comma-separated list. * @return the category as a comma-separated list.
* @see #stringifyCategories(Recipe)
*/ */
public String getCategory() { public String getCategory() {
return category; return category;
@ -241,6 +242,8 @@ public class RecipeDetailBean implements Serializable {
getIngredients().setWrappedData( getIngredients().setWrappedData(
buildIngredientFacade(recipe.getIngredientHash())); buildIngredientFacade(recipe.getIngredientHash()));
stringifyCategories(recipe);
log.info("Set recipe: " + this.recipe); log.info("Set recipe: " + this.recipe);
} }
@ -255,7 +258,19 @@ public class RecipeDetailBean implements Serializable {
if (recipe == null) { if (recipe == null) {
return 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(); Set<Category> cList = recipe.getCategories();
StringBuffer sb = new StringBuffer(35); StringBuffer sb = new StringBuffer(35);
boolean first = true; boolean first = true;
@ -268,7 +283,6 @@ public class RecipeDetailBean implements Serializable {
sb.append(cat.getCategory()); sb.append(cat.getCategory());
} }
this.category = sb.toString(); this.category = sb.toString();
return recipe;
} }
/** /**
@ -344,7 +358,8 @@ public class RecipeDetailBean implements Serializable {
if (instructions == null) { if (instructions == null) {
return ""; return "";
} }
String s = instructions.replace("\n\n", "<p/>"); String s = instructions.replace("\r\n", "<p/>")
.replace("\n\n", "<p/>");
s = s.replace("\n", "<br/>"); s = s.replace("\n", "<br/>");
return s; return s;
} }
@ -464,11 +479,11 @@ public class RecipeDetailBean implements Serializable {
} }
private void auditRows(List<IngredientUI> rows) { private void auditRows(List<IngredientUI> rows) {
log.info("=== AUDIT ROWS ==="); // log.info("=== AUDIT ROWS ===");
for ( IngredientUI row : rows ) { // for ( IngredientUI row : rows ) {
log.info((row.isSelected() ? "[X]" : "[ ]" ) +" ROW="+row); // log.info((row.isSelected() ? "[X]" : "[ ]" ) +" ROW="+row);
} // }
log.info("=== DONE ==="); // log.info("=== DONE ===");
} }
/** /**
@ -527,8 +542,8 @@ public class RecipeDetailBean implements Serializable {
* Invoked when the "E"(dit" button for Ingkey shopping * Invoked when the "E"(dit" button for Ingkey shopping
* category has been clicked. * category has been clicked.
* *
* @param item The item whose ingredient key will * @param item The item whose ingredient key will have its
* have its shopping category edited. Resets the dialog * shopping category edited. Resets the dialog
* backing bean internal state. * backing bean internal state.
*/ */
public void ajaxEditShopcat(IngredientUI item) { public void ajaxEditShopcat(IngredientUI item) {
@ -537,8 +552,8 @@ public class RecipeDetailBean implements Serializable {
} }
/** /**
* On "OK" for edit shopcat where shopcat has changed, * On "OK" for edit shopcat where shopcat has changed, update
* update the shopcat Entity and the ingredients. * the shopcat Entity and the ingredients.
*/ */
public void doUpdateShopcat() { public void doUpdateShopcat() {
@ -555,17 +570,17 @@ public class RecipeDetailBean implements Serializable {
sc = new Shopcat(); sc = new Shopcat();
sc.setIngkey(key); sc.setIngkey(key);
} else { } else {
if ( StringUtils.equals(sc.getShopcategory(), catname) ) { if (StringUtils.equals(sc.getShopcategory(),
catname)) {
return; // No change return; // No change
} }
} }
sc.setShopcategory(catname); sc.setShopcategory(catname);
/* /*
* Because the database does not have a UNIQUE * Because the database does not have a UNIQUE constraint
* constraint on ingkeys, we must delete old * on ingkeys, we must delete old shopcat(s) for this key
* shopcat(s) for this key before adding (updating) * before adding (updating) the new shopcat.
* the new shopcat.
*/ */
this.recipeService.deleteShopcatByIngKey(key); this.recipeService.deleteShopcatByIngKey(key);
if (!StringUtils.isBlank(catname)) { if (!StringUtils.isBlank(catname)) {
@ -798,7 +813,7 @@ public class RecipeDetailBean implements Serializable {
cat.setId(ocat.getId()); cat.setId(ocat.getId());
} }
} }
recipe.setCategories(new HashSet(newList)); recipe.setCategories(new HashSet<Category>(newList));
} }
private Category searchCategory(Set<Category> oldList, 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() { public List<String> getSuggestCategory() {
if (suggestCategory == null) { if (suggestCategory == null) {

View File

@ -54,9 +54,6 @@
</h:form> </h:form>
<!-- --> <!-- -->
<h:form id="frmOpErr"> <h:form id="frmOpErr">
<p:commandButton type="button"
onclick="PF('opError').show()"
/>
<p:confirmDialog <p:confirmDialog
message="Session may have expired." message="Session may have expired."
header="Error" header="Error"

View File

@ -2,11 +2,18 @@
color: red; color: red;
background-color: blue; background-color: blue;
} }
.editIngGroupRow { .editIngGroupRow {
background-color: aqua; background-color: aqua;
font-weight: bold; font-weight: bold;
} }
.displayIngGroupRow { .displayIngGroupRow {
background-color: aqua; background-color: aqua;
font-weight: bold; font-weight: bold;
} }
textarea {
font-family: 'latoregular', 'Trebuchet MS,Arial,Helvetica,sans-serif';
font-size: 1em
}

View File

@ -359,9 +359,9 @@
> >
<p:panel header="Instructions"> <p:panel header="Instructions">
<div id="insection"> <div id="insection">
<p:textEditor <h:inputTextarea
id="ctlInstructions" id="ctlInstructions"
height="320" rows="30" cols="120"
escape="false" escape="false"
value="#{recipeDetailBean.recipe.instructions}" value="#{recipeDetailBean.recipe.instructions}"
/> />
@ -370,8 +370,9 @@
</p:tab> </p:tab>
<p:tab id="notesTab" title="Notes"> <p:tab id="notesTab" title="Notes">
<p:panel header="Notes"> <p:panel header="Notes">
<p:textEditor id="ctlNotes" <h:inputTextarea id="ctlNotes"
height="320" escape="false" rows="30" cols="120"
escape="false"
value="#{recipeDetailBean.recipe.modifications}" value="#{recipeDetailBean.recipe.modifications}"
/> />
</p:panel> </p:panel>
@ -386,6 +387,11 @@
ajax="false" immediate="true" ajax="false" immediate="true"
action="recipeDetails.jsf" action="recipeDetails.jsf"
/> />
<p:commandButton id="doHome" value="Home"
icon="ui-icon-home"
ajax="false" immediate="true"
action="home"
/>
</h:form> </h:form>
</p:panel> </p:panel>
<p:dialog id="addGroupDlg" widgetVar="addGroupDlg"> <p:dialog id="addGroupDlg" widgetVar="addGroupDlg">

View File

@ -10,10 +10,8 @@
<h:messages /> <h:messages />
<h:form id="form1"> <h:form id="form1">
<div> <div>
<span class="ui-input-icon-left"> <i <p:inputText id="searchFor" size="45"
class="pi pi-search" placeholder="Recipe title/cuisine/category, etc.)"
/> <p:inputText id="searchFor" size="45"
placeholder="Recipe title, (todo cuisine, etc.)"
value="#{adminMainBean.searchText}" value="#{adminMainBean.searchText}"
> >
<f:ajax event="change" execute="@this" <f:ajax event="change" execute="@this"
@ -21,10 +19,11 @@
listener="#{adminMainBean.ajaxUpdateList}" listener="#{adminMainBean.ajaxUpdateList}"
/> />
</p:inputText> </p:inputText>
</span> <p:defaultCommand target="find" />
<p:commandButton id="find" value="Find" <p:commandButton id="find" value="Find"
icon="ui-icon-search" defaultCommand="true" icon="ui-icon-search"
action="#{adminMainBean.doFind}" action="#{adminMainBean.doFind}"
update=":form2:table1"
/> />
<p:outputLabel for="@next" value="Search for " /> <p:outputLabel for="@next" value="Search for " />
<p:selectOneMenu id="ctlSearchType" <p:selectOneMenu id="ctlSearchType"
@ -37,14 +36,13 @@
<p:ajax /> <p:ajax />
</p:selectOneMenu> </p:selectOneMenu>
<p:commandButton id="ctlClear" value="Clear" <p:commandButton id="ctlClear" value="Clear"
immediate="true" icon="ui-icon-close" icon="ui-icon-close"
update="form1:searchFor form2:table1" update="@form:searchFor :form2:table1"
action="#{adminMainBean.ajaxClearList}" action="#{adminMainBean.ajaxClearList}"
/> />
<p:commandButton value="New Recipe" <p:commandButton value="New Recipe"
action="#{adminMainBean.doNewRecipe}" action="#{adminMainBean.doNewRecipe}"
/> />
<p:defaultCommand target="find" />
</div> </div>
</h:form> </h:form>
<h:form id="form2"> <h:form id="form2">