mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-25 01:23:23 +00:00
Add basic hard filter adding js infrastructure for BPE
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user