Skip to content

Commit

Permalink
Add search form to show-with-tags page
Browse files Browse the repository at this point in the history
  • Loading branch information
bangn committed Jun 29, 2021
1 parent 6214a60 commit 5000fd1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/pact_broker/ui/controllers/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Index < Base
current_page_size: view_index_items.size,
base_url: base_url,
errors: error_messages,
tags: tags,
pacticipant_name: pacticipant_name
}

Expand Down
27 changes: 26 additions & 1 deletion lib/pact_broker/ui/views/index/show-with-tags.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@
!= render :haml, :'index/_css_and_js', :layout => false
.container
!= render :haml, :'index/_navbar', :layout => false, locals: {tag_toggle: false, base_url: base_url}
- if index_items.empty?
- if index_items.empty? && pacticipant_name.blank?
!= render :haml, :'index/_getting-started', :layout => false
%h1.page-header
Pacts

- unless errors.blank?
- errors.each do | error |
%div.alert.alert-danger
= error

%form{action: "#{base_url}"}
.field
%label{for: 'pacticipant_name'}
Pacticipant name
%input{name: 'pacticipant_name', id: 'pacticipant_name', class: 'pacticipant_name', value: pacticipant_name}
%div.top-of-group
%input{type: 'button', class: 'submit-search', value: 'Search'}
%input{type: 'button', class: 'reset-search', value: 'Reset' }

%table.table.table-bordered.table-striped{ id: 'relationships' }
%thead
%tr
Expand Down Expand Up @@ -118,3 +133,13 @@
$(td).tooltip({container: $(td).first()});
});
});

$(".reset-search").on("click", function() {
location = window.location.href
window.location.replace("#{base_url}/?tags=#{tags}");
})

$(".submit-search").on("click", function() {
pacticipant_name = $("#pacticipant_name").val();
window.location.replace("#{base_url}/?tags=#{tags}" + `&pacticipant_name=${pacticipant_name}`);
})

0 comments on commit 5000fd1

Please sign in to comment.