<ul class="b-advanced-select_choices lsnn check-ul">
<li class="lvl2 b-advanced-select_choice_select-all">
<input type="checkbox" value="" data-action="select-all" id="i-select-all_90">
<label for="i-select-all_90">выбрать всё</label>
</li>
<li class="lvl2 hidden">
<input type="checkbox" value="Y" name="arrFilter_90_1294909896" id="arrFilter_90_1294909896" data-filtren-id="90">
<label for="arrFilter_90_1294909896"></label></li>
<li class="lvl2 hidden">
<input type="checkbox" value="Y" name="arrFilter_90_3483019650" id="arrFilter_90_3483019650" data-filtren-id="90">
<label for="arrFilter_90_3483019650"></label></li>
</ul>
<?
define(PROP_AREA_ID, 52);// id свойства "Район"
define(PROP_STREET_ID, 53);// id свойства "Адрес"
define(PROP_TYPE_ID, 54);// id свойства "Тип"
define(PROP_USING_ID, 90);// id свойства "Занятость" SIA 02.05.2018
$usedPropertyIds = array(PROP_AREA_ID, PROP_STREET_ID, PROP_TYPE_ID, PROP_USING_ID);
$combo = array();
foreach ($arResult['COMBO'] as $comboItem) {
$comboItemRes = array();
foreach ($usedPropertyIds as $propertyId) {
$comboItemRes[$propertyId] = array(
'value' => $comboItem[$propertyId],
'control_id' => $arResult['ITEMS'][$propertyId]['VALUES'][$comboItem[$propertyId]]['CONTROL_ID']
);
}
$combo[] = $comboItemRes;
}
?>
<script>
'use strict';
var addressProgramData = {
combo: <?= json_encode($combo) ?>
}
</script>
function doFiltrenCheckbox(){
try {
var filtrenCheckedCheckboxList = smartFilter.querySelectorAll('.b-filtren .b-filtren_item input[type="checkbox"]:checked');
var arFiltrenCheckedCheckbox = {};
Array.prototype.forEach.call(filtrenCheckedCheckboxList, function(filtrenCheckedCheckbox){
if (filtrenCheckedCheckbox.dataset.filtrenId in arFiltrenCheckedCheckbox) {
arFiltrenCheckedCheckbox[filtrenCheckedCheckbox.dataset.filtrenId].push(filtrenCheckedCheckbox.id);
} else {
arFiltrenCheckedCheckbox[filtrenCheckedCheckbox.dataset.filtrenId] = [filtrenCheckedCheckbox.id];
}
});
var activeFiltrenCheckboxList = {};
addressProgramData.combo.forEach(function(comboItem){
var isPassed = true;
var passedControlIds = [];
var currentFiltrenId = document.querySelector('.b-advanced-select.open');
if (currentFiltrenId) {
currentFiltrenId = currentFiltrenId.dataset.filtrenId;
}
for (filtrenId in comboItem) {
if (filtrenId in arFiltrenCheckedCheckbox) {
if (
currentFiltrenId !== filtrenId &&
arFiltrenCheckedCheckbox[filtrenId].indexOf(comboItem[filtrenId]['control_id']) === -1
) {
isPassed = false;
}
}
passedControlIds.push(comboItem[filtrenId]['control_id']);
}
if (isPassed) {
for (indx in passedControlIds) {
activeFiltrenCheckboxList[passedControlIds[indx]] = true;
}
}
});
// var advSelectSelection = filtrenCheckboxList.item(0).parentNode.parentNode.parentNode.querySelector('.b-advanced-select_selection');
Array.prototype.forEach.call(filtrenCheckboxList, function(filtrenCheckbox){
if(filtrenCheckbox.id in activeFiltrenCheckboxList) {
filtrenCheckbox.parentNode.classList.remove('hidden');
} else {
var advSelectSelection = filtrenCheckbox.parentNode.parentNode.parentNode.querySelector('.b-advanced-select_selection');
var advSelect_selectionChoice = advSelectSelection.querySelector('[data-id="' + filtrenCheckbox.id + '"]');
doUncheckAdvSelectCheckbox(filtrenCheckbox, advSelect_selectionChoice);
if(!filtrenCheckbox.parentNode.classList.contains('b-advanced-select_choice_select-all')) {
filtrenCheckbox.parentNode.classList.add('hidden');
}
}
});
// Выбираем те поля фильтра в которых выбрано несколько значение (есть "Выбрано (#SELECTION_COUNT#)")
// и обновляем значение #SELECTION_COUNT# (число выбранныз элементов)
var advSelectChoiceList = smartFilter.querySelectorAll('.b-advanced-select_choice[data-id=""]');
Array.prototype.forEach.call(advSelectChoiceList, function(advSelectChoice) {
var advSelectSelection = advSelectChoice.parentNode;
updateMultiselectionChoice(advSelectSelection, advSelectChoice);
});
} catch (error) {
console.info('Ошибка в функции "doFiltrenCheckbox" (событие "click" на чекбоксах или загрузка страницы).');
console.error(error);
}
};