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/activities/bitrix/startscriptactivity/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/activities/bitrix/startscriptactivity/src/index.js
import {Reflection, Type, Text, ajax} from 'main.core';
import {TagSelector} from "ui.entity-selector";

const namespace = Reflection.namespace('BX.Bizproc.Activity');

class StartScriptActivity
{
	#templateNode: HTMLElement;
	#templateInput: HTMLInputElement;
	#templateId: number = null;
	#parametersNode: HTMLElement;
	#documentType: [];
	#formName: string;
	#isRobot: boolean = false;

	constructor(options: {
		templateNode: HTMLElement,
		templateInput: HTMLInputElement,
		templateId: number,
		parametersNode: HTMLElement,
		documentType: [],
		formName: string,
		isRobot: boolean,
	})
	{
		if (!Type.isElementNode(options.templateNode))
		{
			throw 'templateNode must be HTML Element';
		}
		this.#templateNode = options.templateNode;

		if (!Type.isElementNode(options.templateInput))
		{
			throw 'templateInput must be HTML Input Element';
		}
		this.#templateInput = options.templateInput;

		if (!Type.isElementNode(options.parametersNode))
		{
			throw 'parametersNode must be HTML Element';
		}
		this.#parametersNode = options.parametersNode;

		const templateId = Text.toInteger(options.templateId);
		if (templateId > 0)
		{
			this.#templateId = templateId;
		}

		this.#documentType = Type.isArrayFilled(options.documentType) ? options.documentType : [];
		this.#formName = Type.isStringFilled(options.formName) ? options.formName : '';
		this.#isRobot = Type.isBoolean(options.isRobot) ? options.isRobot: false;
	}

	init()
	{
		this.#initTemplateSelector();
	}

	#initTemplateSelector()
	{
		const preselectedItems = [];
		if (this.#templateId)
		{
			preselectedItems.push(['bizproc-script-template', this.#templateId]);
		}

		const selector = new TagSelector({
			dialogOptions: {
				entities: [
					{ id: 'bizproc-script-template' }
				],
				multiple: false,
				dropdownMode: true,
				enableSearch: true,
				hideOnSelect: true,
				hideOnDeselect: false,
				clearSearchOnSelect: true,
				showAvatars: false,
				compactView: true,
				height: 300,
				preselectedItems: preselectedItems,
				events: {
					'Item:onSelect': (event) => {
						const { item: selectedItem } = event.getData();
						this.#renderTemplateParameters(selectedItem.getId());

						this.#templateInput.value = selectedItem.getId();
					},
					'Item:onDeselect': () => {
						this.#renderTemplateParameters(-1);
						this.#templateInput.value = '';
					},
				},
			},
			multiple: false,
			tagMaxWidth: 500
		});

		selector.renderTo(this.#templateNode);
	}

	#renderTemplateParameters(templateId: number) {
		this.#parametersNode.innerHTML = '';

		templateId = Text.toInteger(templateId);
		if (templateId <= 0)
		{
			return;
		}

		ajax.runAction('bizproc.activity.request', {
			data: {
				documentType: this.#documentType,
				activity: 'StartScriptActivity',
				params: {
					template_id: templateId,
					form_name: this.#formName,
					document_type: this.#documentType,
				},
			},
		}).then((response) => {
			this.#parametersNode.innerHTML = response.data;
		});
	}
}

namespace.StartScriptActivity = StartScriptActivity;

Youez - 2016 - github.com/yon3zu
LinuXploit