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/catalog/store-enable-wizard/src/ |
Upload File : |
import { Text, Loc, Extension, Runtime, Type } from 'main.core'; import { ModeList } from './mode-list'; import { Popup } from './popup'; import { Service } from './service'; type DisablerOptions = { events: { onDisabled: ?() => void, } } class Disabler { #popup: Popup; #options: DisablerOptions; constructor(options: DisablerOptions = {}) { this.#options = options; const hasCriticalErrors = this.#getPopupTexts().some((text) => text.critical === true); this.#popup = new Popup({ helpCode: this.#getSetting('availableModes').length > 1 ? '20233748' : '15992592', width: hasCriticalErrors ? null : 'auto', title: this.#getPopupTitle(), texts: this.#getPopupTexts(), hideHelp: !hasCriticalErrors, hideIcon: !hasCriticalErrors, primaryButtonText: hasCriticalErrors ? Loc.getMessage('CATALOG_INVENTORY_MANAGEMENT_POPUP_BUTTON_TURN_OFF_ANYWAY') : Loc.getMessage('CATALOG_INVENTORY_MANAGEMENT_POPUP_BUTTON_TURN_OFF'), primaryButtonClass: hasCriticalErrors ? 'ui-btn-danger' : 'ui-btn-primary', secondaryButtonText: Loc.getMessage('CATALOG_INVENTORY_MANAGEMENT_POPUP_BUTTON_CANCEL'), events: { onPrimaryClick: () => this.#disable(), onSecondaryClick: () => this.#popup.show(false), onClose: () => {}, }, }); } open() { this.#popup.show(true); } sendDisableDoneEvent(status: string) { this.#sendEvent({ tool: 'inventory', category: 'settings', event: 'disable_done', c_section: 'settings', p1: `mode_${this.#getSetting('currentMode')}`, status, }); } #getPopupTitle(): String { if (this.#getSetting('currentMode') === ModeList.MODE_B24) { if (this.#getSetting('isWithOrdersMode') === true) { return Loc.getMessage('CATALOG_INVENTORY_MANAGEMENT_NOT_ABLE_TO_TURN_BACK_TITLE') .replace('[break]', '<br>'); } if (this.#hasConductedDocumentsOrQuantities()) { return Loc.getMessage('CATALOG_INVENTORY_MANAGEMENT_DATA_WILL_BE_DELETED_2') .replace('[break]', '<br>'); } } return ''; } #getPopupTexts(): Array { const result = []; if (this.#getSetting('currentMode') === ModeList.MODE_B24) { if (this.#hasConductedDocumentsOrQuantities()) { result.push( { critical: true, text: Loc.getMessage( 'CATALOG_INVENTORY_MANAGEMENT_DELETE_DOCUMENTS_AND_QUANTITY_TEXT_ON_DISABLE_B24_TEXT_1', ), }, { critical: true, text: Loc.getMessage( 'CATALOG_INVENTORY_MANAGEMENT_DELETE_DOCUMENTS_AND_QUANTITY_TEXT_ON_DISABLE_B24_TEXT_2', ), }, ); } if (this.#getSetting('isWithOrdersMode') === true) { result.push({ critical: true, text: Loc.getMessage('CATALOG_INVENTORY_MANAGEMENT_NOT_ABLE_TO_TURN_BACK_TEXT') .replace('[break]', '<br>'), }); } } if (result.length === 0) { result.push({ text: Loc.getMessage( 'CATALOG_INVENTORY_MANAGEMENT_DISABLE_CONFIRMATION_TEXT', ), }); } return result; } #disable() { this.#popup.load(true); Service.disable() .then(() => { this.sendDisableDoneEvent('success'); this.#options.events?.onDisabled?.(); }) .catch((error) => { this.sendDisableDoneEvent( `error_${error?.customData?.analyticsCode ?? 'unknown'}`, ); top.BX.UI.Notification.Center.notify({ content: Text.encode(error.message) }); }) .finally(() => { this.#popup.load(false); this.#popup.show(false); }); } #getSetting(name: string) { return Extension.getSettings('catalog.store-enable-wizard').get(name); } #sendEvent(data: Object) { Runtime.loadExtension('ui.analytics') .then((exports) => { const { sendData } = exports; sendData(data); }); } #hasConductedDocumentsOrQuantities(): boolean { if (Type.isBoolean(this.#options.hasConductedDocumentsOrQuantities)) { return this.#options.hasConductedDocumentsOrQuantities; } return true; } } export { Disabler, };