diff --git a/app/app.js b/app/app.js
index 8e3a637..b5998c6 100644
--- a/app/app.js
+++ b/app/app.js
@@ -4,6 +4,8 @@ var app = angular.module('app', ['ngRoute', 'ngResource']);
// Page controllers in /pages/[your-page] folder
// Factories
+
+// TODO: 'Foods' factory TEMPORARY
app.factory('Foods', function($resource) {
return $resource('assets/json/foods.json');
});
@@ -20,3 +22,15 @@ app.factory('Food', function ($resource) {
app.factory('Categories', function($resource) {
return $resource('assets/json/categories.json');
});
+
+// TODO: 'Nutrients' factory TEMPORARY
+app.factory('Nutrients', function($resource) {
+ return $resource('assets/json/nutrients.json');
+});
+
+app.factory('Nutrient', function ($resource) {
+ var data = $resource('http://foodbank.develop.digitalmediauconn.org/api/nutrients/:nutrient', {nutrient: '@id'}, {
+ update:{ method:'PUT' }
+ });
+ return data;
+});
diff --git a/app/app.route.js b/app/app.route.js
index a71574b..498f92f 100644
--- a/app/app.route.js
+++ b/app/app.route.js
@@ -20,6 +20,11 @@ app.config( function ($routeProvider, $locationProvider) {
controller: 'FoodCtrl'
})
+ .when('/nutrients', {
+ templateUrl: 'app/pages/nutrients/view.html',
+ controller: 'NutrientsCtrl'
+ })
+
// Sandbox Demo
.when('/rest', {
templateUrl: 'app/sandbox/rest.html',
diff --git a/app/pages/nutrients/ctrl.js b/app/pages/nutrients/ctrl.js
new file mode 100644
index 0000000..8c8b196
--- /dev/null
+++ b/app/pages/nutrients/ctrl.js
@@ -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
+ };
+}]);
diff --git a/app/pages/nutrients/style.styl b/app/pages/nutrients/style.styl
new file mode 100644
index 0000000..7809986
--- /dev/null
+++ b/app/pages/nutrients/style.styl
@@ -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
diff --git a/app/pages/nutrients/view.html b/app/pages/nutrients/view.html
new file mode 100644
index 0000000..439a3c7
--- /dev/null
+++ b/app/pages/nutrients/view.html
@@ -0,0 +1,37 @@
+
Nutrient Manager
+
+
+
+
+
add
+
Create a nutrient
+
+
+
+
+
+
+
+
+
+
{{editMode && "Edit nutrient" || "Create a nutrient"}}
+
+
+
+
+
+
diff --git a/app/root/_nav.kit b/app/root/_nav.kit
index cc94925..08b2a75 100644
--- a/app/root/_nav.kit
+++ b/app/root/_nav.kit
@@ -12,6 +12,7 @@
diff --git a/assets/css/main.css b/assets/css/main.css
index 82a1319..bd86a0d 100644
--- a/assets/css/main.css
+++ b/assets/css/main.css
@@ -244,6 +244,59 @@ ul.tabs .tab a:hover {
font-weight: 500;
width: 50%;
}
+.floatBlock,
+.addNutrientBtn,
+.nutrientBlock {
+ align-items: center;
+ box-shadow: 1px 2px 3px 0px rgba(0,0,0,0.2);
+ cursor: pointer;
+ display: flex;
+ transition: all 0.1s;
+}
+.floatBlock:hover,
+.addNutrientBtn:hover,
+.nutrientBlock:hover {
+ transform: scale(0.95);
+}
+h1.nutrientsTitle {
+ text-align: center;
+}
+.nutrientsDiv {
+ display: flex;
+ padding: 2em 3em;
+ flex-wrap: wrap;
+ justify-content: space-between;
+}
+.nutrientsDiv.n2 {
+ margin: -0.5em -0.5em 0 -0.5em;
+}
+.addNutrientBtn {
+ background: #4ba8f8;
+ width: 100%;
+ color: #fff;
+}
+.addNutrientBtn .plus {
+ background: rgba(0,0,0,0.27);
+ padding: 8px;
+ font-size: 40px;
+}
+.addNutrientBtn .text {
+ padding-left: 1em;
+ font-size: 25px;
+}
+.nutrientBlock {
+ align-items: center;
+ background: #f0f0f0;
+ flex-basis: 350px;
+ flex-grow: 1;
+ font-size: 20px;
+ justify-content: space-between;
+ margin: 0.5em;
+ padding: 0.7em;
+}
+.nutrientBlock .delete {
+ color: #fd7b7b;
+}
.spacer {
height: 80px;
}
diff --git a/assets/js/bundle.js b/assets/js/bundle.js
index 3f05148..c5d8a1f 100644
--- a/assets/js/bundle.js
+++ b/assets/js/bundle.js
@@ -4,6 +4,8 @@ var app = angular.module('app', ['ngRoute', 'ngResource']);
// Page controllers in /pages/[your-page] folder
// Factories
+
+// TODO: 'Foods' factory TEMPORARY
app.factory('Foods', function($resource) {
return $resource('assets/json/foods.json');
});
@@ -21,6 +23,18 @@ app.factory('Categories', function($resource) {
return $resource('assets/json/categories.json');
});
+// TODO: 'Nutrients' factory TEMPORARY
+app.factory('Nutrients', function($resource) {
+ return $resource('assets/json/nutrients.json');
+});
+
+app.factory('Nutrient', function ($resource) {
+ var data = $resource('http://foodbank.develop.digitalmediauconn.org/api/nutrients/:nutrient', {nutrient: '@id'}, {
+ update:{ method:'PUT' }
+ });
+ return data;
+});
+
app.config( function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
@@ -43,6 +57,11 @@ app.config( function ($routeProvider, $locationProvider) {
controller: 'FoodCtrl'
})
+ .when('/nutrients', {
+ templateUrl: 'app/pages/nutrients/view.html',
+ controller: 'NutrientsCtrl'
+ })
+
// Sandbox Demo
.when('/rest', {
templateUrl: 'app/sandbox/rest.html',
@@ -130,6 +149,15 @@ app.controller('404Ctrl', ['$scope', function ($scope) {
$scope.var2 = "localStuff";
}]);
+
+app.controller('CategoryCtrl', ['$scope', function ($scope) {
+ $scope.page.title = 'Categories';
+ $scope.page.id = 'cat';
+ $scope.page.yourVar = "globalStuff";
+
+ $scope.var2 = "localStuff";
+}]);
+
app.controller('FoodCtrl', ['$scope', '$http', 'Foods', 'Food', 'Categories', function ($scope, $http, Foods, Food, Categories) {
$scope.page.title = 'Food';
$scope.page.id = 'food';
@@ -225,15 +253,6 @@ app.controller('FoodCtrl', ['$scope', '$http', 'Foods', 'Food', 'Categories', fu
}]);
-app.controller('CategoryCtrl', ['$scope', function ($scope) {
- $scope.page.title = 'Categories';
- $scope.page.id = 'cat';
- $scope.page.yourVar = "globalStuff";
-
- $scope.var2 = "localStuff";
-}]);
-
-
app.controller('LoginCtrl', ['$scope', 'loginService', function ($scope, loginService) {
$scope.page.title = 'Login';
$scope.page.id = 'login';
@@ -285,4 +304,47 @@ app.factory('loginService', ['$http', function($http) {
});
}
};
-}]);
\ No newline at end of file
+}]);
+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
+ };
+}]);
diff --git a/assets/json/nutrients.json b/assets/json/nutrients.json
new file mode 100644
index 0000000..2d1c831
--- /dev/null
+++ b/assets/json/nutrients.json
@@ -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"
+ }
+ ]
+}
diff --git a/index.html b/index.html
index a5c9c52..646cb9c 100644
--- a/index.html
+++ b/index.html
@@ -47,6 +47,7 @@ F2E