403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/cvetdv.ru/bitrix/js/socialnetwork/ui/grid/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/js/socialnetwork/ui/grid/src/filter.js
import {Type} from 'main.core';
import {BaseEvent, EventEmitter} from 'main.core.events';

export class Filter
{
	constructor(options)
	{
		this.filterInstance = BX.Main.filterManager.getById(options.filterId);
		if (!this.filterInstance)
		{
			return;
		}

		this.defaultFilterPresetId = options.defaultFilterPresetId;
		this.gridId = options.gridId;

		this.init();
		this.bindEvents();
	}

	init()
	{
		this.fields = this.filterInstance.getFilterFieldsValues();
	}

	bindEvents()
	{
		EventEmitter.subscribe('BX.Main.Filter:apply', this.onFilterApply.bind(this));
	}

	onFilterApply()
	{
		this.updateFields();
	}

	updateFields()
	{
		this.fields = this.filterInstance.getFilterFieldsValues();
	}

	toggleByField(field)
	{
		const name = Object.keys(field)[0];
		const value = field[name];

		if (!this.isFilteredByFieldValue(name, value))
		{
			this.filterInstance.getApi().extendFilter({[name]: value});
			return;
		}

		this.filterInstance.getFilterFields().forEach((field) => {
			if (field.getAttribute('data-name') === name)
			{
				this.filterInstance.getFields().deleteField(field);
			}
		});

		this.filterInstance.getSearch().apply();
	}

	isFilteredByFieldValue(field, value)
	{
		return (
			this.isFilteredByField(field)
			&& this.fields[field] === value
		);
	}

	isFilteredByField(field)
	{
		if (!Object.keys(this.fields).includes(field))
		{
			return false;
		}

		if (Type.isArray(this.fields[field]))
		{
			return this.fields[field].length > 0;
		}

		return this.fields[field] !== '';
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit