@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
1 lines • 5.91 kB
Source Map (JSON)
{"version":3,"file":"dialog.mjs","sources":["../../../src/frame/dialog.ts"],"sourcesContent":["import type { MessageManager } from './message'\nimport { MessageCommands } from './message'\nimport type { NumberString } from '../types/common'\n\nexport type SelectedUser = {\n /**\n * user identifier\n */\n id: NumberString\n\n /**\n * formatted username\n */\n name: string\n\n photo: string\n\n position: string\n\n url: string\n\n /**\n * The flag indicates that the selected user is a subordinate of the current user\n */\n sub: boolean\n\n /**\n * The flag indicates that the selected user is the manager of the current user\n */\n sup: boolean\n}\n\nexport type SelectedAccess = {\n /**\n * access permission identifier. Examples of identifiers:\n * - U1 — user with identifier 1\n * - IU1 — employees with identifier 1\n * - DR2 — all department and subdepartment employees with identifier 2\n * - D6 — all department employees with identifier 6\n * - G2 — group with identifier 2 (all visitors)\n * - SG4 — social network group with identifier 4\n * - AU — all authorized users\n * - CR — current user\n */\n id:\n | `AU`\n | `CR`\n | `U${number}`\n | `IU${number}`\n | `DR${number}`\n | `D${number}`\n | `G${number}`\n | `SG${number}`\n\n /**\n * name of the access permission\n */\n name: string\n}\n\nexport type SelectCRMParamsEntityType\n = | 'lead'\n | 'contact'\n | 'company'\n | 'deal'\n | 'quote'\n\nexport type SelectCRMParamsValue = {\n lead?: number[]\n contact?: number[]\n company?: number[]\n deal?: number[]\n quote?: number[]\n}\n\nexport type SelectCRMParams = {\n /**\n * Which types of objects to display in the dialog. Possible values:\n * - lead — Leads\n * - contact — Contacts\n * - company — Companies\n * - deal — Deals\n * - quote — Estimates\n */\n entityType: SelectCRMParamsEntityType[]\n\n /**\n * Whether multiple objects can be selected. Default is `false`\n */\n multiple: boolean\n\n /**\n * Which objects to initially add to the selected in the dialog. Works only if `multiple = true`\n */\n value?: SelectCRMParamsValue\n}\n\nexport type SelectedCRMEntity = {\n id: string\n type: SelectCRMParamsEntityType\n place: string\n title: string\n desc: string\n url: string\n}\n\nexport type SelectedCRM = {\n lead?: (SelectedCRMEntity & { id: `L_${number}` })[]\n contact?: (SelectedCRMEntity & { id: `C_${number}`, image: string })[]\n company?: (SelectedCRMEntity & { id: `CO_${number}`, image: string })[]\n deal?: (SelectedCRMEntity & { id: `D_${number}` })[]\n quote?: (SelectedCRMEntity & { id: `Q_${number}` })[]\n}\n\n/**\n * Select dialog manager\n *\n * @link https://apidocs.bitrix24.com/sdk/bx24-js-sdk/system-dialogues/index.html\n */\nexport class DialogManager {\n #messageManager: MessageManager\n\n constructor(messageManager: MessageManager) {\n this.#messageManager = messageManager\n }\n\n /**\n * Method displays the standard single user selection dialog\n * It only shows company employees\n *\n * @return {Promise<null|SelectedUser>}\n *\n * @link https://apidocs.bitrix24.com/sdk/bx24-js-sdk/system-dialogues/bx24-select-user.html\n */\n async selectUser(): Promise<null | SelectedUser> {\n return this.#messageManager.send(MessageCommands.selectUser, {\n mult: false\n })\n }\n\n /**\n * Method displays the standard multiple user selection dialog\n * It only shows company employees\n *\n * @return {Promise<SelectedUser[]>}\n *\n * @link https://apidocs.bitrix24.com/sdk/bx24-js-sdk/system-dialogues/bx24-select-users.html\n */\n async selectUsers(): Promise<SelectedUser[]> {\n return this.#messageManager.send(MessageCommands.selectUser, {\n mult: true\n })\n }\n\n /**\n * Method displays a standard access permission selection dialog\n *\n * @param {string[]} blockedAccessPermissions\n * @return {Promise<SelectedAccess[]>}\n *\n * @link https://apidocs.bitrix24.com/sdk/bx24-js-sdk/system-dialogues/bx24-select-access.html\n */\n async selectAccess(\n blockedAccessPermissions: string[] = []\n ): Promise<SelectedAccess[]> {\n return this.#messageManager.send(MessageCommands.selectAccess, {\n value: blockedAccessPermissions\n })\n }\n\n /**\n * Method invokes the system dialog for selecting a CRM entity\n *\n * @param {SelectCRMParams} params\n * @return {Promise<SelectedCRM>}\n *\n * @link https://apidocs.bitrix24.com/sdk/bx24-js-sdk/system-dialogues/bx24-select-crm.html\n */\n async selectCRM(params?: SelectCRMParams): Promise<SelectedCRM> {\n return this.#message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