Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'Clear All' button work on order cycle page #2821

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ angular.module("admin.orderCycles").controller "OrderCyclesCtrl", ($scope, $q, C
$scope.columns = Columns.columns
$scope.saveAll = -> OrderCycles.saveChanges($scope.order_cycles_form)
$scope.ordersCloseAtLimit = -31 # days
$scope.involvingFilter = 0
$scope.scheduleFilter = 0

$scope.resetSelectFilters = ->
$scope.scheduleFilter = 0
$scope.involvingFilter = 0
$scope.query = ''
$scope.resetSelectFilters()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry @nikobozi, I'm not very angular-savy. When does this get executed? can you explain a bit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's when the controller is loaded @sauloperez

Copy link
Contributor Author

@nikobozi nikobozi Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, and it can then be triggered via a ng-click directive from a DOM element, which in this case is the input button in this template views/admin/order_cycles/_filters.html.haml

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! thanks both!


compileData = ->
for schedule in $scope.schedules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ describe "OrderCyclesCtrl", ->

it "the RequestMonitor will not longer have a state of loading", ->
expect(scope.RequestMonitor.loading).toBe false

describe "filtering order cycles", ->
it "filters by and resets filter variables", ->
scope.query = "test"
scope.scheduleFilter = 1
scope.involvingFilter = 1
scope.resetSelectFilters()
expect(scope.query).toBe ""
expect(scope.scheduleFilter).toBe 0
expect(scope.involvingFilter).toBe 0