Make enter submit the search form in products list

This commit is contained in:
Luis Ramos
2020-06-13 11:49:26 +01:00
parent a91c81059f
commit f08b837115
3 changed files with 13 additions and 1 deletions

View File

@@ -64,6 +64,10 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
RequestMonitor.load(BulkProducts.fetch(params).$promise).then ->
$scope.resetProducts()
# Used by directive enterToSubmit
$scope.submit = ->
$scope.fetchProducts()
removeClearedValues = ->
delete $scope.producerFilter if $scope.producerFilter == "0"
delete $scope.categoryFilter if $scope.categoryFilter == "0"

View File

@@ -0,0 +1,8 @@
angular.module("ofn.admin").directive "enterToSubmit", ->
restrict: 'A'
link: (scope, element, attrs) ->
element.bind "keypress", (event) ->
return if event.which != 13
scope.submit()

View File

@@ -5,7 +5,7 @@
.quick_search.three.columns.alpha
%label{ for: 'quick_filter' }
%br
%input.quick-search.fullwidth{ ng: {model: 'query'}, name: "quick_filter", type: 'text', placeholder: t('admin.quick_search') }
%input.quick-search.fullwidth{ ng: {model: 'query'}, name: "quick_filter", type: 'text', placeholder: t('admin.quick_search'), "enter-to-submit" => "" }
.one.columns  
.filter_select.three.columns
%label{ for: 'producer_filter' }= t 'producer'