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.faces.event.AjaxBehaviorEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.view.ViewScoped;
@ -702,7 +701,7 @@ public class RecipeDetailBean implements Serializable {
public String doDelete() {
recipeService.delete(this.recipe);
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> 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) {
return recipeRepository.findByIngredientHash_ItemContains(searchText);
return recipeRepository.findDistinctByIngredientHash_ItemContains(searchText);
}
}

@ -11,7 +11,7 @@
<h2>View Expired.</h2>
<h:form>
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:body>
</html>

@ -44,8 +44,8 @@
<p:panelGrid id="pnlDetails"
columns="2"
>
<p:commandButton
value="Back" ajax="false"
<p:commandButton value="Back"
ajax="false"
icon="ui-icon-arrowthick-1-w"
action="main.jsf"
immediate="true"
@ -127,17 +127,10 @@
action="#{recipeDetailBean.editNotes}"
/>
</p:panelGrid>
<p:button id="ctlDelete"
<p:commandButton id="ctlDelete"
value="Delete Recipe"
action="#{recipeDetailBean.doDelete}"
immediate="true"
>
<f:facet name="confirmation">
<h:outputText
value="Delete this recipe. Are you sure?"
/>
</f:facet>
</p:button>
onclick="PF('okDeleteDlg').show()"
/>
</p:column>
<!-- ====== Ingredients ============================ -->
<p:column id="ingredientsc"
@ -199,5 +192,24 @@
</p:panelGrid>
</p:panelGrid>
</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:composition>
Loading…
Cancel
Save