Skip to content

Commit

Permalink
Hotfix row bug
Browse files Browse the repository at this point in the history
Signed-off-by: JMiltner97 <[email protected]>
  • Loading branch information
JMiltner97 committed Jul 18, 2023
1 parent d3319fe commit b9f2526
Showing 1 changed file with 16 additions and 31 deletions.
47 changes: 16 additions & 31 deletions src/application/res/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ $(document).ready(function () {
populateAdvancedSearchFormFromSession();
populateSimpleSearch();

$('#form-container').on('change', '[id^=entry-][id$=-metadata_tag]', function() {
var id = $(this).attr('id');
var idx = id.split('-')[1]; // Get the index from the id
updateConditionOptions(idx, $(this).val());
console.log($(this).val());
});

// Delegated change event for condition
$('#form-container').on('change', '[id^=entry-][id$=-condition]', function() {
var id = $(this).attr('id');
var idx = id.split('-')[1]; // Get the index from the id
updateValueField(idx, $(this).val());
});

$('#addRow').on('click', function () {
// Increment the row index when button is clicked
rowIdx++;
Expand Down Expand Up @@ -117,17 +131,6 @@ $(document).ready(function () {
$('#removeRow' + rowIdx).on('click', function () {
$(this).closest('div.row').remove();
});

// Bind the change event for the metadata tag select field of the new row
$('#entry-' + rowIdx + '-metadata_tag').on("change", function () {
updateConditionOptions(rowIdx, $(this).val());
console.log($(this).val());
});

// Set the initial event listener for the choice select field in the first row
$('#entry-'+ rowIdx + '-condition').on("change", function () {
updateValueField(rowIdx, $(this).val());
});

//entry-${rowIdx}-metadata_tag
updateConditionOptions(rowIdx, $('#entry-' + rowIdx + '-metadata_tag').val());
Expand All @@ -139,16 +142,6 @@ $(document).ready(function () {

});

// Set the initial event listener for the metadata tag select field in the first row
$('#entry-0-metadata_tag').on("change", function () {
updateConditionOptions(0, $(this).val());
});

// Set the initial event listener for the choice select field in the first row
$('#entry-0-condition').on("change", function () {
updateValueField(0, $(this).val());
});

//advanced Search handler
$("#advancedSearchForm").one("submit", validateAdvancedSearch);

Expand Down Expand Up @@ -272,7 +265,7 @@ function addRowWithValues(metadataTag, condition, value, weight) {
<button id="removeRow${rowIdx}" type="button" class="btn btn-danger">Remove</button>
</div>
</div>
`);
`);


$("#entry-" + rowIdx + "-metadata_tag").append(options);
Expand All @@ -285,15 +278,7 @@ function addRowWithValues(metadataTag, condition, value, weight) {
$('#removeRow' + rowIdx).on('click', function () {
$(this).closest('div.row').remove();
});
// Bind the change event for the metadata tag select field of the new row
$('#entry-' + rowIdx + '-metadata_tag').on("change", function () {
updateConditionOptions(rowIdx, $(this).val());
console.log($(this).val());
});
// Set the initial event listener for the choice select field in the first row
$('#entry-'+ rowIdx + '-condition').on("change", function () {
updateValueField(rowIdx, $(this).val());
});

initializeSelect2("entry-" + rowIdx + "-metadata_tag");
updateConditionOptions(rowIdx, $("#entry-" + rowIdx + "-metadata_tag").val());
updateValueField(rowIdx, $("#entry-" + rowIdx + "-condition").val());
Expand Down

0 comments on commit b9f2526

Please sign in to comment.