Skip to content

Commit 7743ecc

Browse files
committed
feat(matrix ui): add checkbox for latest version
1 parent cbac0d1 commit 7743ecc

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

lib/pact_broker/ui/controllers/matrix.rb

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def create_selector_objects(selector_hashes)
6363
o.tag_disabled = o.tag ? nil : 'disabled'
6464
o.version_disabled = o.pacticipant_version_number ? nil : 'disabled'
6565
o.specify_latest_tag_checked = o.tag ? 'checked' : nil
66+
o.specify_latest_checked = o.latest ? 'checked' : nil
6667
o.specify_version_checked = o.pacticipant_version_number ? 'checked' : nil
6768
o.specify_all_versions_checked = !(o.tag || o.pacticipant_version_number) ? 'checked' : nil
6869
o

lib/pact_broker/ui/views/matrix/show.haml

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
Version
3737
%input{name: 'q[]version', type: 'text', id: "pacticipant#{index}_version", class: 'by-version', value: selector.pacticipant_version_number}
3838

39+
.input-group
40+
%input{type: 'radio', name: "ignorethis#{index}", class: 'specify-latest version-selectorizor', value: 'tag', id: "pacticipant#{index}_latest", checked: selector.specify_latest_checked}
41+
%label{for: "pacticipant#{index}_latest"}
42+
Latest version
43+
%input{name: 'q[]latest', value: 'true', hidden: true, class: 'latest-flag'}
44+
3945
.input-group
4046
%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}
4147
%label{for: "pacticipant#{index}_by_tag"}

public/javascripts/matrix.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function handleRadioButtonClicked() {
22
selectApplicableTextBox($(this));
3+
clearOtherTextBoxes($(this));
34
}
45

56
function selectApplicableTextBox(selectedRadioButton) {
@@ -15,9 +16,9 @@ function selectApplicableRadioButton(selectedTextBox) {
1516
selectedTextBox.closest('.input-group').find('.version-selectorizor').prop('checked', 'checked');
1617
}
1718

18-
function clearOtherTextBoxes(selectedTextBox) {
19-
selectedTextBox.closest('.selector').find('input[type="text"]').each(function(){
20-
if(!selectedTextBox.is($(this))) {
19+
function clearOtherTextBoxes(clickedElement) {
20+
clickedElement.closest('.selector').find('input[type="text"]').each(function(){
21+
if(!$.contains(clickedElement.closest('.input-group')[0], $(this)[0])) {
2122
$(this).prop('value', '');
2223
}
2324
});

0 commit comments

Comments
 (0)