-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b47d7ca
commit 83909e7
Showing
8 changed files
with
425 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/guru/springframework/services/UnitOfMeasureService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package guru.springframework.services; | ||
|
||
import guru.springframework.commands.UnitOfMeasureCommand; | ||
|
||
import java.util.Set; | ||
|
||
public interface UnitOfMeasureService { | ||
Set<UnitOfMeasureCommand> listAllUoms(); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/guru/springframework/services/UnitOfMeasureServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package guru.springframework.services; | ||
|
||
import guru.springframework.commands.UnitOfMeasureCommand; | ||
import guru.springframework.converters.UnitOfMeasureToUnitOfMeasureCommand; | ||
import guru.springframework.repositories.UnitOfMeasureRepository; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.StreamSupport; | ||
|
||
@Slf4j | ||
@AllArgsConstructor | ||
@Service | ||
public class UnitOfMeasureServiceImpl implements UnitOfMeasureService { | ||
private final UnitOfMeasureRepository unitOfMeasureRepository; | ||
private final UnitOfMeasureToUnitOfMeasureCommand unitOfMeasureToUnitOfMeasureCommand; | ||
|
||
@Override | ||
public Set<UnitOfMeasureCommand> listAllUoms() { | ||
return StreamSupport.stream(unitOfMeasureRepository.findAll().spliterator(),false) | ||
.map(unitOfMeasureToUnitOfMeasureCommand::convert) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/resources/templates/recipe/ingredient/ingredientform.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> | ||
<head> | ||
<meta charset="UTF-8"/> | ||
<title>Edit Ingredient</title> | ||
<!-- Latest compiled and minified CSS --> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" | ||
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" | ||
th:href="@{/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css}"> | ||
|
||
<script src="/webjars/jquery/1.11.1/jquery.min.js"></script> | ||
|
||
<!-- Latest compiled and minified JavaScript --> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" | ||
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" | ||
crossorigin="anonymous" th:src="@{/webjars/bootstrap/3.3.7-1/js/bootstrap.min.js}"></script> | ||
</head> | ||
<body> | ||
|
||
<div class="container-fluid" style="margin-top: 20px"> | ||
<div class="row"> | ||
<div class="col-md-6 col-md-offset-3"> | ||
<!--/*@thymesVar id="ingredient" type="guru.springframework.commands.IngredientCommand"*/--> | ||
<form th:object="${ingredient}" th:action="@{'/recipe/' + ${ingredient.getRecipeId()} + '/ingredient'} " method="post"> | ||
<input type="hidden" th:field="*{id}"/> | ||
<div class="pannel-group"> | ||
<div class="panel panel-primary"> | ||
<div class="panel-heading"> | ||
<h1 class="panel-title">Edit Ingredient Information</h1> | ||
</div> | ||
<div class="panel-body"> | ||
|
||
|
||
<div class="row"> | ||
<div class="col-md-3 form-group"> | ||
<label>Description:</label> | ||
<input type="text" class="form-control" th:field="*{description}"/> | ||
</div> | ||
|
||
<div class="col-md-3 form-group"> | ||
<label>Amount:</label> | ||
<input type="number" class="form-control" th:field="*{amount}"/> | ||
</div> | ||
|
||
<div class="col-md-3 form-group"> | ||
<label>UOM:</label> | ||
<select class="form-control" name="uom.id"> | ||
<option th:each="uomEach : ${uomList}" | ||
th:value="${uomEach.id}" | ||
th:selected="${uomEach.id.equals(ingredient.uom.id)}" | ||
th:text="${uomEach.description}">Each</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.