Skip to content

Commit

Permalink
v2.1.6 | Commit automático
Browse files Browse the repository at this point in the history
Commit automático realizado via script pós build
  • Loading branch information
S0lturn3 committed Oct 2, 2024
1 parent d38d06e commit d49d895
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
4 changes: 2 additions & 2 deletions projects/ngx-sp-infra/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/ngx-sp-infra/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-sp-infra",
"version": "2.1.5",
"version": "2.1.6",
"description": "Biblioteca de utilitários da Infra.",
"author": "P&D",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class RequiredDirective implements OnInit, OnChanges {
get showMarker(): boolean { return this._showMarker; }

/** Identificador único para o elemento <span> criado. */
@Input("sisID") spanID: string = "";
@Input("requiredID") spanID: string = "";


ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<label *ngIf="labelText && labelText != ''" [libRequired]="isRequired" class="form-label fw-bold">{{ labelText }}</label>
<label *ngIf="labelText && labelText != ''" [libRequired]="isRequired" [requiredID]="comboboxID" class="form-label fw-bold">{{ labelText }}</label>
<div class="input-group dropdown flex-fill glb-max-height-350px">

<!-- Este elemento ng-content com o atributo [btnLeft] permite que o usuário final forneça conteúdo personalizado para ser exibido no lado esquerdo do combobox de pesquisa.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class LibComboboxComponent implements OnInit, AfterViewInit, OnDestroy {
protected invalid: boolean = false;
protected dirty: boolean = false;
protected touched: boolean = false;

protected comboboxID: string;
// #endregion PROTECTED

// #region PRIVATE
Expand Down Expand Up @@ -102,9 +104,9 @@ export class LibComboboxComponent implements OnInit, AfterViewInit, OnDestroy {
@Input() public labelText?: string;

/** (opcional) Define se o campo é obrigatório, vai exibir o '*' vermelho ao lado do label (se ele estiver presente)
* @type {boolean}
* @default false */
@Input() public libRequired: boolean = false;
* @type {boolean} */
@Input()
public libRequired?: boolean;

/** (opcional) Define se o campo está desabilitado. Deve ser usado para validações de habilitação dinâmica do campo
* @type {boolean}
Expand Down Expand Up @@ -168,6 +170,9 @@ export class LibComboboxComponent implements OnInit, AfterViewInit, OnDestroy {
constructor() { }

ngOnInit(): void {
this.comboboxID = `lib-combobox-${Math.random() * 100}`;
console.log("comboboxID: ", this.comboboxID);

this.adjustDropdownWidth();

this.setValidator();
Expand All @@ -180,7 +185,7 @@ export class LibComboboxComponent implements OnInit, AfterViewInit, OnDestroy {

ngOnChanges(changes: SimpleChanges): void {
if (changes["comboboxList"]?.currentValue) this.updateSelectedValue();
if (changes["libRequired"]?.currentValue) this.setValidator();
if (changes["libRequired"]?.currentValue != undefined) this.setValidator();
if (changes["outerControl"]?.currentValue) {
this.setValidator();
this.updateSelectedValue((changes["outerControl"].currentValue as FormControl).value);
Expand Down Expand Up @@ -245,16 +250,28 @@ export class LibComboboxComponent implements OnInit, AfterViewInit, OnDestroy {
}
}

/** Serve para aplicar ou remover o Validator.required do controle.
* Por padrão ele priorizará a propriedade libRequired para esta validação. */
private setValidator(): void {
console.log("Validação validator", this._outerControl.hasValidator(Validators.required) || this.libRequired === true);

if (this._outerControl.hasValidator(Validators.required) || this.libRequired === true) {
this.innerControl.addValidators(Validators.required);
this.isRequired = true;
if (this.libRequired !== undefined) {
if (this.libRequired) {
this.innerControl.addValidators(Validators.required);
this.isRequired = true;
}
else {
this.innerControl.removeValidators(Validators.required);
this.isRequired = false;
}
}
else {
this.innerControl.removeValidators(Validators.required);
this.isRequired = false;
if (this._outerControl.hasValidator(Validators.required)) {
this.innerControl.addValidators(Validators.required);
this.isRequired = true;
}
else {
this.innerControl.removeValidators(Validators.required);
this.isRequired = false;
}
}
}

Expand Down

0 comments on commit d49d895

Please sign in to comment.