UNPKG

@cauca-911/devextreme

Version:

Run `npm install @cauca-911/devextreme --save` to add this library to your project

1,008 lines (1,001 loc) 61.6 kB
import * as i0 from '@angular/core'; import { Component, Input, EventEmitter, Output, input, model, ViewChild, Injectable, NgModule } from '@angular/core'; import * as i1 from 'devextreme-angular'; import { DxDataGridComponent, NestedOptionHost, DxDateBoxComponent, DxPopupComponent, DxTextAreaComponent, DxTemplateHost, WatcherHelper, IterableDifferHelper } from 'devextreme-angular'; import * as i2 from '@angular/common'; import { Location, LocationStrategy, PathLocationStrategy, CommonModule } from '@angular/common'; import { exportDataGrid as exportDataGrid$1 } from 'devextreme/excel_exporter'; import { Workbook } from 'exceljs'; import { saveAs } from 'file-saver'; import { exportDataGrid } from 'devextreme/pdf_exporter'; import { jsPDF } from 'jspdf'; import * as i1$1 from '@cauca-911/core'; import { CaucaCoreForChildModule } from '@cauca-911/core'; import * as i2$1 from 'devextreme-angular/ui/popup'; import { DxPopupModule } from 'devextreme-angular/ui/popup'; import * as i2$2 from 'devextreme-angular/ui/text-area'; import { DxTextAreaModule } from 'devextreme-angular/ui/text-area'; import * as i3 from '@ngx-translate/core'; import * as i3$1 from 'devextreme-angular/ui/button'; import { DxButtonModule } from 'devextreme-angular/ui/button'; import * as i4 from 'devextreme-angular/core'; import * as i5 from 'devextreme-angular/ui/tab-panel'; import { DxTabPanelModule } from 'devextreme-angular/ui/tab-panel'; import * as i6 from 'devextreme-angular/ui/text-box'; import { DxTextBoxModule } from 'devextreme-angular/ui/text-box'; import { DxDataGridModule } from 'devextreme-angular/ui/data-grid'; import { DxDateBoxModule } from 'devextreme-angular/ui/date-box'; import { DxValidatorModule } from 'devextreme-angular/ui/validator'; const _c0$2 = ["*"]; class CaucaDataGridComponent extends DxDataGridComponent { constructor(element, ngZone, templateHost, watcherHelper, idh, optionHost, transferState, platform, location, locationStrategy) { super(element, ngZone, templateHost, watcherHelper, idh, optionHost, transferState, platform); this.location = location; this.allowPrint = false; this.allowExports = false; this.allowLocationEditing = true; this.fileName = ''; this.isEditing = false; this.hoverStateEnabled = true; this.rowAlternationEnabled = true; this.showBorders = true; this.filterRow = { visible: true, }; this.pager = { showPageSizeSelector: true, showNavigationButtons: true, showInfo: true, visible: true, }; optionHost.setHost(this); locationStrategy.onPopState(() => { if (this.isEditing) { this.isEditing = false; this.instance.cancelEditData(); } }); } ngOnInit() { super.ngOnInit(); this.onToolbarPreparing.subscribe((e) => this.toolbarPreparing(e)); this.onInitialized.subscribe((e) => this.initialized(e)); this.onExporting.subscribe((e) => this.exporting(e)); this.export = { allowExportSelectedData: true, enabled: this.allowExports, formats: ['xlsx', 'pdf'], }; } exporting(e) { if (e.format == 'xlsx') { this.convertGridAsExcel(this); } else if (e.format == 'pdf') { this.convertGridAsPdf(this); } } toolbarPreparing(e) { const toolbarItems = e.toolbarOptions.items; this.addPrintButton(toolbarItems, e.element); } addPrintButton(toolbarItems, elementToPrint) { if (this.allowPrint) { toolbarItems.push({ widget: 'dxButton', location: 'after', options: { icon: 'print', onClick: (_ev) => { this.printGridAsPage(elementToPrint); }, } }); } } initialized(e) { const options = e.component.option('editing'); options.popup.onShowing = (_ev) => { if (this.allowLocationEditing) { this.location.go(this.location.path() + '#editing'); } this.isEditing = true; }; options.popup.onHiding = (_ev) => { if (this.isEditing && this.allowLocationEditing) { this.location.back(); } this.isEditing = false; }; } printGridAsPage(element) { element.classList.add('only-div-to-print'); window.print(); setTimeout(() => { element.classList.remove('only-div-to-print'); }, 1000); } convertGridAsPdf(dataGridComponent) { const doc = new jsPDF(); exportDataGrid({ jsPDFDocument: doc, component: dataGridComponent.instance }).then(() => { if (this.fileName.length == 0) this.fileName = 'exportPdf'; doc.save(this.fileName + '.pdf'); }); } convertGridAsExcel(dataGridComponent) { const workbook = new Workbook(); const worksheet = workbook.addWorksheet('Page principale'); exportDataGrid$1({ component: dataGridComponent.instance, worksheet: worksheet, autoFilterEnabled: true, customizeCell: (options) => { options.excelCell.font = { name: 'Arial', size: 12, bold: options.gridCell.rowType === 'header' || options.gridCell.rowType === 'columnheader' || options.gridCell.rowType === 'group' }; options.excelCell.alignment = { horizontal: 'left', vertical: 'middle' }; } }).then(() => { const columns = worksheet.columns; columns.forEach(column => { column.width = 50; }); let fileNameToSave = this.fileName; if (fileNameToSave.length === 0) fileNameToSave = 'exportExcel'; workbook.xlsx.writeBuffer() .then(function (buffer) { saveAs(new Blob([buffer], { type: 'application/octet-stream' }), fileNameToSave + '.xlsx'); }); }); } static { this.ɵfac = function CaucaDataGridComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaucaDataGridComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(i1.DxTemplateHost), i0.ɵɵdirectiveInject(i1.WatcherHelper), i0.ɵɵdirectiveInject(i1.IterableDifferHelper), i0.ɵɵdirectiveInject(i1.NestedOptionHost), i0.ɵɵdirectiveInject(i0.TransferState), i0.ɵɵdirectiveInject(i0.PlatformRef), i0.ɵɵdirectiveInject(i2.Location), i0.ɵɵdirectiveInject(i2.LocationStrategy)); }; } static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaucaDataGridComponent, selectors: [["cauca-dx-data-grid"]], inputs: { allowPrint: "allowPrint", allowExports: "allowExports", allowLocationEditing: "allowLocationEditing", fileName: "fileName" }, standalone: false, features: [i0.ɵɵProvidersFeature([NestedOptionHost, Location, { provide: LocationStrategy, useClass: PathLocationStrategy }]), i0.ɵɵInheritDefinitionFeature], ngContentSelectors: _c0$2, decls: 1, vars: 0, template: function CaucaDataGridComponent_Template(rf, ctx) { if (rf & 1) { i0.ɵɵprojectionDef(); i0.ɵɵprojection(0); } }, encapsulation: 2 }); } } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaucaDataGridComponent, [{ type: Component, args: [{ selector: 'cauca-dx-data-grid', providers: [NestedOptionHost, Location, { provide: LocationStrategy, useClass: PathLocationStrategy }], standalone: false, template: "<ng-content></ng-content>" }] }], () => [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i1.DxTemplateHost }, { type: i1.WatcherHelper }, { type: i1.IterableDifferHelper }, { type: i1.NestedOptionHost }, { type: i0.TransferState }, { type: i0.PlatformRef }, { type: i2.Location }, { type: i2.LocationStrategy }], { allowPrint: [{ type: Input }], allowExports: [{ type: Input }], allowLocationEditing: [{ type: Input }], fileName: [{ type: Input }] }); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaucaDataGridComponent, { className: "CaucaDataGridComponent", filePath: "lib/cauca-data-grid/cauca-data-grid.component.ts", lineNumber: 23 }); })(); class CaucaDateBoxComponent extends DxDateBoxComponent { constructor(element, ngZone, templateHost, watcherHelper, idh, optionHost, transferState, platform) { super(element, ngZone, templateHost, watcherHelper, idh, optionHost, transferState, platform); this.type = 'datetime'; this.displayFormat = 'dd/MM/yyyy HH:mm'; this.openOnFieldClick = true; } ngOnInit() { super.ngOnInit(); } static { this.ɵfac = function CaucaDateBoxComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaucaDateBoxComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(i1.DxTemplateHost), i0.ɵɵdirectiveInject(i1.WatcherHelper), i0.ɵɵdirectiveInject(i1.IterableDifferHelper), i0.ɵɵdirectiveInject(i1.NestedOptionHost), i0.ɵɵdirectiveInject(i0.TransferState), i0.ɵɵdirectiveInject(i0.PlatformRef)); }; } static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaucaDateBoxComponent, selectors: [["cauca-dx-date-box"]], standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function CaucaDateBoxComponent_Template(rf, ctx) { }, encapsulation: 2 }); } } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaucaDateBoxComponent, [{ type: Component, args: [{ selector: 'cauca-dx-date-box', standalone: false, template: "" }] }], () => [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i1.DxTemplateHost }, { type: i1.WatcherHelper }, { type: i1.IterableDifferHelper }, { type: i1.NestedOptionHost }, { type: i0.TransferState }, { type: i0.PlatformRef }], null); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaucaDateBoxComponent, { className: "CaucaDateBoxComponent", filePath: "lib/cauca-date-box/cauca-date-box.component.ts", lineNumber: 16 }); })(); const _c0$1 = ["*"]; class CaucaPopupConfirmComponent { constructor(translate) { this.translate = translate; this.title = ''; this.text = ''; this.showTitle = false; this.visibleChange = new EventEmitter(); this.okClick = new EventEmitter(); this.cancelClick = new EventEmitter(); this.doneClick = new EventEmitter(); this.barItems = { ['ok']: { widget: 'dxButton', location: 'center', visible: true, options: { text: '' }, toolbar: 'bottom', parent: this, onClick: CaucaPopupConfirmComponent.onOkClick }, ['cancel']: { widget: 'dxButton', location: 'center', visible: true, options: { text: '' }, toolbar: 'bottom', parent: this, onClick: CaucaPopupConfirmComponent.onCancelClick }, ['close']: { widget: 'dxButton', location: 'center', visible: true, options: { text: '' }, toolbar: 'bottom', parent: this, onClick: CaucaPopupConfirmComponent.onCancelClick }, ['save']: { widget: 'dxButton', location: 'center', visible: true, options: { text: '' }, toolbar: 'bottom', parent: this, onClick: CaucaPopupConfirmComponent.onOkClick }, ['yes']: { widget: 'dxButton', location: 'center', visible: true, options: { text: '' }, toolbar: 'bottom', parent: this, onClick: CaucaPopupConfirmComponent.onOkClick }, ['no']: { widget: 'dxButton', location: 'center', visible: true, options: { text: '' }, toolbar: 'bottom', parent: this, onClick: CaucaPopupConfirmComponent.onCancelClick } }; this.bottomToolbarItems = [this.barItems.ok]; this.translationKeyParent = 'devextreme.popupconfirm'; this.translationKeys = ['buttonsave', 'buttonok', 'buttoncancel', 'buttonyes', 'buttonno', 'buttonclose']; this.types = { ok: 'ok', cancel: 'cancel', close: 'close', yesno: 'yesno', okcancel: 'okcancel', okclose: 'okclose', savecancel: 'savecancel' }; } set type(name) { switch (name) { case this.types.cancel: this.bottomToolbarItems = [this.barItems.cancel]; break; case this.types.close: this.bottomToolbarItems = [this.barItems.close]; break; case this.types.yesno: this.bottomToolbarItems = [this.barItems.yes, this.barItems.no]; break; case this.types.okcancel: this.bottomToolbarItems = [this.barItems.ok, this.barItems.cancel]; break; case this.types.okclose: this.bottomToolbarItems = [this.barItems.ok, this.barItems.close]; break; case this.types.savecancel: this.bottomToolbarItems = [this.barItems.save, this.barItems.cancel]; break; default: this.bottomToolbarItems = [this.barItems.ok]; break; } } static onOkClick(e) { e.itemData.parent.okClick.emit(); e.itemData.parent.doneClick.emit(true); } static onCancelClick(e) { e.itemData.parent.cancelClick.emit(); e.itemData.parent.doneClick.emit(false); } ngOnInit() { this.getTranslations(); } getTranslations() { const keys = this.translationKeys.map((key) => [this.translationKeyParent, key].join('.')); this.translate.get(keys).subscribe((translations) => { this.initBarText(translations); }); } onVisibleChange() { this.visibleChange.emit(this.visible); } initBarText(translations) { this.barItems.ok.options.text = translations[[this.translationKeyParent, 'buttonok'].join('.')]; this.barItems.cancel.options.text = translations[[this.translationKeyParent, 'buttoncancel'].join('.')]; this.barItems.save.options.text = translations[[this.translationKeyParent, 'buttonsave'].join('.')]; this.barItems.yes.options.text = translations[[this.translationKeyParent, 'buttonyes'].join('.')]; this.barItems.no.options.text = translations[[this.translationKeyParent, 'buttonno'].join('.')]; this.barItems.close.options.text = translations[[this.translationKeyParent, 'buttonclose'].join('.')]; } popupHidden() { this.visible = false; this.onVisibleChange(); } static { this.ɵfac = function CaucaPopupConfirmComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaucaPopupConfirmComponent)(i0.ɵɵdirectiveInject(i1$1.TranslateService)); }; } static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaucaPopupConfirmComponent, selectors: [["cauca-popup-confirm"]], inputs: { title: "title", text: "text", showTitle: "showTitle", visible: "visible", type: "type" }, outputs: { visibleChange: "visibleChange", okClick: "okClick", cancelClick: "cancelClick", doneClick: "doneClick" }, standalone: false, ngContentSelectors: _c0$1, decls: 5, vars: 8, consts: [["height", "auto", "width", "auto", 1, "popup", 3, "visibleChange", "onHidden", "showTitle", "title", "dragEnabled", "showCloseButton", "hideOnOutsideClick", "visible", "toolbarItems"]], template: function CaucaPopupConfirmComponent_Template(rf, ctx) { if (rf & 1) { i0.ɵɵprojectionDef(); i0.ɵɵelementStart(0, "div")(1, "dx-popup", 0); i0.ɵɵtwoWayListener("visibleChange", function CaucaPopupConfirmComponent_Template_dx_popup_visibleChange_1_listener($event) { i0.ɵɵtwoWayBindingSet(ctx.visible, $event) || (ctx.visible = $event); return $event; }); i0.ɵɵlistener("onHidden", function CaucaPopupConfirmComponent_Template_dx_popup_onHidden_1_listener() { return ctx.popupHidden(); }); i0.ɵɵelementStart(2, "div"); i0.ɵɵtext(3); i0.ɵɵelementEnd(); i0.ɵɵprojection(4); i0.ɵɵelementEnd()(); } if (rf & 2) { i0.ɵɵadvance(); i0.ɵɵproperty("showTitle", ctx.showTitle)("title", ctx.title)("dragEnabled", false)("showCloseButton", true)("hideOnOutsideClick", false); i0.ɵɵtwoWayProperty("visible", ctx.visible); i0.ɵɵproperty("toolbarItems", ctx.bottomToolbarItems); i0.ɵɵadvance(2); i0.ɵɵtextInterpolate(ctx.text); } }, dependencies: [i2$1.DxPopupComponent], encapsulation: 2 }); } } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaucaPopupConfirmComponent, [{ type: Component, args: [{ selector: 'cauca-popup-confirm', standalone: false, template: "<div>\n <dx-popup\n class=\"popup\"\n [showTitle]=\"showTitle\"\n [title]=\"title\"\n height=\"auto\"\n width=\"auto\"\n [dragEnabled]=\"false\"\n [showCloseButton]=\"true\"\n [hideOnOutsideClick]=\"false\"\n [(visible)]=\"visible\"\n [toolbarItems]=\"bottomToolbarItems\"\n (onHidden)=\"popupHidden()\">\n <div>{{text}}</div>\n <ng-content></ng-content>\n </dx-popup>\n</div>\n" }] }], () => [{ type: i1$1.TranslateService }], { title: [{ type: Input }], text: [{ type: Input }], showTitle: [{ type: Input }], visible: [{ type: Input }], visibleChange: [{ type: Output }], okClick: [{ type: Output }], cancelClick: [{ type: Output }], doneClick: [{ type: Output }], type: [{ type: Input }] }); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaucaPopupConfirmComponent, { className: "CaucaPopupConfirmComponent", filePath: "lib/cauca-popup-confirm/cauca-popup-confirm.component.ts", lineNumber: 10 }); })(); class CaucaPopupEditCancelEvent { constructor(caucaPopupEditComponent) { this.caucaPopupEditComponent = caucaPopupEditComponent; } cancel() { this.caucaPopupEditComponent.cancelSave(); } } const _c0 = ["*"]; class CaucaPopupEditComponent { constructor(translateService) { this.translateService = translateService; this.types = { savecancel: 'savecancel', okcancel: 'okcancel' }; this.title = input(''); this.visible = model(true); this.visibleChange = new EventEmitter(); this.popupShowing = new EventEmitter(); this.popupShown = new EventEmitter(); this.save = new EventEmitter(); this.translationKeyParent = 'devextreme.popupedit'; this.translationKeys = ['buttonsave', 'buttonok', 'buttoncancel']; this.canSaveState = true; this.isSaving = false; this.barItems = { ['ok']: { widget: 'dxButton', location: 'after', visible: true, options: { text: '', disabled: false, onInitialized: (ev) => { this.okButtonComponent = ev.component; }, onClick: (_ev) => { this.saveButtonClick(); }, }, toolbar: 'bottom', }, ['save']: { widget: 'dxButton', location: 'after', visible: true, options: { text: '', disabled: false, onInitialized: (ev) => { this.saveButtonComponent = ev.component; }, onClick: (_ev) => { this.saveButtonClick(); }, }, toolbar: 'bottom', }, ['cancel']: { widget: 'dxButton', location: 'after', visible: true, options: { text: '', disabled: false, onClick: (_ev) => { this.cancelButtonClick(); }, }, toolbar: 'bottom', } }; this.bottomToolbarItems = [this.barItems['save'], this.barItems['cancel']]; this.cancelEvent = new CaucaPopupEditCancelEvent(this); } get canSave() { return this.canSaveState; } set canSave(value) { this.canSaveState = value; this.updateButtonDisabledState(); } set type(name) { switch (name) { case this.types.okcancel: this.bottomToolbarItems = [this.barItems.ok, this.barItems.cancel]; break; default: this.bottomToolbarItems = [this.barItems.save, this.barItems.cancel]; break; } } ngOnInit() { this.getTranslations(); } getTranslations() { const keys = this.translationKeys.map((key) => `${this.translationKeyParent}.${key}`); this.translateService.get(keys).subscribe((translations) => { this.initBarText(translations); }); } onHidden() { this.isSaving = false; this.updateButtonDisabledState(); this.visible.set(false); this.emitVisibleChange(); } onShowing(e) { this.updateButtonDisabledState(); this.emitVisibleChange(); this.popupShowing.emit(e); } onShown(e) { this.popupShown.emit(e); } cancelSave() { this.isSaving = false; this.updateButtonDisabledState(); } emitVisibleChange() { this.visibleChange.emit(this.visible()); } initBarText(translations) { this.barItems.save.options.text = translations[`${this.translationKeyParent}.buttonsave`]; this.barItems.ok.options.text = translations[`${this.translationKeyParent}.buttonok`]; this.barItems.cancel.options.text = translations[`${this.translationKeyParent}.buttoncancel`]; } saveButtonClick() { this.isSaving = true; this.updateButtonDisabledState(); this.save.emit(this.cancelEvent); } cancelButtonClick() { this.visible.set(false); } saveButtonDisabledState() { return !this.canSave || this.isSaving; } updateButtonDisabledState() { if (this.okButtonComponent) { this.okButtonComponent.option('disabled', this.saveButtonDisabledState()); } if (this.saveButtonComponent) { this.saveButtonComponent.option('disabled', this.saveButtonDisabledState()); } } static { this.ɵfac = function CaucaPopupEditComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaucaPopupEditComponent)(i0.ɵɵdirectiveInject(i1$1.TranslateService)); }; } static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaucaPopupEditComponent, selectors: [["cauca-popup-edit"]], viewQuery: function CaucaPopupEditComponent_Query(rf, ctx) { if (rf & 1) { i0.ɵɵviewQuery(DxPopupComponent, 5); } if (rf & 2) { let _t; i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.popup = _t.first); } }, inputs: { title: [1, "title"], visible: [1, "visible"], canSave: "canSave", type: "type" }, outputs: { visible: "visibleChange", visibleChange: "visibleChange", popupShowing: "popupShowing", popupShown: "popupShown", save: "save" }, standalone: false, ngContentSelectors: _c0, decls: 2, vars: 7, consts: [[1, "popup", 3, "visibleChange", "onHidden", "onShowing", "onShown", "showTitle", "title", "dragEnabled", "showCloseButton", "hideOnOutsideClick", "visible", "toolbarItems"]], template: function CaucaPopupEditComponent_Template(rf, ctx) { if (rf & 1) { i0.ɵɵprojectionDef(); i0.ɵɵelementStart(0, "dx-popup", 0); i0.ɵɵtwoWayListener("visibleChange", function CaucaPopupEditComponent_Template_dx_popup_visibleChange_0_listener($event) { i0.ɵɵtwoWayBindingSet(ctx.visible, $event) || (ctx.visible = $event); return $event; }); i0.ɵɵlistener("onHidden", function CaucaPopupEditComponent_Template_dx_popup_onHidden_0_listener() { return ctx.onHidden(); })("onShowing", function CaucaPopupEditComponent_Template_dx_popup_onShowing_0_listener($event) { return ctx.onShowing($event); })("onShown", function CaucaPopupEditComponent_Template_dx_popup_onShown_0_listener($event) { return ctx.onShown($event); }); i0.ɵɵprojection(1); i0.ɵɵelementEnd(); } if (rf & 2) { i0.ɵɵproperty("showTitle", true)("title", ctx.title)("dragEnabled", false)("showCloseButton", true)("hideOnOutsideClick", false); i0.ɵɵtwoWayProperty("visible", ctx.visible); i0.ɵɵproperty("toolbarItems", ctx.bottomToolbarItems); } }, dependencies: [i2$1.DxPopupComponent], encapsulation: 2 }); } } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaucaPopupEditComponent, [{ type: Component, args: [{ selector: 'cauca-popup-edit', standalone: false, template: "<dx-popup\n class=\"popup\"\n [showTitle]=\"true\"\n [title]=\"title\"\n [dragEnabled]=\"false\"\n [showCloseButton]=\"true\"\n [hideOnOutsideClick]=\"false\"\n [(visible)]=\"visible\"\n [toolbarItems]=\"bottomToolbarItems\"\n (onHidden)=\"onHidden()\"\n (onShowing)=\"onShowing($event)\"\n (onShown)=\"onShown($event)\"\n >\n <ng-content></ng-content>\n</dx-popup>\n" }] }], () => [{ type: i1$1.TranslateService }], { visibleChange: [{ type: Output }], popupShowing: [{ type: Output }], popupShown: [{ type: Output }], save: [{ type: Output }], popup: [{ type: ViewChild, args: [DxPopupComponent] }], canSave: [{ type: Input }], type: [{ type: Input }] }); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaucaPopupEditComponent, { className: "CaucaPopupEditComponent", filePath: "lib/cauca-popup-edit/cauca-popup-edit.component.ts", lineNumber: 12 }); })(); function CaucaTextAreaLimitedComponent_span_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "span"); i0.ɵɵtext(1); i0.ɵɵpipe(2, "translate"); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵtextInterpolate2("", i0.ɵɵpipeBind1(2, 2, "devextreme.numberOfSms"), " : ", ctx_r0.getNumberOfSms(), ""); } } function CaucaTextAreaLimitedComponent_span_3_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "span"); i0.ɵɵtext(1); i0.ɵɵpipe(2, "translate"); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵtextInterpolate2("", i0.ɵɵpipeBind1(2, 2, "devextreme.numberOfChar"), " : ", ctx_r0.getNumberOfChar(), ""); } } function CaucaTextAreaLimitedComponent_div_4_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div"); i0.ɵɵtext(1); i0.ɵɵpipe(2, "translate"); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵclassProp("replaceChars", ctx_r0.charsToReplace.length > 0)("avoidChars", ctx_r0.charsToAvoid.length > 0); i0.ɵɵadvance(); i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 5, "devextreme.usingCharactersThatCanMakeCountBigger"), "\n"); } } function CaucaTextAreaLimitedComponent_div_5_span_3_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "span"); i0.ɵɵtext(1); i0.ɵɵelementStart(2, "strong"); i0.ɵɵtext(3); i0.ɵɵelementEnd()(); } if (rf & 2) { const char_r2 = ctx.$implicit; const i_r3 = ctx.index; i0.ɵɵadvance(); i0.ɵɵtextInterpolate(i_r3 > 0 ? ", " : ""); i0.ɵɵadvance(2); i0.ɵɵtextInterpolate(char_r2); } } function CaucaTextAreaLimitedComponent_div_5_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 6); i0.ɵɵtext(1); i0.ɵɵpipe(2, "translate"); i0.ɵɵtemplate(3, CaucaTextAreaLimitedComponent_div_5_span_3_Template, 4, 2, "span", 7); i0.ɵɵtext(4, ".\n"); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, "devextreme.youShouldReplaceTheFollowingCharacters"), ": "); i0.ɵɵadvance(2); i0.ɵɵproperty("ngForOf", ctx_r0.charsToReplace); } } function CaucaTextAreaLimitedComponent_div_6_span_3_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "span"); i0.ɵɵtext(1); i0.ɵɵelementStart(2, "strong"); i0.ɵɵtext(3); i0.ɵɵelementEnd()(); } if (rf & 2) { const char_r4 = ctx.$implicit; const i_r5 = ctx.index; i0.ɵɵadvance(); i0.ɵɵtextInterpolate(i_r5 > 0 ? ", " : ""); i0.ɵɵadvance(2); i0.ɵɵtextInterpolate(char_r4); } } function CaucaTextAreaLimitedComponent_div_6_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div", 8); i0.ɵɵtext(1); i0.ɵɵpipe(2, "translate"); i0.ɵɵtemplate(3, CaucaTextAreaLimitedComponent_div_6_span_3_Template, 4, 2, "span", 7); i0.ɵɵtext(4, ".\n"); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r0 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, "devextreme.youShouldAvoidTheFollowingCharacters"), ": "); i0.ɵɵadvance(2); i0.ɵɵproperty("ngForOf", ctx_r0.charsToAvoid); } } class CaucaTextAreaLimitedComponent { constructor() { this.value = ''; this.maxChar = 225; this.format = 'text'; this.valueChanged = new EventEmitter(); this.charsToAvoid = []; this.charsToReplace = []; this.replaceChars = { // eslint-disable-next-line @typescript-eslint/naming-convention â: 'a', Â: 'A', // eslint-disable-next-line @typescript-eslint/naming-convention ê: 'e', ë: 'e', Ê: 'E', Ë: 'E', // eslint-disable-next-line @typescript-eslint/naming-convention ï: 'i', Ï: 'I', // eslint-disable-next-line @typescript-eslint/naming-convention û: 'u', Û: 'U', // eslint-disable-next-line @typescript-eslint/naming-convention ç: 'c', '’': '\'', '`': '"', '“': '"', '”': '"', '~': '-', '¬': '-', '|': '-' }; // eslint-disable-next-line max-len this.gsm7bitChars = '@£$¥èéùìòÇ\\nØø\\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\\"#¤%&\'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà'; this.gsm7bitCharsExt = '\\^{}\\\\\\[~\\]|€'; this.gsm7bitRegExp = RegExp('^[' + this.gsm7bitChars + ']*$'); this.gsm7bitExtRegExp = RegExp('^[' + this.gsm7bitChars + this.gsm7bitCharsExt + ']*$'); this.gsm7bitExtOnlyRegExp = RegExp('^[' + this.gsm7bitCharsExt + ']*$'); this.messageLength = { // eslint-disable-next-line @typescript-eslint/naming-convention GSM7: 160, // eslint-disable-next-line @typescript-eslint/naming-convention GSM7ext: 160, // eslint-disable-next-line @typescript-eslint/naming-convention UTF16: 70 }; this.multiMessageLength = { // eslint-disable-next-line @typescript-eslint/naming-convention GSM7: 153, // eslint-disable-next-line @typescript-eslint/naming-convention GSM7ext: 153, // eslint-disable-next-line @typescript-eslint/naming-convention UTF16: 67 }; } ngOnInit() { if (this.format === 'sms') { this.maxChar = 0; } } changed(e) { this.value = e.value; this.valueChanged.emit(e); } getNumberOfSms() { if (!this.value) { return 0; } const length = this.countSmsChars(this.value); const charset = this.getCharset(this.value); const perMessage = (length > this.messageLength[charset] ? this.multiMessageLength[charset] : this.messageLength[charset]); this.listUTF16Chars(); return Math.ceil(length / perMessage); } getNumberOfChar() { return `${this.value ? this.value.length : 0}/${this.maxChar}`; } listUTF16Chars() { const charToAvoidOrReplace = this.value.replace(new RegExp('([' + this.gsm7bitChars + ']+)', 'g'), ''); const charToReplace = charToAvoidOrReplace.replace(new RegExp('([' + this.gsm7bitCharsExt + ']+)', 'g'), ''); const charToAvoid = charToAvoidOrReplace.match(new RegExp('([' + this.gsm7bitCharsExt + ']+)', 'g')); this.charsToAvoid = charToAvoid || []; this.charsToReplace = charToReplace ? charToReplace.split('') : []; } countSmsChars(text) { let length = text.length; const charset = this.getCharset(text); if (charset === 'GSM7ext') { length += this.countGsm7bitExt(text); } return length; } countGsm7bitExt(text) { let char2; const chars = () => { let _i; let _len; const _results = []; for (_i = 0, _len = text.length; _i < _len; _i++) { char2 = text[_i]; if (char2.match(this.gsm7bitExtOnlyRegExp) != null) { _results.push(char2); } } return _results; }; return chars.length; } getCharset(text) { switch (false) { case text.match(this.gsm7bitRegExp) == null: return 'GSM7'; case text.match(this.gsm7bitExtRegExp) == null: return 'GSM7ext'; default: return 'UTF16'; } } static { this.ɵfac = function CaucaTextAreaLimitedComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaucaTextAreaLimitedComponent)(); }; } static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaucaTextAreaLimitedComponent, selectors: [["cauca-dx-text-area-limited"]], viewQuery: function CaucaTextAreaLimitedComponent_Query(rf, ctx) { if (rf & 1) { i0.ɵɵviewQuery(DxTextAreaComponent, 5); } if (rf & 2) { let _t; i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.textarea = _t.first); } }, inputs: { value: "value", maxChar: "maxChar", format: "format" }, outputs: { valueChanged: "valueChanged" }, standalone: false, decls: 7, vars: 8, consts: [["minHeight", "50", "valueChangeEvent", "keyup", 3, "valueChange", "onValueChanged", "value", "maxLength", "autoResizeEnabled"], [1, "limit"], [4, "ngIf"], [3, "replaceChars", "avoidChars", 4, "ngIf"], ["class", "replaceChars", 4, "ngIf"], ["class", "avoidChars", 4, "ngIf"], [1, "replaceChars"], [4, "ngFor", "ngForOf"], [1, "avoidChars"]], template: function CaucaTextAreaLimitedComponent_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "dx-text-area", 0); i0.ɵɵtwoWayListener("valueChange", function CaucaTextAreaLimitedComponent_Template_dx_text_area_valueChange_0_listener($event) { i0.ɵɵtwoWayBindingSet(ctx.value, $event) || (ctx.value = $event); return $event; }); i0.ɵɵlistener("onValueChanged", function CaucaTextAreaLimitedComponent_Template_dx_text_area_onValueChanged_0_listener($event) { return ctx.changed($event); }); i0.ɵɵelementEnd(); i0.ɵɵelementStart(1, "div", 1); i0.ɵɵtemplate(2, CaucaTextAreaLimitedComponent_span_2_Template, 3, 4, "span", 2)(3, CaucaTextAreaLimitedComponent_span_3_Template, 3, 4, "span", 2); i0.ɵɵelementEnd(); i0.ɵɵtemplate(4, CaucaTextAreaLimitedComponent_div_4_Template, 3, 7, "div", 3)(5, CaucaTextAreaLimitedComponent_div_5_Template, 5, 4, "div", 4)(6, CaucaTextAreaLimitedComponent_div_6_Template, 5, 4, "div", 5); } if (rf & 2) { i0.ɵɵtwoWayProperty("value", ctx.value); i0.ɵɵproperty("maxLength", ctx.maxChar)("autoResizeEnabled", true); i0.ɵɵadvance(2); i0.ɵɵproperty("ngIf", ctx.format === "sms"); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx.format === "text"); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx.format === "sms" && (ctx.charsToAvoid.length > 0 || ctx.charsToReplace.length > 0)); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx.format === "sms" && ctx.charsToReplace.length > 0); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx.format === "sms" && ctx.charsToAvoid.length > 0); } }, dependencies: [i2.NgForOf, i2.NgIf, i2$2.DxTextAreaComponent, i3.TranslatePipe], styles: ["[_nghost-%COMP%]{clear:both}.limit[_ngcontent-%COMP%]{font-size:.9em;font-weight:700;float:right}.avoidChars[_ngcontent-%COMP%]{color:orange}.replaceChars[_ngcontent-%COMP%]{color:#d9534f}"] }); } } (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaucaTextAreaLimitedComponent, [{ type: Component, args: [{ selector: 'cauca-dx-text-area-limited', standalone: false, template: "<dx-text-area\n [(value)]=\"value\"\n [maxLength]=\"maxChar\"\n minHeight=\"50\"\n valueChangeEvent=\"keyup\"\n [autoResizeEnabled]=\"true\"\n (onValueChanged)=\"changed($event)\">\n</dx-text-area>\n<div class=\"limit\">\n <span *ngIf=\"format === 'sms'\">{{'devextreme.numberOfSms' | translate}} : {{getNumberOfSms()}}</span>\n <span *ngIf=\"format === 'text'\">{{'devextreme.numberOfChar' | translate}} : {{getNumberOfChar()}}</span>\n</div>\n<div *ngIf=\"format === 'sms' && (charsToAvoid.length > 0 || charsToReplace.length > 0)\" [class.replaceChars]=\"charsToReplace.length > 0\" [class.avoidChars]=\"charsToAvoid.length > 0\">\n {{'devextreme.usingCharactersThatCanMakeCountBigger' | translate}}\n</div>\n<div *ngIf=\"format === 'sms' && charsToReplace.length > 0\" class=\"replaceChars\">\n {{'devextreme.youShouldReplaceTheFollowingCharacters' | translate}}:\n <span *ngFor=\"let char of charsToReplace; let i = index\">{{i > 0 ? ', ' : ''}}<strong>{{char}}</strong></span>.\n</div>\n<div *ngIf=\"format === 'sms' && charsToAvoid.length > 0\" class=\"avoidChars\">\n {{'devextreme.youShouldAvoidTheFollowingCharacters' | translate}}:\n <span *ngFor=\"let char of charsToAvoid; let i = index\">{{i > 0 ? ', ' : ''}}<strong>{{char}}</strong></span>.\n</div>", styles: [":host{clear:both}.limit{font-size:.9em;font-weight:700;float:right}.avoidChars{color:orange}.replaceChars{color:#d9534f}\n"] }] }], null, { textarea: [{ type: ViewChild, args: [DxTextAreaComponent, { static: false }] }], value: [{ type: Input }], maxChar: [{ type: Input }], format: [{ type: Input }], valueChanged: [{ type: Output }] }); })(); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaucaTextAreaLimitedComponent, { className: "CaucaTextAreaLimitedComponent", filePath: "lib/cauca-text-area-limited/cauca-text-area-limited.component.ts", lineNumber: 10 }); })(); function CaucaTextBoxMultipleLangueComponent_div_1_span_3_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "span", 3); i0.ɵɵelement(1, "i", 4); i0.ɵɵelementEnd(); } } function CaucaTextBoxMultipleLangueComponent_div_1_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div")(1, "span"); i0.ɵɵtext(2); i0.ɵɵelementEnd(); i0.ɵɵtemplate(3, CaucaTextBoxMultipleLangueComponent_div_1_span_3_Template, 2, 0, "span", 2); i0.ɵɵelementEnd(); } if (rf & 2) { const lang_r1 = ctx.$implicit; const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵclassMap(ctx_r1.isValidLang[lang_r1.languageCode] ? "" : "text-error"); i0.ɵɵadvance(); i0.ɵɵtextInterpolate(lang_r1.text); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", !ctx_r1.isValidLang[lang_r1.languageCode]); } } function CaucaTextBoxMultipleLangueComponent_div_2_div_1_dx_button_2_Template(rf, ctx) { if (rf & 1) { const _r5 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "dx-button", 8); i0.ɵɵpipe(1, "translate"); i0.ɵɵlistener("click", function CaucaTextBoxMultipleLangueComponent_div_2_div_1_dx_button_2_Template_dx_button_click_0_listener() { i0.ɵɵrestoreView(_r5); const lang_r4 = i0.ɵɵnextContext(2).$implicit; const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.autoTranslateClicked(lang_r4.languageCode, ctx_r1.value[ctx_r1.getLocalizationIndex(lang_r4.languageCode)][ctx_r1.localizationField])); }); i0.ɵɵelementEnd(); } if (rf & 2) { i0.ɵɵproperty("text", i0.ɵɵpipeBind1(1, 1, "devextreme.autoTranslate")); } } function CaucaTextBoxMultipleLangueComponent_div_2_div_1_Template(rf, ctx) { if (rf & 1) { const _r3 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "div")(1, "dx-text-box", 6); i0.ɵɵtwoWayListener("valueChange", function CaucaTextBoxMultipleLangueComponent_div_2_div_1_Template_dx_text_box_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r3); const lang_r4 = i0.ɵɵnextContext().$implicit; const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵtwoWayBindingSet(ctx_r1.value[ctx_r1.getLocalizationIndex(lang_r4.languageCode)][ctx_r1.localizationField], $event) || (ctx_r1.value[ctx_r1.getLocalizationIndex(lang_r4.languageCode)][ctx_r1.localizationField] = $event); return i0.ɵɵresetView($event); }); i0.ɵɵlistener("onValueChanged", function CaucaTextBoxMultipleLangueComponent_div_2_div_1_Template_dx_text_box_onValueChanged_1_listener() { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.onValueChanged()); }); i0.ɵɵelementEnd(); i0.ɵɵtemplate(2, CaucaTextBoxMultipleLangueComponent_div_2_div_1_dx_button_2_Template, 2, 3, "dx-button", 7); i0.ɵɵelementEnd(); } if (rf & 2) { const lang_r4 = i0.ɵɵnextContext().$implicit; const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵproperty("maxLength", ctx_r1.maxLength)("placeholder", lang_r4.text); i0.ɵɵtwoWayProperty("value", ctx_r1.value[ctx_r1.getLocalizationIndex(lang_r4.languageCode)][ctx_r1.localizationField]); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx_r1.hasAutoTranslateEvent); } } function CaucaTextBoxMultipleLangueComponent_div_2_div_2_dx_button_2_Template(rf, ctx) { if (rf & 1) { const _r7 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "dx-button", 8); i0.ɵɵpipe(1, "translate"); i0.ɵɵlistener("click", function CaucaTextBoxMultipleLangueComponent_div_2_div_2_dx_button_2_Template_dx_button_click_0_listener() { i0.ɵɵrestoreView(_r7); const lang_r4 = i0.ɵɵnextContext(2).$implicit; const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.autoTranslateClicked(lang_r4.languageCode, ctx_r1.value[lang_r4.languageCode])); }); i0.ɵɵelementEnd(); } if (rf & 2) { i0.ɵɵproperty("text", i0.ɵɵpipeBind1(1, 1, "devextreme.autoTranslate")); } } function CaucaTextBoxMultipleLangueComponent_div_2_div_2_Template(rf, ctx) { if (rf & 1) { const _r6 = i0.ɵɵgetCurrentView(); i0.ɵɵelementStart(0, "div")(1, "dx-text-box", 6); i0.ɵɵtwoWayListener("valueChange", function CaucaTextBoxMultipleLangueComponent_div_2_div_2_Template_dx_text_box_valueChange_1_listener($event) { i0.ɵɵrestoreView(_r6); const lang_r4 = i0.ɵɵnextContext().$implicit; const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵtwoWayBindingSet(ctx_r1.value[lang_r4.languageCode], $event) || (ctx_r1.value[lang_r4.languageCode] = $event); return i0.ɵɵresetView($event); }); i0.ɵɵlistener("onValueChanged", function CaucaTextBoxMultipleLangueComponent_div_2_div_2_Template_dx_text_box_onValueChanged_1_listener() { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.onValueChanged()); }); i0.ɵɵelementEnd(); i0.ɵɵtemplate(2, CaucaTextBoxMultipleLangueComponent_div_2_div_2_dx_button_2_Template, 2, 3, "dx-button", 7); i0.ɵɵelementEnd(); } if (rf & 2) { const lang_r4 = i0.ɵɵnextContext().$implicit; const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵproperty("maxLength", ctx_r1.maxLength)("placeholder", lang_r4.text); i0.ɵɵtwoWayProperty("value", ctx_r1.value[lang_r4.languageCode]); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx_r1.hasAutoTranslateEvent); } } function CaucaTextBoxMultipleLangueComponent_div_2_Template(rf, ctx) { if (rf & 1) { i0.ɵɵelementStart(0, "div"); i0.ɵɵtemplate(1, CaucaTextBoxMultipleLangueComponent_div_2_div_1_Template, 3, 4, "div", 5)(2, CaucaTextBoxMultipleLangueComponent_div_2_div_2_Template, 3, 4, "div", 5); i0.ɵɵelementEnd(); } if (rf & 2) { const ctx_r1 = i0.ɵɵnextContext(); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", ctx_r1.localizationField); i0.ɵɵadvance(); i0.ɵɵproperty("ngIf", !ctx_r1.localizationField); } } class CaucaTextBoxMultipleLangueComponent { constructor(coreService, translate) { this.translate = translate; this.valueChange = new EventEmitter(); this.autoTranslate = new EventEmitter(); this.maxLength = null; this.availableLanguages = []; this.isValid = true; this.isValidLang = {}; this.tabs = []; this.selectedIndex = 0; this.hasAutoTranslateEvent = false; this.values = []; this.validation = { isRequired: false }; this.config = coreService.getConfig(); } get isRequired() { return this.validation.isRequired; } set isRequired(value) { this.validation.isRequired = value; this.validate(); } get value() { return this.values; } set value(value) { this.values = []; if (typeof (value) === 'string' || typeof (value) === 'undefined') { for (const i of this.config.languages) { const valueLang = {}; valueLang['languageCode'] = i; valueLang[this.localizationField] = value || ''; this.values.push(valueLang); } } else if (typeof (value) === 'object') { this.values = value; } } ngOnInit() { this.initializeLanguages(); this.hasAutoTranslateEvent = this.autoTranslate.observed; } getLocalizationIndex(languageCode) { const index = this.values.findIndex((l) => l.languageCode === languageCode); if (index === -1) { const value = {}; value['languageCode'] = languageCode; value[this.localizationField] = ''; this.values.push(value); return this.values.length - 1; } return index; } validate() { let isValid = true; this.config.languages.forEach((lang) => { if ('findIndex' in this.values) { const index = this.values.findIndex((l) => l.languageCode === lang); if (this.validation.isRequired && (index === -1 || !this.values[index][this.localizationField])) { isValid = false; this.isValidLang[lang] = false; } else { this.isValidLang[lang] = true; } } else { if (this.validation.isRequired && !this.values[lang]) { isValid = false; this.isValidLang[lang] = false; } else { this.isValidLang[lang] = true; } } }); this.isValid = isValid; } onTagChanged() { this.validate(); } onValueChanged() { if (this.values) { this.validate(); } this.valueChange.emit(this.values); } autoTranslateClicked(languageCode, text) { this.autoTranslate.emit({ languageCode, text, }); } initializeLanguages() { let languageCodes = this.config.languages; if (this.availableLanguages.length > 0) { languageCodes = this.availableLanguages; } this.translate.get(languageCodes).subscribe((labels) => { this.loadLanguageTabs(labels); }); } loadLanguageTabs(languages) { this.tabs = []; for (const i in languages) { if (languages[i]) { this.isValidLang[i] = true; this.tabs.push({ languageCode: i, text: languages[i], }); } } } static { this.ɵfac = function CaucaTextBoxMultipleLangueComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaucaTextBoxMultipleLangueCo