pact_broker 2.18.0 → 2.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +7 -0
  3. data/CHANGELOG.md +21 -0
  4. data/README.md +5 -2
  5. data/example/example_data.sql +2 -0
  6. data/lib/pact_broker/api.rb +5 -0
  7. data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +8 -0
  8. data/lib/pact_broker/api/decorators/provider_pacts_decorator.rb +12 -7
  9. data/lib/pact_broker/api/pact_broker_urls.rb +4 -0
  10. data/lib/pact_broker/api/resources/badge.rb +3 -1
  11. data/lib/pact_broker/api/resources/error_handler.rb +5 -1
  12. data/lib/pact_broker/api/resources/error_test.rb +2 -2
  13. data/lib/pact_broker/api/resources/index.rb +13 -1
  14. data/lib/pact_broker/api/resources/latest_provider_pacts.rb +7 -19
  15. data/lib/pact_broker/api/resources/pact_content_diff.rb +14 -2
  16. data/lib/pact_broker/api/resources/pact_version.rb +13 -0
  17. data/lib/pact_broker/api/resources/provider_pacts.rb +45 -0
  18. data/lib/pact_broker/api/resources/version.rb +1 -1
  19. data/lib/pact_broker/domain/verification.rb +1 -2
  20. data/lib/pact_broker/error.rb +1 -0
  21. data/lib/pact_broker/matrix/repository.rb +39 -28
  22. data/lib/pact_broker/matrix/service.rb +2 -6
  23. data/lib/pact_broker/pacts/diff.rb +24 -13
  24. data/lib/pact_broker/pacts/pact_params.rb +10 -0
  25. data/lib/pact_broker/pacts/repository.rb +18 -0
  26. data/lib/pact_broker/pacts/service.rb +4 -0
  27. data/lib/pact_broker/pacts/sort_verifiable_content.rb +41 -0
  28. data/lib/pact_broker/ui/controllers/error_test.rb +1 -1
  29. data/lib/pact_broker/ui/controllers/matrix.rb +5 -6
  30. data/lib/pact_broker/ui/views/matrix/show.haml +15 -17
  31. data/lib/pact_broker/verifications/repository.rb +3 -3
  32. data/lib/pact_broker/version.rb +1 -1
  33. data/lib/pact_broker/versions/repository.rb +11 -1
  34. data/lib/pact_broker/versions/service.rb +2 -2
  35. data/public/javascripts/matrix.js +40 -33
  36. data/spec/features/get_pact_version.rb +13 -0
  37. data/spec/features/get_provider_pacts_spec.rb +33 -12
  38. data/spec/lib/pact_broker/api/decorators/pacticipant_decorator_spec.rb +12 -1
  39. data/spec/lib/pact_broker/api/decorators/provider_pacts_decorator_spec.rb +57 -0
  40. data/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +16 -0
  41. data/spec/lib/pact_broker/api/resources/badge_spec.rb +3 -3
  42. data/spec/lib/pact_broker/api/resources/error_handler_spec.rb +19 -1
  43. data/spec/lib/pact_broker/api/resources/latest_provider_pacts_spec.rb +52 -0
  44. data/spec/lib/pact_broker/api/resources/provider_pacts_spec.rb +75 -0
  45. data/spec/lib/pact_broker/matrix/repository_spec.rb +52 -0
  46. data/spec/lib/pact_broker/matrix/service_spec.rb +1 -17
  47. data/spec/lib/pact_broker/pacts/diff_spec.rb +34 -7
  48. data/spec/lib/pact_broker/pacts/pact_params_spec.rb +33 -8
  49. data/spec/lib/pact_broker/pacts/repository_spec.rb +65 -1
  50. data/spec/lib/pact_broker/pacts/sort_verifiable_content_spec.rb +25 -0
  51. data/spec/lib/pact_broker/verifications/repository_spec.rb +44 -17
  52. data/spec/lib/pact_broker/versions/repository_spec.rb +2 -2
  53. data/spec/support/test_data_builder.rb +4 -0
  54. data/tasks/rspec.rake +6 -4
  55. metadata +17 -2
@@ -57,11 +57,7 @@ module PactBroker
57
57
  error_messages << "Please specify the pacticipant name"
58
58
  else
59
59
  if s.key?(:pacticipant_version_number) && s.key?(:latest)
60
- error_messages << "A version and latest flag cannot both be specified for #{s[:pacticipant_name]}"
61
- end
62
-
63
- if s.key?(:tag) && !s.key?(:latest)
64
- error_messages << "Querying for all versions with a tag is not currently supported. The latest=true flag must be specified when a tag is given."
60
+ error_messages << "A version number and latest flag cannot both be specified for #{s[:pacticipant_name]}"
65
61
  end
66
62
  end
67
63
  end
@@ -78,7 +74,7 @@ module PactBroker
78
74
  version = version_service.find_by_pacticipant_name_and_number(pacticipant_name: s[:pacticipant_name], pacticipant_version_number: s[:pacticipant_version_number])
79
75
  error_messages << "No pact or verification found for #{s[:pacticipant_name]} version #{s[:pacticipant_version_number]}" if version.nil?
80
76
  elsif s[:tag]
81
- version = version_service.find_by_pacticpant_name_and_latest_tag(s[:pacticipant_name], s[:tag])
77
+ version = version_service.find_by_pacticipant_name_and_latest_tag(s[:pacticipant_name], s[:tag])
82
78
  error_messages << "No version of #{s[:pacticipant_name]} found with tag #{s[:tag]}" if version.nil?
83
79
  end
84
80
  end
@@ -1,6 +1,7 @@
1
1
  require 'pact_broker/api/pact_broker_urls'
2
2
  require 'pact_broker/date_helper'
3
3
  require 'pact_broker/pacts/create_formatted_diff'
4
+ require 'pact_broker/pacts/sort_verifiable_content'
4
5
  require 'pact_broker/repositories'
5
6
  require 'yaml'
6
7
 
@@ -10,13 +11,13 @@ module PactBroker
10
11
  class Diff
11
12
  include PactBroker::Repositories
12
13
 
13
- def process(params)
14
+ def process(params, comparison_pact_params = nil, options = {})
14
15
  pact = find_pact(params)
15
- previous_distinct_pact = pact_repository.find_previous_distinct_pact(pact)
16
+ comparison_pact = comparison_pact_params ? find_pact(comparison_pact_params) : pact_repository.find_previous_distinct_pact(pact)
16
17
 
17
- if previous_distinct_pact
18
- next_pact = pact_repository.find_next_pact(previous_distinct_pact)
19
- DiffDecorator.new(pact, previous_distinct_pact, next_pact, params[:base_url]).to_text
18
+ if comparison_pact
19
+ next_pact = pact_repository.find_next_pact(comparison_pact) || pact
20
+ DiffDecorator.new(pact, comparison_pact, next_pact, params[:base_url], { raw: options[:raw] }).to_text
20
21
  else
21
22
  no_previous_version_message pact
22
23
  end
@@ -27,7 +28,8 @@ module PactBroker
27
28
  def find_pact(params)
28
29
  pact_repository.find_pact(params.consumer_name,
29
30
  params.consumer_version_number,
30
- params.provider_name)
31
+ params.provider_name,
32
+ params.pact_version_sha)
31
33
  end
32
34
 
33
35
  def no_previous_version_message(pact)
@@ -46,11 +48,12 @@ module PactBroker
46
48
  # the latest distinct version content was first created.
47
49
 
48
50
  class DiffDecorator
49
- def initialize(pact, previous_distinct_pact, next_pact, base_url)
51
+ def initialize(pact, comparison_pact, next_pact, base_url, options)
50
52
  @pact = pact
51
- @previous_distinct_pact = previous_distinct_pact
53
+ @comparison_pact = comparison_pact
52
54
  @next_pact = next_pact
53
55
  @base_url = base_url
56
+ @options = options
54
57
  end
55
58
 
56
59
  def to_text
@@ -59,7 +62,7 @@ module PactBroker
59
62
 
60
63
  private
61
64
 
62
- attr_reader :pact, :previous_distinct_pact, :next_pact, :base_url
65
+ attr_reader :pact, :comparison_pact, :next_pact, :base_url, :options
63
66
 
64
67
  def change_date_in_words
65
68
  DateHelper.local_date_in_words next_pact.created_at
@@ -70,7 +73,7 @@ module PactBroker
70
73
  end
71
74
 
72
75
  def header
73
- title = "# Diff between versions #{previous_distinct_pact.consumer_version_number} and #{pact.consumer_version_number} of the pact between #{pact.consumer.name} and #{pact.provider.name}"
76
+ title = "# Diff between versions #{comparison_pact.consumer_version_number} and #{pact.consumer_version_number} of the pact between #{pact.consumer.name} and #{pact.provider.name}"
74
77
  description = "The following changes were made #{change_date_ago_in_words} ago (#{change_date_in_words})"
75
78
 
76
79
  title + "\n\n" + description
@@ -78,7 +81,7 @@ module PactBroker
78
81
 
79
82
  def links
80
83
  self_url = PactBroker::Api::PactBrokerUrls.pact_url(base_url, pact)
81
- previous_distinct_url = PactBroker::Api::PactBrokerUrls.pact_url(base_url, previous_distinct_pact)
84
+ previous_distinct_url = PactBroker::Api::PactBrokerUrls.pact_url(base_url, comparison_pact)
82
85
 
83
86
  links = {
84
87
  "current-pact-version" => {
@@ -88,7 +91,7 @@ module PactBroker
88
91
  },
89
92
  "previous-distinct-pact-version" => {
90
93
  "title" => "Pact",
91
- "name" => previous_distinct_pact.name,
94
+ "name" => comparison_pact.name,
92
95
  "href" => previous_distinct_url
93
96
  }
94
97
  }
@@ -96,12 +99,20 @@ module PactBroker
96
99
  end
97
100
 
98
101
  def diff
99
- CreateFormattedDiff.(pact.json_content, previous_distinct_pact.json_content)
102
+ CreateFormattedDiff.(prepare_content(pact.json_content), prepare_content(comparison_pact.json_content))
100
103
  end
101
104
 
102
105
  def change_date_ago_in_words
103
106
  DateHelper.distance_of_time_in_words next_pact.created_at, now
104
107
  end
108
+
109
+ def prepare_content json_content
110
+ if options[:raw]
111
+ json_content
112
+ else
113
+ PactBroker::Pacts::SortVerifiableContent.call(json_content)
114
+ end
115
+ end
105
116
  end
106
117
  end
107
118
  end
@@ -10,6 +10,16 @@ module PactBroker
10
10
  merge!(attributes)
11
11
  end
12
12
 
13
+ def self.from_path_info path_info
14
+ new(
15
+ consumer_name: path_info.fetch(:consumer_name),
16
+ provider_name: path_info.fetch(:provider_name),
17
+ consumer_version_number: path_info[:consumer_version_number],
18
+ revision_number: path_info[:revision_number],
19
+ pact_version_sha: path_info[:pact_version_sha]
20
+ )
21
+ end
22
+
13
23
  def self.from_request request, path_info
14
24
  json_content = request.body.to_s
15
25
  parsed_content = begin
@@ -70,6 +70,24 @@ module PactBroker
70
70
  end
71
71
  end
72
72
 
73
+ def find_pact_versions_for_provider provider_name, tag = nil
74
+ if tag
75
+ LatestPactPublicationsByConsumerVersion
76
+ .join(:tags, {version_id: :consumer_version_id})
77
+ .provider(provider_name)
78
+ .order_ignore_case(:consumer_name)
79
+ .order_append(:consumer_version_order)
80
+ .where(Sequel[:tags][:name] => tag)
81
+ .collect(&:to_domain)
82
+ else
83
+ LatestPactPublicationsByConsumerVersion
84
+ .provider(provider_name)
85
+ .order_ignore_case(:consumer_name)
86
+ .order_append(:consumer_version_order)
87
+ .collect(&:to_domain)
88
+ end
89
+ end
90
+
73
91
  # Returns latest pact version for the consumer_version_number
74
92
  def find_by_consumer_version consumer_name, consumer_version_number
75
93
  LatestPactPublicationsByConsumerVersion
@@ -68,6 +68,10 @@ module PactBroker
68
68
  pact_repository.find_latest_pact_versions_for_provider provider_name, options[:tag]
69
69
  end
70
70
 
71
+ def find_pact_versions_for_provider provider_name, options = {}
72
+ pact_repository.find_pact_versions_for_provider provider_name, options[:tag]
73
+ end
74
+
71
75
  def find_previous_distinct_pact_version params
72
76
  pact = find_pact params
73
77
  return nil if pact.nil?
@@ -0,0 +1,41 @@
1
+ require 'pact_broker/json'
2
+
3
+ module PactBroker
4
+ module Pacts
5
+ class SortVerifiableContent
6
+
7
+ def self.call json
8
+ hash = JSON.parse(json, PACT_PARSING_OPTIONS)
9
+ verifiable_content = if hash['interactions']
10
+ hash['interactions']
11
+ elsif hash['messages']
12
+ hash['messages']
13
+ end
14
+ order_verifiable_content(verifiable_content).to_json
15
+ end
16
+
17
+ def self.order_verifiable_content array
18
+ array_with_ordered_hashes = order_hashes(array)
19
+ array_with_ordered_hashes.sort{|a, b| a.to_json <=> b.to_json }
20
+ end
21
+
22
+ def self.order_hashes thing
23
+ case thing
24
+ when Hash then order_hash(thing)
25
+ when Array then order_child_array(thing)
26
+ else thing
27
+ end
28
+ end
29
+
30
+ def self.order_child_array array
31
+ array.collect{|thing| order_hashes(thing) }
32
+ end
33
+
34
+ def self.order_hash hash
35
+ hash.keys.sort.each_with_object({}) do | key, new_hash |
36
+ new_hash[key] = order_hashes(hash[key])
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -9,7 +9,7 @@ module PactBroker
9
9
  include PactBroker::Services
10
10
 
11
11
  get "/" do
12
- raise PactBroker::Error.new("Don't panic. This is a test UI error.")
12
+ raise PactBroker::TestError.new("Don't panic. This is a test UI error.")
13
13
  end
14
14
  end
15
15
  end
@@ -59,12 +59,11 @@ module PactBroker
59
59
  def create_selector_objects(selector_hashes)
60
60
  selector_hashes.collect do | selector_hash |
61
61
  o = OpenStruct.new(selector_hash)
62
- o.tag_disabled = o.tag ? nil : 'disabled'
63
- o.version_disabled = o.pacticipant_version_number ? nil : 'disabled'
64
- o.specify_latest_tag_checked = o.tag ? 'checked' : nil
65
- o.specify_latest_checked = o.latest ? 'checked' : nil
66
- o.specify_version_checked = o.pacticipant_version_number ? 'checked' : nil
67
- o.specify_all_versions_checked = !(o.tag || o.pacticipant_version_number) ? 'checked' : nil
62
+ o.specify_latest_tag = o.tag && o.latest ? 'checked' : nil
63
+ o.specify_all_tagged = o.tag && !o.latest ? 'checked' : nil
64
+ o.specify_latest = o.latest ? 'checked' : nil
65
+ o.specify_version = o.pacticipant_version_number ? 'checked' : nil
66
+ o.specify_all_versions = !(o.tag || o.pacticipant_version_number) ? 'checked' : nil
68
67
  o
69
68
  end
70
69
  end
@@ -29,29 +29,27 @@
29
29
  %input{name: 'q[]pacticipant', id: "pacticipant1#{index}", value: selector.pacticipant_name}
30
30
 
31
31
  .input-group
32
- %input{type: 'radio', name: "ignorethis#{index}", class: 'specify-all-versions version-selectorizor', value: 'all_versions', id: "pacticipant#{index}_all_versions", checked: selector.specify_all_versions_checked}
33
- %label{for: "pacticipant#{index}_all_versions"}
34
- All versions
35
32
 
36
33
  .input-group
37
- %input{type: 'radio', name: "ignorethis#{index}", class: 'specify-version version-selectorizor', value: 'version', id: "pacticipant#{index}_by_version", checked: selector.specify_version_checked}
38
- %label{for: "pacticipant#{index}_by_version"}
39
- Version
40
- %input{name: 'q[]version', type: 'text', id: "pacticipant#{index}_version", class: 'by-version', value: selector.pacticipant_version_number}
34
+ %select{ name: "ignorethis#{index}", class: 'version-selectorizor' }
35
+ %option{ value: 'specify-all-versions', selected: selector.specify_all_versions }
36
+ All versions
37
+ %option{ value: 'specify-latest', selected: selector.specify_latest }
38
+ Latest version
39
+ %option{ value: 'specify-version', selected: selector.specify_version }
40
+ Version number ...
41
+ %option{ value: 'specify-latest-tag', selected: selector.specify_latest_tag }
42
+ Latest version with tag ...
43
+ %option{ value: 'specify-all-tagged', selected: selector.specify_all_tagged }
44
+ All versions with tag...
41
45
 
42
- .input-group
43
- %input{type: 'radio', name: "ignorethis#{index}", class: 'specify-latest version-selectorizor', value: 'tag', id: "pacticipant#{index}_latest", checked: selector.specify_latest_checked}
44
- %label{for: "pacticipant#{index}_latest"}
45
- Latest version
46
- %input{name: 'q[]latest', value: 'true', hidden: true, class: 'latest-flag'}
46
+ %input{name: 'q[]version', type: 'text', id: "pacticipant#{index}_version", class: 'version', value: selector.pacticipant_version_number}
47
+
48
+ %input{name: 'q[]tag', type: 'text', id: "pacticipant#{index}_tag", class: 'tag', value: selector.tag}
47
49
 
48
- .input-group
49
- %input{type: 'radio', name: "ignorethis#{index}", class: 'specify-latest-tag version-selectorizor', value: 'tag', id: "pacticipant#{index}_by_tag", checked: selector.specify_latest_tag_checked}
50
- %label{for: "pacticipant#{index}_by_tag"}
51
- Latest version with tag
52
- %input{name: 'q[]tag', type: 'text', id: "pacticipant#{index}_tag", class: "by-latest-tag", value: selector.tag}
53
50
  %input{name: 'q[]latest', value: 'true', hidden: true, class: 'latest-flag'}
54
51
 
52
+
55
53
  %div.top-of-group
56
54
  .input-group
57
55
  %input{type: 'radio', name: "latestby", class: '', value: '', id: 'all_rows', checked: options.all_rows_checked}
@@ -75,15 +75,15 @@ module PactBroker
75
75
  query = PactBroker::Verifications::AllVerifications
76
76
  .select_all_qualified
77
77
  .join(:versions, {Sequel[:provider_versions][:id] => Sequel[view_name][:provider_version_id]}, {table_alias: :provider_versions})
78
- .join(:all_pact_publications, { Sequel[view_name][:pact_version_id] => Sequel[:all_pact_publications][:pact_version_id] })
78
+ .join(:latest_pact_publications_by_consumer_versions, { Sequel[view_name][:pact_version_id] => Sequel[:latest_pact_publications_by_consumer_versions][:pact_version_id] })
79
79
  .consumer(consumer_name)
80
80
  .provider(provider_name)
81
81
  .tag(consumer_version_tag)
82
82
  .provider_version_tag(provider_version_tag)
83
83
 
84
84
  query.reverse_order(
85
- Sequel[:all_pact_publications][:consumer_version_order],
86
- Sequel[:all_pact_publications][:revision_number],
85
+ Sequel[:latest_pact_publications_by_consumer_versions][:consumer_version_order],
86
+ Sequel[:latest_pact_publications_by_consumer_versions][:revision_number],
87
87
  Sequel[:provider_versions][:order],
88
88
  Sequel[view_name][:execution_date]
89
89
  ).limit(1).single_record
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '2.18.0'
2
+ VERSION = '2.19.0'
3
3
  end
@@ -12,7 +12,7 @@ module PactBroker
12
12
  PactBroker::Domain::Version.where(number: number, pacticipant_id: pacticipant_id).single_record
13
13
  end
14
14
 
15
- def find_by_pacticpant_name_and_latest_tag pacticipant_name, tag
15
+ def find_by_pacticipant_name_and_latest_tag pacticipant_name, tag
16
16
  PactBroker::Domain::Version
17
17
  .select_all_qualified
18
18
  .join(:pacticipants, {id: :pacticipant_id}, {implicit_qualifier: :versions})
@@ -23,6 +23,16 @@ module PactBroker
23
23
  .first
24
24
  end
25
25
 
26
+ def find_by_pacticipant_name_and_tag pacticipant_name, tag
27
+ PactBroker::Domain::Version
28
+ .select_all_qualified
29
+ .join(:pacticipants, {id: :pacticipant_id}, {implicit_qualifier: :versions})
30
+ .join(:tags, {version_id: :id}, {implicit_qualifier: :versions})
31
+ .where(name_like(Sequel[:tags][:name], tag))
32
+ .where(name_like(Sequel[:pacticipants][:name], pacticipant_name))
33
+ .all
34
+ end
35
+
26
36
  def find_latest_by_pacticpant_name pacticipant_name
27
37
  PactBroker::Domain::Version
28
38
  .select_all_qualified
@@ -15,8 +15,8 @@ module PactBroker
15
15
  version_repository.find_by_pacticipant_name_and_number params.fetch(:pacticipant_name), params.fetch(:pacticipant_version_number)
16
16
  end
17
17
 
18
- def self.find_by_pacticpant_name_and_latest_tag(pacticipant_name, tag)
19
- version_repository.find_by_pacticpant_name_and_latest_tag(pacticipant_name, tag)
18
+ def self.find_by_pacticipant_name_and_latest_tag(pacticipant_name, tag)
19
+ version_repository.find_by_pacticipant_name_and_latest_tag(pacticipant_name, tag)
20
20
  end
21
21
 
22
22
  def self.delete version
@@ -1,27 +1,48 @@
1
- function handleRadioButtonClicked() {
2
- selectApplicableTextBox($(this));
3
- clearOtherTextBoxes($(this));
4
- }
5
1
 
6
- function selectApplicableTextBox(selectedRadioButton) {
7
- selectedRadioButton.closest('.input-group').find('input[type="text"]').first().focus();
2
+ function setTextboxVisibility(selectBox, cssSelector, visibility) {
3
+ var textbox = selectBox.closest('.selector').find(cssSelector);
4
+ textbox.toggle(visibility);
5
+ if(visibility) {
6
+ textbox.prop('disabled', '');
7
+ textbox.focus();
8
+ } else {
9
+ textbox.prop('disabled', 'disabled');
10
+ }
8
11
  }
9
12
 
10
- function handleTextBoxClicked() {
11
- selectApplicableRadioButton($(this));
12
- clearOtherTextBoxes($(this));
13
+ function toggleLatestFlag(selectBox, enabled) {
14
+ var flagElement = selectBox.closest('.selector').find('.latest-flag');
15
+ if(enabled) {
16
+ flagElement.prop('disabled', '');
17
+ } else {
18
+ flagElement.prop('disabled', 'disabled');
19
+ }
13
20
  }
14
21
 
15
- function selectApplicableRadioButton(selectedTextBox) {
16
- selectedTextBox.closest('.input-group').find('.version-selectorizor').prop('checked', 'checked');
22
+ function showApplicableTextBoxes(selectorizor) {
23
+ var selectorizorType = selectorizor.val();
24
+ if( selectorizorType === 'specify-version') {
25
+ setTextboxVisibility(selectorizor, '.version', true);
26
+ setTextboxVisibility(selectorizor, '.tag', false);
27
+ }
28
+ else if( selectorizorType === 'specify-latest-tag' || selectorizorType === 'specify-all-tagged') {
29
+ setTextboxVisibility(selectorizor, '.version', false);
30
+ setTextboxVisibility(selectorizor, '.tag', true);
31
+ }
32
+ else if ( selectorizorType === 'specify-all-versions' || selectorizorType === 'specify-latest') {
33
+ setTextboxVisibility(selectorizor, '.version', false);
34
+ setTextboxVisibility(selectorizor, '.tag', false);
35
+ }
36
+
37
+ if (selectorizorType === 'specify-latest' || selectorizorType === 'specify-latest-tag') {
38
+ toggleLatestFlag(selectorizor, true);
39
+ } else {
40
+ toggleLatestFlag(selectorizor, false);
41
+ }
17
42
  }
18
43
 
19
- function clearOtherTextBoxes(clickedElement) {
20
- clickedElement.closest('.selector').find('input[type="text"]').each(function(){
21
- if(!$.contains(clickedElement.closest('.input-group')[0], $(this)[0])) {
22
- $(this).prop('value', '');
23
- }
24
- });
44
+ function handleSelectorizorChanged() {
45
+ showApplicableTextBoxes($(this));
25
46
  }
26
47
 
27
48
  function onSubmit() {
@@ -30,26 +51,12 @@ function onSubmit() {
30
51
  }
31
52
 
32
53
  function disableFieldsThatShouldNotBeSubmitted() {
33
- disableInputsForUncheckedRadioButtons();
34
- disableRadioButtons();
35
- }
36
-
37
- function disableInputsForUncheckedRadioButtons() {
38
- $('.version-selectorizor').each(function(){
39
- if($(this).prop('checked') === false) {
40
- $(this).closest('.input-group').find('input').prop('disabled', 'disabled');
41
- }
42
- });
43
- }
44
-
45
- function disableRadioButtons() {
46
54
  $('.version-selectorizor').prop('disabled', 'disabled');
47
55
  }
48
56
 
49
57
  $(document).ready(function(){
50
- $('.by-version').click(handleTextBoxClicked);
51
- $('.by-latest-tag').click(handleTextBoxClicked);
52
- $('.version-selectorizor').click(handleRadioButtonClicked);
58
+ $('.version-selectorizor').change(handleSelectorizorChanged);
59
+ $('.version-selectorizor').each(function(){ showApplicableTextBoxes($(this)); });
53
60
 
54
61
  $("#matrix").tablesorter({
55
62
  textExtraction : function(node, table, cellIndex){