Skip to content

Commit

Permalink
Add to settings field and mark for select section by part of handle
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdhosting authored May 12, 2023
1 parent bc120ea commit f930a44
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/templates/_components/fields/section/_settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@

<hr>

{{ forms.textField({
id: 'searchInput',
label : 'Select Section By Text In Handle' | t('section-and-product-type'),
instructions : 'This will allow to select all section by text in handle.' | t('section-and-product-type'),
name : 'partOfHandle',
value: partOfHandle,
}) }}

<hr>

{{ forms.checkboxGroupField({
label : 'Allowed Sections' | t('section-and-product-type'),
instructions : 'The sections that may be chosen for this field.\n **If selected Select All Sections, all sections are selected**.' | t('section-and-product-type'),
Expand All @@ -39,3 +49,29 @@
id : 'excludedSections',
name : 'excludedSections',
}) }}

<script>
const searchInput = document.querySelector('#types-wmd-sectionandproducttype-fields-SectionField-searchInput');
const checkboxes = document.querySelectorAll('.checkbox-group .checkboxfield');
searchInput.addEventListener('input', (event) => {
const searchText = event.target.value.toLowerCase();
if (searchText.length > 0) {
checkboxes.forEach((checkbox) => {
const checkboxText = checkbox.querySelector('label').textContent.toLowerCase();
if (checkboxText.includes(searchText)) {
checkbox.style.background = 'yellow';
} else {
checkbox.style.background = '';
}
})
} else {
checkboxes.forEach((checkbox) => {
const checkboxText = checkbox.querySelector('label').textContent.toLowerCase();
if (checkboxText.includes(searchText)) {
checkbox.style.background = '';
}
})
}
});
</script>

0 comments on commit f930a44

Please sign in to comment.