Fixed confirm dialog for delete, search ingredient return only 1 copy of recipe

version2
Tim Holloway 2 years ago
parent 9e7e68f657
commit 23d0c5f2ca
  1. 3
      src/main/java/com/mousetech/gourmetj/RecipeDetailBean.java
  2. 3
      src/main/java/com/mousetech/gourmetj/persistence/dao/RecipeRepository.java
  3. 2
      src/main/java/com/mousetech/gourmetj/persistence/service/RecipeService.java
  4. 2
      src/main/resources/META-INF/resources/error/viewExpired.xhtml
  5. 36
      src/main/resources/META-INF/resources/recipeDetails.xhtml

@ -10,7 +10,6 @@ import java.util.Set;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.faces.event.AjaxBehaviorEvent; import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.DataModel; import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
import javax.faces.view.ViewScoped; import javax.faces.view.ViewScoped;
@ -702,7 +701,7 @@ public class RecipeDetailBean implements Serializable {
public String doDelete() { public String doDelete() {
recipeService.delete(this.recipe); recipeService.delete(this.recipe);
this.userSession.setLastEdit(null); // Don't point to me! this.userSession.setLastEdit(null); // Don't point to me!
return "main"; return "/main.jsf";
} }
/** /**

@ -36,6 +36,7 @@ public interface RecipeRepository
List<Recipe> findByCuisineContains(String searchText); List<Recipe> findByCuisineContains(String searchText);
List<Recipe> findByIngredientHash_ItemContains(String searchText); List<Recipe> findDistinctByIngredientHash_ItemContains(
String searchText);
} }

@ -128,6 +128,6 @@ public class RecipeService implements Serializable {
} }
public List<Recipe> findByIngredientLike(String searchText) { public List<Recipe> findByIngredientLike(String searchText) {
return recipeRepository.findByIngredientHash_ItemContains(searchText); return recipeRepository.findDistinctByIngredientHash_ItemContains(searchText);
} }
} }

@ -11,7 +11,7 @@
<h2>View Expired.</h2> <h2>View Expired.</h2>
<h:form> <h:form>
The user session has timed out. Return to main page. The user session has timed out. Return to main page.
<h:commandButton value="OK" action="home"></h:commandButton> <h:commandButton value="OK" action="/main.jsf"></h:commandButton>
</h:form> </h:form>
</h:body> </h:body>
</html> </html>

@ -44,8 +44,8 @@
<p:panelGrid id="pnlDetails" <p:panelGrid id="pnlDetails"
columns="2" columns="2"
> >
<p:commandButton <p:commandButton value="Back"
value="Back" ajax="false" ajax="false"
icon="ui-icon-arrowthick-1-w" icon="ui-icon-arrowthick-1-w"
action="main.jsf" action="main.jsf"
immediate="true" immediate="true"
@ -127,17 +127,10 @@
action="#{recipeDetailBean.editNotes}" action="#{recipeDetailBean.editNotes}"
/> />
</p:panelGrid> </p:panelGrid>
<p:button id="ctlDelete" <p:commandButton id="ctlDelete"
value="Delete Recipe" value="Delete Recipe"
action="#{recipeDetailBean.doDelete}" onclick="PF('okDeleteDlg').show()"
immediate="true" />
>
<f:facet name="confirmation">
<h:outputText
value="Delete this recipe. Are you sure?"
/>
</f:facet>
</p:button>
</p:column> </p:column>
<!-- ====== Ingredients ============================ --> <!-- ====== Ingredients ============================ -->
<p:column id="ingredientsc" <p:column id="ingredientsc"
@ -199,5 +192,24 @@
</p:panelGrid> </p:panelGrid>
</p:panelGrid> </p:panelGrid>
</h:form> </h:form>
<!-- -->
<h:form id="frmDelete">
<p:confirmDialog closable="false" id="okDeleteDlg"
header="Confirm Deletion"
message="OK to delete this recipe?"
severity="alert"
widgetVar="okDeleteDlg"
style="z-index: 25000"
>
<p:commandButton id="dlgOK" value="OK"
oncomplete="PF('okDeleteDlg').hide()"
action="#{recipeDetailBean.doDelete}"
immediate="true"
/>
<p:commandButton id="dlgCancel" value="Cancel"
onclick="PF('okDeleteDlg').hide()"
/>
</p:confirmDialog>
</h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
Loading…
Cancel
Save