Removed: Pyramid Debug Toolbar dependency removed.

Recipe: Recipe list and Add / Delete recipe created.
Breaking: Major updates to old databases needed as structure has changed significantly
Product table is not a inherited table similar to ledger table
table prefixes for entities removed
renamed a few tables
removed file types not used from the manifest
README.txt now contains the installation procedure on an Ubuntu 14.04 machine
Product.ShowForPurchase column removed
Product.Discountinued renamed to !Product.IsActive
This commit is contained in:
Amritanshu committed 2014-04-29 15:38:44 +05:30
1 parent 246f8465d7
commit 1448120941
48 files changed
+1094 -264

No files matched your search

+4
View File
@@ -130,6 +130,10 @@ overlord_directive.directive('keypress', [function () {
});
})(k);
}
element.on('$destroy', function() {
$interval.cancel(timeoutId);
});
};
}]);
+7
View File
@@ -21,6 +21,13 @@ overlord_service.factory('Account', ['$resource', function ($resource) {
});
}]);
overlord_service.factory('Recipe', ['$resource', function ($resource) {
return $resource('/api/Recipe/:id',
{id: '@RecipeID'}, {
query: {method: 'GET', params: {list: true}, isArray: true}
});
}]);
overlord_service.factory('Employee', ['$resource', function ($resource) {
return $resource('/api/Employee/:id',
{id: '@LedgerID'}, {
+4
View File
@@ -83,6 +83,10 @@ var overlord = angular.module('overlord', ['overlord.directive', 'overlord.filte
when('/Product', {templateUrl: '/partial/product-detail.html', controller: ProductCtrl, resolve: ProductCtrl.resolve}).
when('/Product/:id', {templateUrl: '/partial/product-detail.html', controller: ProductCtrl, resolve: ProductCtrl.resolve}).
when('/Recipes', {templateUrl: '/partial/recipe-list.html', controller: RecipeListCtrl, resolve: RecipeListCtrl.resolve, reloadOnSearch:false}).
when('/Recipe', {templateUrl: '/partial/recipe-detail.html', controller: RecipeCtrl, resolve: RecipeCtrl.resolve}).
when('/Recipe/:id', {templateUrl: '/partial/recipe-detail.html', controller: RecipeCtrl, resolve: RecipeCtrl.resolve}).
when('/ProductGroups', {templateUrl: '/partial/product-group-list.html', controller: ProductGroupListCtrl, resolve: ProductGroupListCtrl.resolve}).
when('/ProductGroup', {templateUrl: '/partial/product-group-detail.html', controller: ProductGroupCtrl, resolve: ProductGroupCtrl.resolve}).
when('/ProductGroup/:id', {templateUrl: '/partial/product-group-detail.html', controller: ProductGroupCtrl, resolve: ProductGroupCtrl.resolve}).
+6 -6
View File
@@ -45,7 +45,7 @@ var ProductListCtrl = ['$scope', '$location', '$routeParams', 'products', functi
if (value.indexOf("'") === 0 || value.indexOf('"') === 0) {
value = value.substring(1, value.length - 2);
}
if (key !== '' && value !== '' && _.any(['w', 'u', 'g'], function (item) {
if (key !== '' && value !== '' && _.any(['a', 'u', 'g'], function (item) {
return item === key;
})) {
matches.push({'key': key, 'value': value});
@@ -60,8 +60,8 @@ var ProductListCtrl = ['$scope', '$location', '$routeParams', 'products', functi
if (item.Name.toLowerCase().indexOf(match.value) === -1) {
return false;
}
} else if (match.key === 'w') {
if (item.Discontinued === $scope.isTrue(match.value)) {
} else if (match.key === 'a') {
if (item.IsActive === $scope.isTrue(match.value)) {
return false;
}
} else if (match.key === 'u') {
@@ -85,14 +85,14 @@ ProductListCtrl.resolve = {
}]
};
var ProductCtrl = ['$scope', '$location', '$modal', 'product', 'product_groups', function ($scope, $location, $modal, product, product_groups) {
var ProductCtrl = ['$scope', '$location', '$window', '$modal', 'product', 'product_groups', function ($scope, $location, $window, $modal, product, product_groups) {
$scope.product = product;
$scope.product_groups = product_groups;
$scope.save = function () {
$scope.product.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: u.Code});
$location.path('/Products');
$window.history.back();
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
@@ -101,7 +101,7 @@ var ProductCtrl = ['$scope', '$location', '$modal', 'product', 'product_groups',
$scope.delete = function () {
$scope.product.$delete(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$location.path('/Products');
$window.history.back();
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
+177
View File
@@ -0,0 +1,177 @@
'use strict';
var RecipeListCtrl = ['$scope', 'recipes', function ($scope, recipes) {
$scope.info = recipes;
$scope.display = $scope.info;
$scope.product_type_selected = 'all';
$scope.show_latest = 'latest';
$scope.show_summary = 'no';
$scope.$watch('product_type_selected', function (value) {
$scope.display = $scope.doFilter();
}, true);
$scope.$watch('show_latest', function (value) {
$scope.display = $scope.doFilter();
}, true);
$scope.doFilter = function (q) {
return _.filter($scope.info, function (item) {
if ($scope.product_type_selected === 'menu') {
if (item.IsSemi) {
return false;
}
} else if ($scope.product_type_selected === 'semi') {
if (!item.IsSemi) {
return false;
}
}
if ($scope.show_latest === 'latest' && !item.IsLatest) {
return false;
}
return true;
});
};
}];
RecipeListCtrl.resolve = {
recipes: ['Recipe', function (Recipe) {
return Recipe.query({}).$promise;
}]
};
var RecipeCtrl = ['$scope', '$location', '$window', '$modal', 'dateFilter', 'Product', 'recipe', 'product_groups', function ($scope, $location, $window, $modal, dateFilter, Product, recipe, product_groups) {
$scope.recipe = recipe;
$scope.original = {};
angular.copy($scope.recipe, $scope.original);
$scope.product_groups = product_groups;
$scope.cost_price = 0;
function getOld(productID, recipe_items) {
return _.find(recipe_items, function (recipe_item) {
return recipe_item.Product.ProductID === productID;
});
}
$scope.add = function () {
if (!$scope.product || !$scope.product.ProductID || !$scope.quantity || Number(!$scope.quantity)) {
return;
}
var oldItem = getOld($scope.product.ProductID, this.recipe.RecipeItems);
if (typeof oldItem === 'undefined') {
var quantity = Number($scope.quantity);
var price = Number($scope.product.Price);
this.recipe.RecipeItems.push({
Product: $scope.product,
Quantity: quantity,
Price: price
});
} else {
$scope.toasts.push({Type: 'Danger', Message: 'Ingredient already in the list'});
}
delete $scope.quantity;
delete $scope.product;
$('#txtProduct').focus();
};
$scope.removeItem = function (item) {
var index = this.recipe.RecipeItems.indexOf(item);
this.recipe.RecipeItems.splice(index, 1);
};
$scope.$watch('recipe.RecipeItems', function (recipe_items, oldValue) {
if (!angular.isArray(recipe_items)) {
return;
}
$scope.cost_price = recipe_items.reduce(function (sum, item, index, array) {
var rate = item.Price / (item.Product.Fraction * item.Product.ProductYield)
return sum + (item.Quantity * rate);
}, 0);
}, true);
$scope.save = function () {
if (angular.isDate($scope.recipe.Date)) {
$scope.recipe.Date = dateFilter($scope.recipe.Date, 'dd-MMM-yyyy');
}
if (angular.isUndefined($scope.recipe.Date) || $scope.recipe.Date === '') {
$scope.toasts.push({Type: 'Danger', Message: 'Please Choose a date'});
return;
}
if ($scope.recipe.Date === $scope.original.Date) {
var modalInstance = $modal.open({
backdrop: true,
templateUrl: '/template/modal/confirm.html',
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
$scope.title = "Update Recipe?";
$scope.body = "Are you sure? This will overwrite the original recipe.";
$scope.isDelete = false;
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]
});
modalInstance.result.then(function () {
$scope.doSave();
});
} else {
$scope.doSave();
}
};
$scope.doSave = function () {
$scope.recipe.$save(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$window.history.back();
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.delete = function () {
$scope.recipe.$delete(function (u, putResponseHeaders) {
$scope.toasts.push({Type: 'Success', Message: ''});
$window.history.back();
}, function (data, status) {
$scope.toasts.push({Type: 'Danger', Message: data.data});
});
};
$scope.confirm = function () {
var modalInstance = $modal.open({
backdrop: true,
templateUrl: '/template/modal/confirm.html',
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
$scope.title = "Delete Recipe";
$scope.body = "Are you sure? This cannot be undone.";
$scope.isDelete = true;
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]
});
modalInstance.result.then(function () {
$scope.delete();
});
};
$('#txtName').focus();
$scope.products = function ($viewValue) {
return Product.autocomplete({term: $viewValue, count: 20, a: true, e: true, t: 'S'}).$promise;
};
}];
RecipeCtrl.resolve = {
recipe: ['$route', 'Recipe', function ($route, Recipe) {
var id = $route.current.params.id;
return Recipe.get({id: id}).$promise;
}],
product_groups: ['ProductGroup', function (ProductGroup) {
return ProductGroup.query({}).$promise;
}]
};