Skip to content

Commit

Permalink
feat(matrix ui): add checkbox for latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Dec 21, 2017
1 parent cbac0d1 commit 7743ecc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/pact_broker/ui/controllers/matrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def create_selector_objects(selector_hashes)
o.tag_disabled = o.tag ? nil : 'disabled'
o.version_disabled = o.pacticipant_version_number ? nil : 'disabled'
o.specify_latest_tag_checked = o.tag ? 'checked' : nil
o.specify_latest_checked = o.latest ? 'checked' : nil
o.specify_version_checked = o.pacticipant_version_number ? 'checked' : nil
o.specify_all_versions_checked = !(o.tag || o.pacticipant_version_number) ? 'checked' : nil
o
Expand Down
6 changes: 6 additions & 0 deletions lib/pact_broker/ui/views/matrix/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
Version
%input{name: 'q[]version', type: 'text', id: "pacticipant#{index}_version", class: 'by-version', value: selector.pacticipant_version_number}

.input-group
%input{type: 'radio', name: "ignorethis#{index}", class: 'specify-latest version-selectorizor', value: 'tag', id: "pacticipant#{index}_latest", checked: selector.specify_latest_checked}
%label{for: "pacticipant#{index}_latest"}
Latest version
%input{name: 'q[]latest', value: 'true', hidden: true, class: 'latest-flag'}

.input-group
%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}
%label{for: "pacticipant#{index}_by_tag"}
Expand Down
7 changes: 4 additions & 3 deletions public/javascripts/matrix.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function handleRadioButtonClicked() {
selectApplicableTextBox($(this));
clearOtherTextBoxes($(this));
}

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

function clearOtherTextBoxes(selectedTextBox) {
selectedTextBox.closest('.selector').find('input[type="text"]').each(function(){
if(!selectedTextBox.is($(this))) {
function clearOtherTextBoxes(clickedElement) {
clickedElement.closest('.selector').find('input[type="text"]').each(function(){
if(!$.contains(clickedElement.closest('.input-group')[0], $(this)[0])) {
$(this).prop('value', '');
}
});
Expand Down

0 comments on commit 7743ecc

Please sign in to comment.