Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
i wish my parents had never met each other
  • Loading branch information
Joel Salisbury committed Sep 21, 2017
1 parent bcc0ad3 commit f3c7478
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 51 deletions.
4 changes: 2 additions & 2 deletions app/app.js
Expand Up @@ -17,11 +17,11 @@ app.factory('FoodDetail', function($resource) {
});

app.factory('Categories', function($resource) {
return $resource('api/index.php/category/all');
return $resource('http://foodbank.develop.digitalmediauconn.org/api/index.php/category/all');
});

app.factory('Nutrients', function($resource) {
return $resource('api/index.php/nutrient/all');
return $resource('http://foodbank.develop.digitalmediauconn.org/api/index.php/nutrient/all');
});

// Just does a PUT request when u call Food.update
Expand Down
2 changes: 1 addition & 1 deletion app/app.route.js
Expand Up @@ -2,7 +2,7 @@ app.config( function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'app/pages/categories/view.html',
controller: 'FoodCtrl'
controller: 'CategoryCtrl'
})

.when('/login', {
Expand Down
1 change: 1 addition & 0 deletions app/root/_nav.kit
Expand Up @@ -6,6 +6,7 @@
</div>


<!-- Links -->


<!-- Sign in/up Buttons -->
Expand Down
95 changes: 47 additions & 48 deletions assets/js/bundle.js
Expand Up @@ -17,11 +17,11 @@ app.factory('FoodDetail', function($resource) {
});

app.factory('Categories', function($resource) {
return $resource('api/index.php/category/all');
return $resource('http://foodbank.develop.digitalmediauconn.org/api/index.php/category/all');
});

app.factory('Nutrients', function($resource) {
return $resource('api/index.php/nutrient/all');
return $resource('http://foodbank.develop.digitalmediauconn.org/api/index.php/nutrient/all');
});

// Just does a PUT request when u call Food.update
Expand All @@ -44,7 +44,7 @@ app.config( function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'app/pages/categories/view.html',
controller: 'FoodCtrl'
controller: 'CategoryCtrl'
})

.when('/login', {
Expand Down Expand Up @@ -362,50 +362,6 @@ app.controller('FoodCtrl', ['$scope', '$http', 'Foods', 'FoodDetail', 'Categorie

}]);

app.controller('NutrientsCtrl', ['$scope', 'Nutrients', function ($scope, Nutrients) {
$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
};
}]);

app.controller('LoginCtrl', ['$scope', 'loginService', function ($scope, loginService) {
$scope.page.title = 'Login';
$scope.page.id = 'login';
Expand Down Expand Up @@ -457,4 +413,47 @@ app.factory('loginService', ['$http', function($http) {
});
}
};
}]);
}]);
app.controller('NutrientsCtrl', ['$scope', 'Nutrients', function ($scope, Nutrients) {
$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
};
}]);
1 change: 1 addition & 0 deletions index.html
Expand Up @@ -43,6 +43,7 @@
</div>


<!-- Links -->


<!-- Sign in/up Buttons -->
Expand Down

0 comments on commit f3c7478

Please sign in to comment.