From 3a8c4ebb43616abaad1087c8384a61138a6398dd Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 21 Mar 2016 14:01:20 -0500 Subject: [PATCH] Loop through form inputs --- .../javascripts/search_autocomplete.js.coffee | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/search_autocomplete.js.coffee b/app/assets/javascripts/search_autocomplete.js.coffee index 69ca0d996d1..8165502914e 100644 --- a/app/assets/javascripts/search_autocomplete.js.coffee +++ b/app/assets/javascripts/search_autocomplete.js.coffee @@ -28,7 +28,6 @@ class @SearchAutocomplete @groupInputEl = @getElement('#group_id') @searchCodeInputEl = @getElement('#search_code') @repositoryInputEl = @getElement('#repository_ref') - @scopeInputEl = @getElement('#scope') @saveOriginalState() @@ -51,6 +50,7 @@ class @SearchAutocomplete group_id: @groupInputEl.val() search_code: @searchCodeInputEl.val() repository_ref: @repositoryInputEl.val() + scope: @scopeInputEl.val() # Location badge _location: $.trim(@locationText.text()) @@ -191,20 +191,17 @@ class @SearchAutocomplete @locationBadgeEl.children().length resetSearchState: -> - # Remove scope - @scopeInputEl.val('') + inputs = Object.keys @originalState - # Remove group - @groupInputEl.val('') + for input in inputs - # Remove project id - @projectInputEl.val('') + # _location isnt a input + break if input is '_location' - # Remove code search - @searchCodeInputEl.val('') + # renamed to avoid tests to fail + if input is 'project_id' then input = 'search_project_id' - # Remove repository ref - @repositoryInputEl.val('') + @getElement("##{input}").val('') removeLocationBadge: -> @locationBadgeEl.empty()