Skip to content

Commit

Permalink
feat(matrix): allow matrix columns to be sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 7, 2017
1 parent d81f129 commit 7d22eb8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/pact_broker/api/pact_broker_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def new_verification_url pact, number, base_url
].join('/')
end

def verification_url verification, base_url
def verification_url verification, base_url = ''
[ base_url, 'pacts',
'provider', url_encode(verification.provider_name),
'consumer', url_encode(verification.consumer_name),
Expand Down
37 changes: 37 additions & 0 deletions lib/pact_broker/ui/view_models/matrix_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,51 @@ def initialize line
@line = line
end

def provider_name
@line[:provider_name]
end

def consumer_name
@line[:consumer_name]
end

def pact_version_sha
@line[:pact_version_sha]
end

# verification number
def number
@line[:number]
end

def consumer_version_number
@line[:consumer_version_number]
end

def consumer_version_number_url
pact_url_from_params('', @line)
end

def consumer_version_order
@line[:consumer_version_order]
end

def provider_version_number
@line[:provider_version]
end

def provider_version_number_url
hal_browser_url(verification_url(self))
end

def provider_version_order
if @line[:execution_date]
@line[:execution_date].to_time.to_i
else
0
end
end

def verification_status
case @line[:success]
when true then "Verified"
Expand Down
22 changes: 17 additions & 5 deletions lib/pact_broker/ui/views/matrix/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.container
%h1.page-header
= title
%table.table.table-bordered.table-striped{id: 'relationships'}
%table.table.table-bordered.table-striped{id: 'matrix'}
%thead
%th.consumer
= "#{consumer_name} version"
Expand All @@ -18,13 +18,25 @@
%span.glyphicon.glyphicon-sort.sort
%th.verification-result
Verification
%span.glyphicon.glyphicon-sort.sort
%tbody
- lines.each do | line |
%tr
%td.consumer-version
= line.consumer_version_number
%td.provider
= line.provider_version_number
%td.consumer-version{'data-sort-value' => line.consumer_version_order}
%a{href: line.consumer_version_number_url}
= line.consumer_version_number
%td.provider{'data-sort-value' => line.provider_version_order}
%a{href: line.provider_version_number_url}
= line.provider_version_number
%td.verification-result{class: line.verification_status_class}
= line.verification_status

:javascript
$(function(){
$("#matrix").tablesorter({
textExtraction : function(node, table, cellIndex){
n = $(node);
return n.attr('data-sort-value') || n.text();
}
});
});

0 comments on commit 7d22eb8

Please sign in to comment.