Skip to content

Commit

Permalink
Only show parent product field if no child products
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepdeJong committed Sep 20, 2024
1 parent a843b90 commit 7d01c3a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/resources/static/js/products/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ $(document).ready(function () {
}
});

hasParentFields($('#parentProduct').val() !== '');
// Check if parentProduct exists
hasParentFields($('#parentProduct').val() !== '' && $('#parentProduct').val() !== undefined);
$('#parentProduct').on('change', function () {
const hasParent = $(this).val() !== '';
hasParentFields(hasParent);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/js/products/script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main/resources/templates/admin/products/product.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h6 class="card-header">Information</h6>
</div>
<div class="col-12">
<!-- Product selection -->
<div class="row" th:if="${product.event != null}">
<div class="row" th:if="${product.event != null && product.getChildProducts().size() == 0}">
<div class="form-group col-6">
<label>Parent product</label>
<select id="parentProduct" class="form-control"
Expand Down

0 comments on commit 7d01c3a

Please sign in to comment.