-
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.
Merge branch 'develop' of https://github.uconn.edu/dmd-web-and-mobile…
…/foodbank into develop
- Loading branch information
Showing
24 changed files
with
7,267 additions
and
365 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,36 @@ | ||
var app = angular.module('app', ['ngRoute']); | ||
var app = angular.module('app', ['ngRoute', 'ngResource']); | ||
|
||
// Root controllers in /root/ folder | ||
// Page controllers in /pages/[your-page] folder | ||
|
||
// Factories | ||
|
||
// TODO: 'Foods' factory TEMPORARY | ||
app.factory('Foods', function($resource) { | ||
return $resource('assets/json/foods.json'); | ||
}); | ||
|
||
// Just does a PUT request when u call Food.update | ||
app.factory('Food', function ($resource) { | ||
// {food: '@id'} means replace :food with $scope.foodCRUD.id | ||
var data = $resource('http://foodbank.develop.digitalmediauconn.org/api/food/:food', {food: '@id'}, { | ||
update:{ method:'PUT' } | ||
}); | ||
return data; | ||
}); | ||
|
||
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; | ||
}); |
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 |
---|---|---|
@@ -1,7 +1,118 @@ | ||
|
||
function GetCategories() { | ||
return [ | ||
{ | ||
name: 'fruit', | ||
rules: [ | ||
{ nutrient: 'sugar', | ||
rule_id: '1', | ||
ranks: [ { name: 'green', operation: 'lt', value: 5 }, | ||
{ name: 'yellow', operation: 'gt', value: 2 } ] }, | ||
{ nutrient: 'sodium', | ||
rule_id: '2', | ||
ranks: [ { name: 'green', operation: 'lt', value: 5 }, | ||
{ name: 'yellow', operation: 'gtoe', value: 2 } ] }, | ||
{ nutrient: 'satfat', | ||
rule_id: '3', | ||
ranks: [ { name: 'green', operation: 'lt', value: 5 }, | ||
{ name: 'yellow', operation: 'gt', value: 2 } ] } ] | ||
|
||
}, | ||
{ | ||
name: 'veggie', | ||
rules: [ | ||
{ nutrient: 'sugar', | ||
rule_id: '4', | ||
ranks: [ { name: 'green', operation: 'lt', value: 5 }, | ||
{ name: 'yellow', operation: 'gt', value: 2 } ] }, | ||
{ nutrient: 'sodium', | ||
rule_id: '5', | ||
ranks: [ { name: 'green', operation: 'lt', value: 5 }, | ||
{ name: 'yellow', operation: 'gt', value: 2 } ] }, | ||
{ nutrient: 'satfat', | ||
rule_id: '6', | ||
ranks: [ { name: 'green', operation: 'lt', value: 5 }, | ||
{ name: 'yellow', operation: 'gt', value: 2 } ] } ] | ||
|
||
} | ||
]; | ||
} | ||
|
||
function GetRanks() { | ||
return ['green', 'yellow']; | ||
} | ||
|
||
function GetNutrients() { | ||
return ['sodium', 'sugar', 'satfat']; | ||
} | ||
|
||
function GetOperations() { | ||
return [{name: 'lt', symbol: 'Less Than'}, | ||
{name: 'lte', symbol: 'Less Than or Equal'}, | ||
{name: 'gt', symbol: 'Greater Than'}, | ||
{name: 'gte', symbol: 'Greater Than or Equal'}, | ||
{name: 'e', symbol: 'Equal To'}]; | ||
} | ||
|
||
function SaveData(categories) { | ||
console.log('save'); | ||
} | ||
|
||
app.controller('CategoryCtrl', ['$scope', function ($scope) { | ||
$scope.page.title = 'Categories'; | ||
$scope.page.id = 'cat'; | ||
$scope.page.yourVar = "globalStuff"; | ||
|
||
$scope.var2 = "localStuff"; | ||
|
||
$scope.categories = GetCategories(); | ||
$scope.ranks = GetRanks(); | ||
$scope.nutrients = GetNutrients(); | ||
$scope.operations = GetOperations(); | ||
|
||
$scope.getCategoryIndexFromName = function(categoryName) { | ||
for(var i = 0; i < $scope.categories.length; i++) { | ||
if($scope.categories[i].name == categoryName) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
}; | ||
|
||
$scope.addRule = function(categoryName) { | ||
var categoryIndex = $scope.getCategoryIndexFromName(categoryName); | ||
if(categoryIndex != -1) { | ||
$scope.categories[categoryIndex].rules.push({ nutrient: 'sugar', | ||
rule_id: '0', | ||
ranks: [ { name: 'green', operation: 'lt', value: 5 }, | ||
{ name: 'yellow', operation: 'gt', value: 2 } ] }); | ||
} | ||
|
||
}; | ||
|
||
$scope.removeRule = function(category, rule) { | ||
for(var i = 0; i < category.rules.length; i++) { | ||
if(category.rules[i] == rule) { | ||
category.rules.splice(i, 1); | ||
} | ||
} | ||
}; | ||
|
||
$scope.addCategory = function() { | ||
$scope.categories.push({name: 'New Category', rules: []}) | ||
}; | ||
|
||
$scope.renameCategory = function(category, name) { | ||
console.log(name); | ||
}; | ||
|
||
$scope.removeCategory = function(category) { | ||
for(var i = 0; i < $scope.categories.length; i++) { | ||
if($scope.categories[i] == category) { | ||
$scope.categories.splice(i, 1); | ||
} | ||
} | ||
}; | ||
|
||
$scope.saveData = function() { | ||
SaveData($scope.categories); | ||
}; | ||
}]); |
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,13 @@ | ||
.collapsible-body { | ||
padding: 1em; | ||
box-sizing:border-box; | ||
} | ||
|
||
.card-title, | ||
.collapsible-header { | ||
text-transform:capitalize; | ||
} | ||
|
||
select { | ||
display:block!important; | ||
} |
Oops, something went wrong.