Add basic hard filter adding js infrastructure for BPE

This commit is contained in:
Rob H
2014-01-04 16:44:00 +08:00
parent 687332d2b0
commit 7ef358a476
2 changed files with 40 additions and 1 deletions

View File

@@ -138,10 +138,15 @@ productsApp.controller "AdminBulkProductsCtrl", [
["Items", "items"]
]
$scope.filterTypes = [
{ name: "Equals", ransack_predicate: "eq" }
]
$scope.perPage = 25
$scope.currentPage = 1
$scope.products = []
$scope.filteredProducts = []
$scope.currentFilters = []
$scope.totalCount = -> $scope.filteredProducts.length
$scope.totalPages = -> Math.ceil($scope.totalCount()/$scope.perPage)
$scope.firstVisibleProduct = -> ($scope.currentPage-1)*$scope.perPage+1
@@ -225,6 +230,12 @@ productsApp.controller "AdminBulkProductsCtrl", [
onHand
$scope.addFilter = (filter) ->
if Object.keys($scope.columns).indexOf(filter.property) >= 0
if $scope.filterTypes.map( (filter_type) -> filter_type.ransack_predicate ).indexOf(filter.ransack_predicate) >= 0
$scope.currentFilters.push filter
$scope.editWarn = (product, variant) ->
if ($scope.dirtyProductCount() > 0 and confirm("Unsaved changes will be lost. Continue anyway?")) or ($scope.dirtyProductCount() == 0)
window.location = "/admin/products/" + product.permalink_live + ((if variant then "/variants/" + variant.id else "")) + "/edit"