On filters reseting , set dates to undefined: range is not mandatory

+ send flatpickr event to reset the component

+ update specs as well
This commit is contained in:
Jean-Baptiste Bellet
2023-01-05 15:02:52 +01:00
parent b75b123cba
commit 121a4a08af
4 changed files with 8 additions and 21 deletions

View File

@@ -13,22 +13,14 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.confirmRefresh = ->
LineItems.allSaved() || confirm(t("unsaved_changes_warning"))
$scope.initStartAndEnDate = ->
$scope.startDate = moment().startOf('day').subtract(7, 'days').format('YYYY-MM-DD')
$scope.endDate = moment().startOf('day').format('YYYY-MM-DD')
$scope.resetFilters = ->
$scope.distributorFilter = ''
$scope.supplierFilter = ''
$scope.orderCycleFilter = ''
$scope.quickSearch = ''
$scope.initStartAndEnDate()
event = new CustomEvent('flatpickr:change', {
detail: {
startDate: $scope.startDate,
endDate: $scope.endDate
}
})
$scope.startDate = undefined
$scope.endDate = undefined
event = new CustomEvent('flatpickr:clear')
window.dispatchEvent(event)
$scope.resetSelectFilters = ->