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/rospirotorg.ru/bitrix/js/calendar/resourcebooking/src/controls/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/calendar/resourcebooking/src/controls/userselector.js
import {Type} from "../resourcebooking";
import {ViewControlAbstract} from "../viewcontrolabstract";
import {ViewDropDownSelect} from "../viewdropdownselect";

export class UserSelector extends ViewControlAbstract
{
	constructor(params)
	{
		super(params);

		this.name = 'UserSelector';
		this.data = params.data || {};
		this.userList = [];
		this.userIndex = {};

		this.values = [];
		this.defaultMode = 'auto';
		this.previewMode = params.previewMode === undefined;
		this.autoSelectDefaultValue = params.autoSelectDefaultValue;
		this.changeValueCallback = params.changeValueCallback;

		this.handleSettingsData(this.data, params.userIndex);
	}

	displayControl()
	{
		this.selectedValue = this.getSelectedUser();
		this.dropdownSelect = new ViewDropDownSelect({
			wrap: this.DOM.controlWrap,
			values: this.userList,
			selected: this.selectedValue,
			handleChangesCallback: this.handleChanges.bind(this)
		});
		this.dropdownSelect.build();
	}

	refresh(data, userIndex)
	{
		this.refreshLabel(data);
		this.data = data;
		this.handleSettingsData(this.data, userIndex);
		this.selectedValue = this.getSelectedUser();

		if (this.dropdownSelect)
		{
			this.dropdownSelect.setSettings({
				values: this.userList,
				selected: this.selectedValue
			});
		}

		if (this.setDataConfig())
		{
			if (this.isDisplayed())
			{
				this.show({animation: true});
			}
			else
			{
				this.hide({animation: true});
			}
		}
	}

	handleSettingsData(data, userIndex)
	{
		if (Type.isPlainObject(userIndex))
		{
			for (let id in userIndex)
			{
				if (userIndex.hasOwnProperty(id))
				{
					this.userIndex[id] = userIndex[id];
				}
			}
		}

		this.defaultMode = this.data.defaultMode === 'none' ? 'none' : 'auto';
		let dataValue = [];
		this.userList = [];
		if (this.data.value)
		{
			let dataValueRaw = Type.isArray(this.data.value) ? this.data.value : this.data.value.split('|');
			dataValueRaw.forEach(function(id)
			{
				id = parseInt(id);
				if (id > 0)
				{
					dataValue.push(id);
					if (this.userIndex[id])
					{
						this.userList.push({
							id: id,
							title: this.userIndex[id].displayName
						});
					}
				}
			}, this);
		}
		this.values = dataValue;
	}

	getSelectedUser()
	{
		let selected = null;
		if (this.dropdownSelect)
		{
			selected = this.dropdownSelect.getSelectedValues();
			selected = (Type.isArray(selected) && selected.length) ? selected[0] : null;
		}

		if (!selected && this.previewMode
			&& this.data.defaultMode === 'auto'
			&& this.userList && this.userList[0])
		{
			selected = this.userList[0].id;
		}

		if (!selected && this.autoSelectDefaultValue)
		{
			selected = this.autoSelectDefaultValue;
		}

		return selected;
	}

	setSelectedUser(userId)
	{
		if (this.dropdownSelect)
		{
			this.dropdownSelect.setSelectedValues([userId]);
		}
		else
		{
			this.autoSelectDefaultValue = parseInt(userId);
		}
	}

	handleChanges(selectedValues)
	{
		if (!this.previewMode && Type.isFunction(this.changeValueCallback))
		{
			this.changeValueCallback(selectedValues[0] || null);
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit