-
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
Gabe Rogan
committed
Feb 6, 2017
1 parent
5fa1614
commit dc7cc8e
Showing
10 changed files
with
295 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
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,43 @@ | ||
app.controller('NutrientsCtrl', ['$scope', 'Nutrients', 'Nutrient', function ($scope, Nutrients, Nutrient) { | ||
$scope.page.title = 'Nutrients'; | ||
$scope.page.id = 'nutrients'; | ||
|
||
// Initialize CRUD modes | ||
$scope.editMode = false; | ||
$scope.createMode = false; | ||
|
||
// Initialize CRUD form | ||
$scope.nutrientCRUD = {}; | ||
|
||
// GET nutrients | ||
Nutrients.get({}, function (data) { | ||
$scope.nutrients = data.data; | ||
}); | ||
|
||
// CRUD: edit food | ||
$scope.edit = function (nutrientToEdit) { | ||
$scope.editMode = true; | ||
$scope.nutrientCRUD = nutrientToEdit; | ||
$scope.nutrientCRUD.action = "update"; | ||
}; | ||
|
||
// CRUD: create food | ||
$scope.create = function () { | ||
$scope.createMode = true; | ||
$scope.nutrientCRUD = {}; | ||
$scope.nutrientCRUD.action = "create"; | ||
}; | ||
|
||
// CRUD: cancel | ||
$scope.cancel = function () { | ||
$scope.editMode = false; | ||
$scope.createMode = false; | ||
}; | ||
|
||
// CRUD: POST | ||
$scope.submit = function () { | ||
if ($scope.editMode) {Nutrient.update($scope.nutrientCRUD);} | ||
else if ($scope.createMode) {Nutrient.save($scope.nutrientCRUD);} | ||
$scope.cancel(); // hide modal | ||
}; | ||
}]); |
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,47 @@ | ||
.floatBlock | ||
align-items center | ||
box-shadow 1px 2px 3px 0px rgba(0,0,0,0.2) | ||
cursor pointer | ||
display flex | ||
transition: all .1s | ||
&:hover | ||
transform scale(.95) | ||
|
||
h1.nutrientsTitle | ||
text-align center | ||
|
||
.nutrientsDiv | ||
display flex | ||
padding 2em 3em | ||
flex-wrap wrap | ||
justify-content space-between | ||
&.n2 | ||
margin -.5em -.5em 0 -.5em | ||
|
||
|
||
.addNutrientBtn | ||
background blue | ||
@extend .floatBlock | ||
width 100% | ||
color white | ||
.plus | ||
background alpha(black, .27) | ||
padding 8px | ||
font-size 40px | ||
.text | ||
padding-left 1em | ||
font-size 25px | ||
|
||
|
||
.nutrientBlock | ||
@extend .floatBlock | ||
align-items center | ||
background lightgray | ||
flex-basis 350px | ||
flex-grow 1 | ||
font-size 20px | ||
justify-content space-between | ||
margin .5em | ||
padding .7em | ||
.delete | ||
color red |
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,37 @@ | ||
<h1 class="nutrientsTitle">Nutrient Manager</h1> | ||
|
||
<!-- Create a nutrient button --> | ||
<div class="nutrientsDiv"> | ||
<div class="addNutrientBtn" ng-click="create()"> | ||
<i class="material-icons plus">add</i> | ||
<div class="text">Create a nutrient</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Nutrients list --> | ||
<div class="nutrientsDiv n2"> | ||
<div class="nutrientBlock" ng-repeat="nutrient in nutrients" ng-click="edit(nutrient)"> | ||
<div class="text">{{nutrient.name}}</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Modal --> | ||
<div ng-show="editMode || createMode" class="foodModal"> | ||
<div class="CRUD"> | ||
<h4>{{editMode && "Edit nutrient" || "Create a nutrient"}}</h4> | ||
|
||
<form ng-submit="submit()"> | ||
|
||
<div class="input-field"> | ||
<input type="text" placeholder="Name" ng-model="nutrientCRUD.name" required> | ||
</div> | ||
|
||
<button type="submit" class="btn green" ng-show="createMode">Create</button> | ||
<button type="submit" class="btn blue" ng-show="editMode">Update</button> | ||
<button type="button" class="btn orange" ng-click="cancel()">Cancel</button> | ||
|
||
</form> | ||
|
||
</div> | ||
</div> | ||
<!-- End of Modal --> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"status": "ok", | ||
"code": "200", | ||
"data": [ | ||
{ | ||
"id": "1", | ||
"name": "fat" | ||
}, | ||
{ | ||
"id": "2", | ||
"name": "carbs" | ||
}, | ||
{ | ||
"id": "3", | ||
"name": "saturated fat" | ||
}, | ||
{ | ||
"id": "4", | ||
"name": "protein" | ||
} | ||
] | ||
} |
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