Telerik Forums
Kendo UI for Angular Forum
2 answers
254 views
I need to have ngModel in chip component because my list is updated from backend and accordingly I want to remove/add chips on UI. So basically every time my list is updated the chip component should show the items which are there in that list.
Maitri
Top achievements
Rank 1
Veteran
 answered on 02 Jul 2020
1 answer
161 views

Hello,

 

Using the angular material theme you can set the appearance of form controls to "outline".

As you can see in the official documentation here:

https://material.angular.io/components/form-field/overview

 

Under "Form field appearance variants"

 

I can't seem to find this option in kendo ui.

 

Is there any way we can style the kendo-formfield with the same look as the angular material outline appearance?

 

Kind regards,

 

Nick Vergauwen

Svet
Telerik team
 answered on 01 Jul 2020
2 answers
107 views

I am following the Rendering Item Checkboxes documentation. But I'm running into a problem where when I try to reuse the form and existing controls, the multiselect displays the correct tags and the correct items are highlighted when you open it, but the checkbox inputs are not checked.

This is my HTML:

<ng-container *ngSwitchCase="'mulitselect'">
    <kendo-multiselect [formControlName]="col.ControlName"
                       [data]="col.Extras.Data"
                       [textField]="col.Extras.TextField"
                       [valueField]="col.Extras.ValueField"
                       [valuePrimitive]="true"
                       [autoClose]="false">
        <ng-template kendoMultiSelectItemTemplate
                     let-dataItem>
            <input type="checkbox"
                   class="k-checkbox"
                   [checked]="isItemSelected(col.Extras.Data, dataItem, col.Extras.ValueField)">
            <label class="k-checkbox-label">{{ dataItem[col.Extras.TextField] }}</label>
        </ng-template>
      </kendo-multiselect>
</ng-container>

 

This is my isItemSelected method:

isItemSelected(data: any, dataItem: any, valueField) {
    return data.indexOf(item => item[valueField] === dataItem[valueField]) > -1;
}

 

This how I'm reusing the form, where control named Foo represents the multiselect:

showEditForm(record?: ITestInterface) {
    this.form.disable();
    this.form.reset(record); // Patch in new value
 
    if (record) {
        this.form.get('Foo').setValue([1, 3]);
    }
}

 

Attached is a screenshot demonstrating what I mean.

Georgi
Telerik team
 answered on 30 Jun 2020
3 answers
320 views

Hi Team,We are planing to use Kendo Conversation UI to provide messaging feature to the user. 

 

We have an existing application which is built in angular 8 and uses Web API for any CRUD operation which is written in C#. 

Here, I am looking for some code sample / snippet / example which can explain how a user can participate in chat sessions with other users (not with any bot etc.) 

and would like to see how the message will be send to another user in a chat session or how the message will broadcast to multiple users.

Any help in this regard will be very much appreciated.

Regards,

Mahesh

Dimiter Topalov
Telerik team
 answered on 30 Jun 2020
9 answers
1.7K+ views

I tried adding a class to the kendo-dropdownlist but it does not seem to do anything.

.hide-overflow {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  max-width: 99%;
}

 

<kendo-dropdownlist [class]="'hide-overflow'".... 

 

What is best way to show ellipses or alternately do word wrap?

 

 

 

Steven
Top achievements
Rank 1
 answered on 29 Jun 2020
1 answer
972 views

I have created a light and dark theme from the kendo theme builder tool. I would like to switch the themes on the fly in my angular app. I managed to do that, however, the charts dont seem to like the new theme. Other controls seem to work fine.  I am switching href of the link tag on the fly. Below is a snippet of the code I used.

 

@Component({
  selector: 'css-loader',
  template: `<link rel="stylesheet" type="text/css" [href]="path" />`,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CssLoaderComponent {
  public theme: string = environment.theme;
  cssPath: any;
  constructor(
    public sanitizer: DomSanitizer,
    private themeService: SidenavService,
    private cd: ChangeDetectorRef,
    private router: Router
  ) {

    this.themeService.toggleState$.subscribe((val) => {
      this.theme = this.theme === 'light-theme' ? 'dark-theme' : 'light-theme';
      this.cssPath = `assets/themes/${this.theme}/${this.theme}.css`;
      this.cd.markForCheck();
    });
  }
  set path(path) {
    this.cssPath = path;
  }
  get path() {
    return this.sanitizer.bypassSecurityTrustResourceUrl(this.cssPath);
  }
}

Dimiter Topalov
Telerik team
 answered on 29 Jun 2020
1 answer
629 views

Can I group the grid with Date, but ignore the time part?

 

 

 

Dimiter Topalov
Telerik team
 answered on 29 Jun 2020
1 answer
219 views

Hi,

how can I localize (change language) my scheduler in AngularJS?

On the page I found only a solution for jQuery.

 

Nencho
Telerik team
 answered on 29 Jun 2020
5 answers
879 views

I want to edit the Kendo Pager Info such that the items counts is properly represented by its locale. Ex. 1025 ---> 1,025

Here's the approach I did:

I converted the total of the PagerInfoComponent from number to any, and applied this to a lifecycle hook:

this.pagerInfoComponent.total = this.pagerInfoComponent.total.toLocaleString();
this.pagerInfoComponent.ngOnInit();

This is causing a problem as it's resulting to this: 1 - n of 1025 items.

Another way I could do this is to directly edit it via DOM, but then I would have to update the values constantly for any change I make in a grid.

How can I properly best approach this? Please see link here: https://stackblitz.com/edit/angular-mejm68

Thanks in advance!

Charles
Top achievements
Rank 1
Veteran
 answered on 26 Jun 2020
1 answer
128 views

I'm trying to use Kendo Angular Upload but when I check the data being sent to the server in Google Chrome DevTools, the property rawFile, which I beleive is the one responsible to actually retrieve the file data, is always empty as the attachment indicates.

Here's my HTML:

<form class='content' novalidate [formGroup]="edicaoForm">
    <div class="k-i-loading" *ngIf="loading"></div>
    <div class="row"></div>
 
    <div class="clear-fix mt-4"></div>
    <div class="row">
        <div class="col-sm-12">
            <div class="col-sm-4 pull-left">
                <label [for]="logomarca">Logo</label>
                <kendo-uploaddropzone zoneId="myZone">Somente arquivos do tipo JPG, JPEG, PNG e SVG são permitidos.</kendo-uploaddropzone>
                <kendo-upload zoneId="myZone" [saveField]="logomarca" [saveUrl]="uploadLogoURL" [chunkable]="false" [restrictions]="restrictions" #logomarca [multiple]="false" [autoUpload]="true" formControlName="logomarca" ngDefaultControl>
                    <kendo-upload-messages select="Selecionar arquivo" uploadSelectedFiles="Enviar arquivo" clearSelectedFiles="Cancelar seleção de arquivo"
                        dropFilesHere="Solte arquivos aqui para carregar" invalidFileExtension="Tipo de arquivo não permitido." remove="Remover" cancel="Cancelar"
                        fileStatusUploaded="Arquivo carregado com sucesso." externalDropFilesHere="Arraste e solte arquivos aqui para carregar" resume="Concluir" pause="Pausar"
                        headerStatusUploaded="Concluído" headerStatusUploading="Carregando..." headerStatusPaused="Pausado" fileStatusFailed="Falha ao carregar arquivo."></kendo-upload-messages>
                </kendo-upload>
            </div>
 
            <div class="row">
                <div class="col-sm-6"
                    [ngClass]="{'has-error': displayMessages.empresaId }">
                    <label>Empresa</label>
                    <div>
                        <kendo-combobox [data]="empresasData" [allowCustom]="false" [placeholder]="'Empresa'" [textField]="'nomeFantasia'" [valueField]="'gid'"
                            [filterable]="true" class="w-100" formControlName="empresaId" (filterChange)="empresaHandleFilter($event)" (open)="empresaHandleOpen()" required
                            [suggest]="true" [valuePrimitive]="true" (blur)="blur('empresaId')"></kendo-combobox>
                        <span class="text-danger" *ngIf="displayMessages.empresaId">
                            <p [innerHTML]="displayMessages.empresaId"></p>
                        </span>
                    </div>
                </div>
 
                <div class="col-sm-6"
                    [ngClass]="{'has-error': displayMessages.codigo }">
                    <label>Código</label>
                    <div>
                        <input kendoTextBox [placeholder]="'Código'" maxlength="30" class="w-100" formControlName="codigo" />
                        <span class="text-danger" *ngIf="displayMessages.codigo">
                            <p [innerHTML]="displayMessages.codigo"></p>
                        </span>
                    </div>
                </div>
            </div>
 
            <div class="clear-fix mt-4"></div>
 
            <div class="row">
                <div class="col-sm-6" [ngClass]="{'has-error': displayMessages.descricao }">
                    <label>Descrição</label>
                    <div>
                        <input kendoTextBox [placeholder]="'Descrição'" class="w-100" formControlName="descricao" />
                        <span class="text-danger" *ngIf="displayMessages.descricao">
                            <p [innerHTML]="displayMessages.descricao"></p>
                        </span>
                    </div>
                </div>
 
                <div class="col-sm-6" [ngClass]="{'has-error': displayMessages.nomeFantasia }">
                    <label>Nome Fantasia</label>
                    <div>
                        <input kendoTextBox [placeholder]="'Nome Fantasia'" class="w-100" formControlName="nomeFantasia" />
                        <span class="text-danger" *ngIf="displayMessages.nomeFantasia">
                            <p [innerHTML]="displayMessages.nomeFantasia"></p>
                        </span>
                    </div>
                </div>
            </div>
 
            <div class="clear-fix mt-4"></div>
 
            <div class="row">
                <div class="col-sm-6 pull-left" [ngClass]="{'has-error': displayMessages.tipoIdentificacao }">
                    <label>Tipo de identificação</label>
                    <kendo-combobox [data]="tiposDeIdentificacao" [allowCustom]="false" [placeholder]="'Tipo de Identificação'" [textField]="'descricao'"
                        [valueField]="'valor'" [filterable]="true" class="w-100" [valuePrimitive]="true" formControlName="tipoIdentificacao"
                        (blur)="blur('tipoIdentificacao')"></kendo-combobox>
                    <span class="text-danger" *ngIf="displayMessages.tipoIdentificacao">
                        <p [innerHTML]="displayMessages.tipoIdentificacao"></p>
                    </span>
                </div>
 
                <div class="col-sm-6 pull-left" [ngClass]="{'has-error': displayMessages.numeroDocumento }">
                    <label>Número Documento</label>
                    <div>
                        <input kendoTextBox [placeholder]="'Número Documento'" maxlength="18" class="w-100" (keyup)="maskInputCpfCnpj()" formControlName="numeroDocumento" />
                        <span class="text-danger" *ngIf="displayMessages.numeroDocumento">
                            <p [innerHTML]="displayMessages.numeroDocumento"></p>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
 
    <div class="clear-fix mt-4"></div>
 
    <div class="row">
        <div class="col-sm-12">
            <div class="col-sm-4 pull-left"
                [ngClass]="{'has-error': displayMessages.inscricaoMunicipal }">
                <label>Inscrição Municipal</label>
                <div>
                    <input kendoTextBox [placeholder]="'Inscrição Municipal'" maxlength="20" class="w-100" formControlName="inscricaoMunicipal" />
                    <span class="text-danger" *ngIf="displayMessages.inscricaoMunicipal">
                        <p [innerHTML]="displayMessages.inscricaoMunicipal"></p>
                    </span>
                </div>
            </div>
 
            <div class="col-sm-4 pull-left" [ngClass]="{'has-error': displayMessages.inscricaoEstadual }">
                <label>Inscrição Estadual</label>
                <div>
                    <input kendoTextBox [placeholder]="'Inscrição Estadual'" maxlength="20" class="w-100" formControlName="inscricaoEstadual" />
                    <span class="text-danger" *ngIf="displayMessages.inscricaoEstadual">
                        <p [innerHTML]="displayMessages.inscricaoEstadual"></p>
                    </span>
                </div>
            </div>
 
            <div class="col-sm-4 pull-left" [ngClass]="{'has-error': displayMessages.cnaeId }">
                <label>CNAE</label>
                <div>
                    <kendo-combobox [data]="cnaesData" [allowCustom]="false" [placeholder]="'CNAE'" [textField]="'descricao'" [valueField]="'gid'" [filterable]="true"
                        (filterChange)="cnaeHandleFilter($event)" (open)="cnaeHandleOpen()" [suggest]="true" class="w-100" formControlName="cnaeId" [valuePrimitive]="true"
                        (blur)="blur('cnaeId')"></kendo-combobox>
                    <span class="text-danger" *ngIf="displayMessages.cnaeId">
                        <p [innerHTML]="displayMessages.cnaeId"></p>
                    </span>
                </div>
            </div>
        </div>
    </div>
 
    <div class="clear-fix mt-4"></div>
    <div class="row">
        <div class="col-sm-12">
            <div class="col-sm-4 pull-left" [ngClass]="{'has-error': displayMessages.email }">
                <label>E-mail</label>
                <div>
                    <input kendoTextBox [placeholder]="'E-mail'" class="w-100" formControlName="email" />
                    <span class="text-danger" *ngIf="displayMessages.email">
                        <p [innerHTML]="displayMessages.email"></p>
                    </span>
                </div>
            </div>
 
            <div class="col-sm-4 pull-left" [ngClass]="{'has-error': displayMessages.site }">
                <label>Site</label>
                <div>
                    <input kendoTextBox [placeholder]="'Site'" class="w-100" formControlName="site" />
                    <span class="text-danger" *ngIf="displayMessages.site">
                        <p [innerHTML]="displayMessages.site"></p>
                    </span>
                </div>
            </div>
 
            <div class="col-sm-4 pull-left" [ngClass]="{'has-error': displayMessages.dataRegistro }">
                <label>Data Registro</label>
                <div>
                    <kendo-datepicker [(value)]="dataRegistro" [placeholder]="'Data Registro'" [format]="'dd/MM/yyyy'" [navigation]="false" [weekNumber]="true" class="w-100"
                        formControlName="dataRegistro"> </kendo-datepicker>
                    <span class="text-danger" *ngIf="displayMessages.dataRegistro">
                        <p [innerHTML]="displayMessages.dataRegistro"></p>
                    </span>
                </div>
            </div>
        </div>
    </div>
 
    <div class="clear-fix mt-4"></div>
 
    <div class="row">
        <div class="col-sm-12">
            <div class="col-sm-4 pull-left">
                <div class="col-sm-6 pull-left" style="padding-left: 2px;" [ngClass]="{'has-error': displayMessages.bloqueada }">
                    <input type="checkbox" id="bloqueada" class="k-checkbox" formControlName="bloqueada" [checked]="false">
                    <label class="k-checkbox-label" for="bloqueada">Bloqueada</label>
                </div>
 
                <div class="col-sm-6 pull-left" [ngClass]="{'has-error': displayMessages.matriz }">
                    <input type="checkbox" id="matriz" class="k-checkbox" formControlName="matriz" [checked]="false">
                    <label class="k-checkbox-label" for="matriz">Matriz</label>
                </div>
            </div>
        </div>
    </div>
 
    <div class="clear-fix mt-4"></div>
 
    <div class="row">
        <div class="col-sm-12">
            <div class="col-sm-12">
                <label [for]="observacao">Observação</label>
                <kendo-textbox-container class="w-100" style="padding-top: 4px;">
                    <textarea kendoTextArea formControlName="observacao" #observacao></textarea>
                </kendo-textbox-container>
                <span class="text-danger" *ngIf="displayMessages.observacao">
                    <p [innerHTML]="displayMessages.observacao"></p>
                </span>
            </div>
        </div>
    </div>
 
    <div class="clear-fix mt-4"></div>
 
    <div class="col-sm-12 mt-2">
        <button kendoButton [icon]="'save'"
            class="pull-left btn-primary btn-sm" (click)="atualizar()" [disabled]='!edicaoForm.valid'>Salvar</button>
        <button kendoButton [icon]="'delete'" class="pull-right btn-danger btn-sm ml-1" (click)="excluir()">Excluir</button>
        <button kendoButton [icon]="'close'" class="pull-right btn-secondary btn-sm" (click)="sendFormStatus()">Fechar</button>
    </div>
</form>
 
<app-alert (alertStatus)="alertEvent($event)" [openedAlert]="openedAlert" [title]="title" [message]="message"></app-alert>

Here's my angular component:

import { Component, OnChanges, AfterViewInit, Input, Output, EventEmitter, ElementRef, ViewChildren } from '@angular/core';
import { FormGroup, FormControlName, FormBuilder, Validators } from '@angular/forms';
import { FormValidator } from '../../../utils/form-validator';
import { NotificationService } from '@progress/kendo-angular-notification';
import { IntlService } from '@progress/kendo-angular-intl';
import { EstabelecimentosService } from '../../services/estabelecimentos.service';
import { Estabelecimento } from '../../models/estabelecimento';
import { Observable, forkJoin } from 'rxjs';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/observable/merge';
import { Cnae } from '../../../cnae/models/cnae';
import { CnaeService } from '../../../cnae/services/cnae.service';
import { Empresa } from '../../../empresas/models/empresa';
import { EmpresasService } from '../../../empresas/services/empresas.service';
import { Utils } from '../../../utils/utils';
import { FileRestrictions } from '@progress/kendo-angular-upload';
import { environment } from '../../../../environments/environment';
 
@Component({
    selector: 'app-edit-estabelecimento',
    templateUrl: './edit-estabelecimento.component.html',
    styleUrls: ['../index/index-estabelecimento.component.css', './edit-estabelecimento.component.css']
})
export class EditEstabelecimentoComponent implements AfterViewInit, OnChanges {
    @Input() habilitarView: boolean;
    @Input() estabelecimentoId: string;
    @Output() formStatus = new EventEmitter<boolean>();
    @Output() editedItem = new EventEmitter<Estabelecimento>();
    public message: string = '';
    public title: string = '';
    public openedAlert: boolean = false;
    public loading: boolean = false;
    private estabelecimentoDescricao: string;
    public estabelecimento: Estabelecimento;
    public cnaesData: Cnae[] = [];
    public cnaesSource: Cnae[] = [];
    public empresasData: Empresa[] = [];
    public empresasSource: Empresa[] = [];
    edicaoForm: FormGroup;
    formValidator: FormValidator;
    validationMessages: { [key: string]: { [key: string]: string } };
    displayMessages: { [key: string]: string } = {};
    dataRegistro: any = null;
    @ViewChildren(FormControlName, { read: ElementRef }) formInputElements: ElementRef[];
    public tiposDeIdentificacao: Array<{ descricao: string, valor: number }> = [{ descricao: 'Pessoa Jurídica', valor: 1 }, { descricao: 'Pessoa Física', valor: 2 }];
    uploadLogoURL: string = `${environment.url}imagens/estabelecimento/${this.estabelecimentoId}/logo`;
 
    public restrictions: FileRestrictions = {
        allowedExtensions: ['jpg', 'jpeg', 'png', 'svg'],
        maxFileSize: 5242880
    };
 
    constructor(private readonly fb: FormBuilder,
        private readonly utils: Utils,
        private readonly empresasService: EmpresasService,
        private readonly cnaeServices: CnaeService,
        private readonly estabelecimentosService: EstabelecimentosService,
        private readonly intl: IntlService,
        private readonly notificationService: NotificationService) { }
 
    ngAfterViewInit(): void {
        let controlBlurs: Observable<any>[] = this.formInputElements
            .map((formControl: ElementRef) => Observable.fromEvent(formControl.nativeElement, 'blur'));
 
        Observable.merge(...controlBlurs).subscribe(() => {
            this.displayMessages = this.formValidator.processMessages(this.edicaoForm);
        });
    }
 
    ngOnChanges(): void {
        this.loading = true;
        this.validationMessages = {
            codigo: { required: 'Informe o código' },
            descricao: { required: 'Informe a descrição' },
            tipoIdentificacao: { required: 'Informe o tipo de identificação' },
            nomeFantasia: { required: 'Informe o nome fantasia ' },
            numeroDocumento: { required: 'Informe o número do documento' },
            inscricaoEstadual: { required: 'Informe o número de inscrição estadual' },
            inscricaoMunicipal: { required: 'Informe o número de inscrição municipal' },
            email: { required: 'Informe o email' },
            site: { required: 'Informe o site' },
            dataRegistro: { required: 'Informe a data do registro' },
            observacao: { required: 'Preencha a observação' },
            empresaId: { required: 'Informe a Empresa' },
            cnaeId: { required: '' }
        };
 
        this.edicaoForm = this.fb.group({
            codigo: ['', [Validators.required]],
            descricao: ['', [Validators.required]],
            tipoIdentificacao: [0, [Validators.required]],
            nomeFantasia: ['', [Validators.required]],
            numeroDocumento: ['', [Validators.required]],
            inscricaoEstadual: ['', []],
            inscricaoMunicipal: ['', []],
            email: ['', []],
            site: ['', []],
            bloqueada: ['', []],
            dataRegistro: ['', []],
            observacao: ['', []],
            matriz: ['', []],
            empresaId: ['', [Validators.required]],
            cnaeId: ['', []],
            logomarca: ['', []]
        });
 
        this.formValidator = new FormValidator(this.validationMessages);
 
        forkJoin(this.estabelecimentosService.getEstabelencimento(this.estabelecimentoId), this.empresasService.getAll(), this.cnaeServices.getAll()).subscribe(response => {
            this.estabelecimento = new Estabelecimento();
            this.estabelecimento.gid = this.estabelecimentoId;
 
            response[0]['data'].numeroDocumento = this.utils.convertToCpfCnpj(response[0]['data'].numeroDocumento);
            this.preencherForm(response[0]['data']);
 
            this.empresasSource = response[1]['data'];
            this.formValidator.preencherCombo(this.edicaoForm, 'empresaId', this.empresasData = response[1]['data']);
 
            this.cnaesSource = response[2]['data'];
            this.formValidator.preencherCombo(this.edicaoForm, 'cnaeId', this.cnaesData = response[2]['data']);
        });
    }
 
    preencherForm(estabelecimento: any): void {
        this.estabelecimentoDescricao = estabelecimento.descricao;
        if (estabelecimento.cnae == [] || estabelecimento.cnae == undefined || estabelecimento.cnae == null) {
            estabelecimento.cnae = Object.assign({});
        }
 
        if (!estabelecimento.logomarca) {
            estabelecimento.logomarca = Object.assign({});
        }
 
        this.edicaoForm.patchValue({
            codigo: estabelecimento.codigo,
            descricao: estabelecimento.descricao,
            tipoIdentificacao: estabelecimento.tipoIdentificacao,
            nomeFantasia: estabelecimento.nomeFantasia,
            numeroDocumento: estabelecimento.numeroDocumento,
            inscricaoEstadual: estabelecimento.inscricaoEstadual,
            inscricaoMunicipal: estabelecimento.inscricaoMunicipal,
            email: estabelecimento.email,
            site: estabelecimento.site,
            dataRegistro: this.intl.parseDate(estabelecimento.dataRegistro),
            bloqueada: estabelecimento.bloqueada,
            matriz: estabelecimento.matriz,
            observacao: estabelecimento.observacao,
            empresaId: estabelecimento.empresa.gid,
            cnaeId: estabelecimento.cnae.gid,
            logomarca: estabelecimento.logomarca
        });
 
        this.loading = false;
    }
 
    sendFormStatus() {
        this.habilitarView = false;
        this.formStatus.emit(this.habilitarView);
    }
 
    atualizar() {
        this.loading = true;
 
        if (this.edicaoForm.dirty && this.edicaoForm.valid) {
            const estabelecimento = Object.assign({}, this.estabelecimento, this.edicaoForm.value);
            if (estabelecimento.cnaeId != [] && estabelecimento.cnaeId != undefined && estabelecimento.cnaeId != null) {
                estabelecimento.cnae = new Cnae();
                estabelecimento.cnae.gid = estabelecimento.cnaeId;
            } else {
                estabelecimento.cnae = null;
            }
 
            estabelecimento.empresa = new Empresa();
            estabelecimento.empresa.gid = estabelecimento.empresaId;
            estabelecimento.numeroDocumento = this.utils.removeCaracter(estabelecimento.numeroDocumento);
            this.estabelecimentosService.atualizar(estabelecimento).subscribe(success => {
                this.onSuccess(success, 'Atualizado');
            }, error => {
                this.onError(error);
            });
        }
    }
 
    excluir() {
        this.title = 'Atenção';
        this.message = `Você deseja realmente excluir o estabelecimento "${this.estabelecimentoDescricao}"?`;
        this.openedAlert = true;
        this.loading = true;
    }
 
    alertEvent($event: boolean) {
        this.openedAlert = false;
        $event == false ? this.loading = false : true;
        if ($event == true) {
            this.estabelecimentosService.excluir(this.estabelecimentoId).subscribe(success => {
                this.onSuccess(success, 'Excluído');
                this.habilitarView = false;
                this.formStatus.emit(this.habilitarView);
            }, error => {
                this.onError(error);
            });
        }
    }
 
    onSuccess(success: any, acao: string): any {
        this.notificationService.show({
            content: `${acao} com sucesso!`,
            animation: { type: 'slide', duration: 800 },
            cssClass: 'button-notification',
            position: { horizontal: 'center', vertical: 'bottom' },
            type: { style: 'success', icon: true },
            hideAfter: 1000
        });
 
        this.editedItem.emit(success);
        this.loading = false;
    }
 
    onError(error: any): any {
        this.notificationService.show({
            content: `Ocorreu um erro: ${error.message}.`,
            animation: { type: 'slide', duration: 800 },
            cssClass: 'button-notification',
            position: { horizontal: 'center', vertical: 'bottom' },
            type: { style: 'error', icon: true },
            closable: true
        });
        this.loading = false;
    }
 
    maskInputCpfCnpj() {
        let estabelecimento = Object.assign({}, this.estabelecimento, this.edicaoForm.value);
        this.edicaoForm.patchValue({
            numeroDocumento: estabelecimento.numeroDocumento = this.utils.convertToCpfCnpj(estabelecimento.numeroDocumento)
        });
    }
 
    blur(item: string) {
        if (this.edicaoForm.controls[item].value === '' || this.edicaoForm.controls[item].value === undefined || this.edicaoForm.controls[item].value === null) {
            this.displayMessages[item] = this.validationMessages[item].required
        } else {
            delete this.displayMessages[item];
        }
    }
 
    empresaHandleOpen() {
        this.empresasData = JSON.parse(JSON.stringify(this.empresasSource));
    }
 
    empresaHandleFilter(value: string) {
        if (value) {
            this.empresasData = this.empresasSource.filter((s) => s.nomeFantasia.toLocaleLowerCase().includes(value.toLocaleLowerCase()));
        }
    }
 
    cnaeHandleOpen() {
        this.cnaesData = JSON.parse(JSON.stringify(this.cnaesSource));
    }
 
    cnaeHandleFilter(value: string) {
        if (value) {
            this.cnaesData = this.cnaesSource.filter((s) => s.codigo.toLocaleLowerCase().includes(value.toLocaleLowerCase()));
        }
    }
}
Martin Bechev
Telerik team
 answered on 24 Jun 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?