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/bizproc/automation/src/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/bizproc/automation/src/templates-scheme.js
import {Type} from 'main.core';
import {DocumentType, DocumentCategory, DocumentStatus} from './document/types';
import {TemplateScope} from './template-scope';

export default class TemplatesScheme
{
	#scheme: Array<TemplateScope>;

	constructor(scheme: Array<TemplateScope>)
	{
		this.#scheme = [];

		if (Type.isArray(scheme))
		{
			scheme.forEach(rawScope => {
				const scope = new TemplateScope(rawScope);
				this.#scheme.push(scope);
			});
		}
	}

	getDocumentTypes(): Array<DocumentType>
	{
		const documentTypes = new Map();

		for (const scope of this.#scheme)
		{
			documentTypes.set(scope.getDocumentType().Type, scope.getDocumentType());
		}

		return Array.from(documentTypes.values());
	}

	getTypeCategories(documentType: DocumentType): Array<DocumentCategory>
	{
		const documentCategories = new Map();

		for (const scope of this.#scheme)
		{
			if (scope.hasCategory() && scope.getDocumentType().Type === documentType.Type)
			{
				const category = scope.getDocumentCategory();
				documentCategories.set(category.Id, category);
			}
		}

		return Array.from(documentCategories.values());
	}

	getTypeStatuses(documentType: DocumentType, documentCategory: DocumentCategory | null): Array<DocumentStatus>
	{
		const takenStatuses = new Set();
		if (Type.isNil(documentCategory))
		{
			documentCategory = {Id: null};
		}

		const predicate = scope => {
			const shouldBeTaken = (
				scope.getDocumentType().Type === documentType.Type
				&& (scope.hasCategory() ? scope.getDocumentCategory().Id === documentCategory.Id : true)
				&& !takenStatuses.has(scope.getDocumentStatus().Id)
			);

			if (shouldBeTaken)
			{
				takenStatuses.add(scope.getDocumentStatus().Id);
			}

			return shouldBeTaken;
		};

		return Array.from(this.#filterBy(predicate)).map(scope => scope.getDocumentStatus());
	}

	#filterBy(predicate: (TemplateScope) => boolean): Iterable<TemplateScope>
	{
		const generator = function*(scheme)
		{
			for (const scope of scheme)
			{
				if (predicate(scope))
				{
					yield scope;
				}
			}
		};

		return generator(this.#scheme);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit