Skip to content

Commit

Permalink
Merge pull request #891 from Hlavtox/non-category-filter
Browse files Browse the repository at this point in the history
Improve wording, add hints, fix javascript form validation
  • Loading branch information
Hlavtox authored Aug 3, 2023
2 parents faa9dbf + 5ed8857 commit 9df5f04
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 19 deletions.
5 changes: 5 additions & 0 deletions _dev/back/blocklayered.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@
.sortable-ghost {
color: orange;
}
#content.bootstrap {
.form-group-categories .panel {
margin-bottom: 0;
}
}
21 changes: 20 additions & 1 deletion _dev/back/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import './blocklayered.scss';
/* eslint-disable no-unused-vars, no-alert */
window.checkForm = function checkForm() {
let isCategorySelected = false;
let isCategoryControllerSelected = false;
let isControllerSelected = false;
let isFilterSelected = false;

$('#categories-treeview input[type=checkbox]').each(function checkCategoriesCheckboxes() {
Expand All @@ -31,6 +33,15 @@ window.checkForm = function checkForm() {
return true;
});

$('input[name="controllers[]"]').each(function checkPagesCheckboxes() {
if ($(this).prop('checked')) {
isControllerSelected = true;
if ($(this).val() === 'category') {
isCategoryControllerSelected = true;
}
}
});

$('.filter_list_item input[type=checkbox]').each(function checkFilterListCheckboxes() {
if ($(this).prop('checked')) {
isFilterSelected = true;
Expand All @@ -39,12 +50,20 @@ window.checkForm = function checkForm() {
return true;
});

if (!isCategorySelected) {
// If no controller is selected at all
if (!isControllerSelected) {
alert(translations.no_selected_controllers);
return false;
}

// If category controller was checked, but no category is selected
if (isCategoryControllerSelected && !isCategorySelected) {
alert(translations.no_selected_categories);
$('#categories-treeview input[type=checkbox]').first().focus();
return false;
}

// If no filter is selected at all
if (!isFilterSelected) {
alert(translations.no_selected_filters);
$('#filter_list_item input[type=checkbox]').first().focus();
Expand Down
2 changes: 1 addition & 1 deletion views/dist/back.css

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

2 changes: 1 addition & 1 deletion views/dist/back.css.map

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

Loading

0 comments on commit 9df5f04

Please sign in to comment.