Skip to content

Commit

Permalink
Merge branch 'foodsUI' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
briankelleher committed Dec 7, 2016
2 parents f98f816 + ecfa6dc commit ca0ff2e
Show file tree
Hide file tree
Showing 11 changed files with 418 additions and 188 deletions.
Empty file removed app/pages/food/anotherCtrl.js
Empty file.
91 changes: 88 additions & 3 deletions app/pages/food/ctrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,92 @@
app.controller('FoodCtrl', ['$scope', function ($scope) {
app.controller('FoodCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.page.title = 'Food';
$scope.page.id = 'food';
$scope.page.yourVar = "globalStuff";

$scope.var2 = "localStuff";
// Initialize Filters
$scope.foods = [];
$scope.categories = [];
$scope.rankSelection = {
"green": true,
"yellow": true,
"red": true
};
$scope.categorySelection = { "all": true };
$scope.searchTerm = "";

// Initialize CRUD modes
$scope.editMode = false;
$scope.createMode = false;

// Initialize CRUD form
$scope.foodCRUD = {};

// GET foods
$http.get("assets/json/foods.json")
.then(function(response) {
$scope.foods = response.data.data;
});

// GET list of categories
$http.get("assets/json/categories.json")
.then(function(response) {
$scope.categories = response.data.data;

// Preset category filters
$scope.resetCategorySelection();
});

// Set category filters to false
$scope.resetCategorySelection = function () {
$scope.categories.forEach(function(c){
$scope.categorySelection[c.id] = false;
});
}

// Category filter function
$scope.categoryFilter = function (food) {
return ( $scope.categorySelection[food.category_id] | $scope.categorySelection["all"] );
}

// Rank filter function
$scope.rankFilter = function (food) {
return ( $scope.rankSelection[food.rank_id] );
}

// CRUD: edit food
$scope.edit = function (foodToEdit) {
$scope.editMode = true;
$scope.foodCRUD = foodToEdit;
$scope.foodCRUD.action = "update";
// console.log($scope.foodCRUD);
};

// CRUD: create food
$scope.create = function () {
$scope.createMode = true;
$scope.foodCRUD = {};
$scope.foodCRUD.rank_mode = "auto";
$scope.foodCRUD.action = "create";
// console.log($scope.foodCRUD);
};

// CRUD: cancel
$scope.cancel = function () {
$scope.editMode = false;
$scope.createMode = false;
};

// CRUD: POST
$scope.submit = function () {
$scope.cancel(); // hide modal

$http.post('request-url', $scope.foodCRUD)
.success(function (data) {
// console.log(data);
})
.error(function (data) {
// console.log(data);
});
};


}]);
94 changes: 50 additions & 44 deletions app/pages/food/style.styl
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
cursor: pointer
top: 6px
right: 0
&:hover
color: #888
transform: scale(.9)
transition: all .2s
// &:hover
// color: #888
// transform: scale(.9)
// transition: all .2s
.input-field label.active
transform: translateY(-120%)
.input-field.col label
left: 0

.barcode
margin: 0

.food-filter
display: flex
flex-flow: row wrap
flex-flow: row no-wrap
width: 100%
padding: 0 1em
.block
Expand All @@ -24,7 +27,6 @@
&:last-child
flex: 0 130px
nav
box-shadow: none
display: flex
align-items: center
justify-content: center
Expand All @@ -51,6 +53,7 @@
flex-wrap: wrap

.card-panel
background: lightergray
flex-grow: 1
display: flex
padding: 0
Expand All @@ -61,14 +64,21 @@
&:hover
transform: scale(.95)
.health
background-color: green
width: 3em
min-width: @width
min-height: @width
height: 100%
display: flex
align-items: center
justify-content: center
background-color: gray
&.rank-green
background-color: green
&.rank-yellow
background-color: yellow
&.rank-red
background-color: red

i
color: white
h5
Expand All @@ -88,48 +98,13 @@



.food-crud
font-size: 1.1em
padding: 1em
border: 1px solid lightgray
my-box-shadow()
background: white
[type="radio"]:not(:checked)+label, [type="radio"]:checked+label
padding-left: 1.7em
padding-right: 1em
.grade
margin-bottom: 2em
h4
margin: 5px 0 25px 0
p
font-size: 1.1em
font-weight: 500
color: #BBB
margin-bottom: 5px
a.btn
width: 48%
.orange
float: right

.nutrition
margin-bottom: 1.5em
td
padding: .5em 5px
td:first-child
font-weight: 500
width: 50%



.modal_ .editContent
display: none
.modal_.editMode .editContent
display: inline

.modal_
.foodModal
display: flex
align-items: center
justify-content: center
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
Expand All @@ -139,3 +114,34 @@
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */

.CRUD
font-size: 1.1em
padding: 1em
border: 1px solid lightgray
my-box-shadow()
background: white
[type="radio"]:not(:checked)+label, [type="radio"]:checked+label
padding-left: 1.7em
padding-right: 1em
.grade
margin-bottom: 2em
h4
margin: 5px 0 25px 0
p
font-size: 1.1em
font-weight: 500
color: #BBB
margin-bottom: 5px
a.btn
width: 48%
.orange
float: right

.nutrition
margin-bottom: 1.5em
td
padding: .5em 5px
td:first-child
font-weight: 500
width: 50%
Loading

0 comments on commit ca0ff2e

Please sign in to comment.