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/ui/stepprocessing/src/fields/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/ui/stepprocessing/src/fields/select-field.js
// @flow

import {Type, Tag} from 'main.core';
import type { OptionsField } from '../process-types';
import { BaseField } from './base-field';
import { DialogStyle } from '../dialog';

export class SelectField extends BaseField
{
	type: string = 'select';
	multiple: boolean = false;
	size: number;
	list: Array = [];
	className: string = DialogStyle.ProcessOptionSelect;

	constructor(options: OptionsField)
	{
		super(options);

		if ('multiple' in options)
		{
			this.multiple = Type.isBoolean(options.multiple) ? options.multiple === true : options.multiple === 'Y';
		}
		if (this.multiple)
		{
			if ('size' in options)
			{
				this.size = options.size;
			}
		}
		if ('list' in options)
		{
			this.list = options.list;
		}
	}

	setValue(value: any)
	{
		if (this.multiple)
		{
			this.value = Type.isArray(value) ? value : [value];
		}
		else
		{
			this.value = value;
		}
		if (this.field)
		{
			if (this.multiple)
			{
				for (let k = 0; k < this.field.options.length; k++)
				{
					this.field.options[k].selected = (this.value.indexOf(this.field.options[k].value) !== -1);
				}
			}
			else
			{
				this.field.value = this.value;
			}
		}
		return this;
	}
	getValue(): any
	{
		if (this.field && this.disabled !== true)
		{
			if (this.multiple)
			{
				this.value = [];
				for (let k = 0; k < this.field.options.length; k++)
				{
					if (this.field.options[k].selected)
					{
						this.value.push(this.field.options[k].value);
					}
				}
			}
			else
			{
				this.value = this.field.value;
			}
		}
		return this.value;
	}

	isFilled(): boolean
	{
		if (this.field)
		{
			for (let k = 0; k < this.field.options.length; k++)
			{
				if (this.field.options[k].selected)
				{
					return true;
				}
			}
		}
		return false;
	}

	render(): HTMLElement
	{
		if (!this.field)
		{
			this.field = Tag.render`<select id="${this.id}" name="${this.name}"></select>`;
		}
		if (this.multiple)
		{
			this.field.multiple = 'multiple';
			if (this.size)
			{
				this.field.size = this.size;
			}
		}

		Object.keys(this.list).forEach(itemId => {
			let selected;
			if (this.multiple === true)
			{
				selected = (this.value.indexOf(itemId) !== -1);
			}
			else
			{
				selected = (itemId === this.value);
			}

			let option = this.field.appendChild(Tag.render`<option value="${itemId}">${this.list[itemId]}</option>`);
			if (selected)
			{
				option.selected = 'selected';
			}
		});

		return this.field;
	}

	lock(flag: boolean = true)
	{
		this.disabled = flag;
		this.field.disabled = !!flag;
		return this;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit