fixing bug on default autocomplete-input validation mechanism
This commit is contained in:
parent
2548bcfd63
commit
bc5a3e8c6a
|
@ -22,6 +22,7 @@
|
||||||
<span id="home-logged-message" *ngIf="account" jhiTranslate="home.logged.message"
|
<span id="home-logged-message" *ngIf="account" jhiTranslate="home.logged.message"
|
||||||
[translateValues]="{ username: account.login }">You are logged in as user "{{account.login}}".</span>
|
[translateValues]="{ username: account.login }">You are logged in as user "{{account.login}}".</span>
|
||||||
</div>
|
</div>
|
||||||
|
<!--
|
||||||
<div class="d-inline-block my-3">
|
<div class="d-inline-block my-3">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>Your Contexts</mat-label>
|
<mat-label>Your Contexts</mat-label>
|
||||||
|
@ -31,8 +32,9 @@
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="d-inline-block my-3" ngbDropdown #myDrop="ngbDropdown" ></div>
|
<div class="d-inline-block my-3" ngbDropdown #myDrop="ngbDropdown" ></div>
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { IContextNode } from 'app/services/i-context-node';
|
||||||
styleUrls: ['./home.component.scss'],
|
styleUrls: ['./home.component.scss'],
|
||||||
providers: [ContextsLoaderService],
|
providers: [ContextsLoaderService],
|
||||||
})
|
})
|
||||||
|
|
||||||
export class HomeComponent implements OnInit {
|
export class HomeComponent implements OnInit {
|
||||||
account: Account | null = null;
|
account: Account | null = null;
|
||||||
|
|
||||||
|
@ -31,8 +32,6 @@ export class HomeComponent implements OnInit {
|
||||||
//public filteredContextsStr: Observable<string[]>| undefined;
|
//public filteredContextsStr: Observable<string[]>| undefined;
|
||||||
chooseContextForm: FormGroup | any;
|
chooseContextForm: FormGroup | any;
|
||||||
resType: string;
|
resType: string;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
|
@ -84,20 +83,41 @@ export class HomeComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
//PER VALIDAZIONE FORM
|
//PER VALIDAZIONE FORM
|
||||||
|
/*
|
||||||
checkForErrorsIn(formControl: AbstractControl): string {
|
checkForErrorsIn(formControl: AbstractControl): string {
|
||||||
if (formControl.hasError('required')) {
|
if (formControl.hasError('required')) {
|
||||||
return 'Value is required!';
|
return 'Value is required!';
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
checkForErrorsIn(formControl: AbstractControl): string {
|
||||||
|
if (formControl.hasError('')) {
|
||||||
|
return 'Value is required!';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidationErrors | null =>!instanceOfContext(formControl?.value) ? { matchRequired: true } : null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
displayFn(ctx: IContextNode): string {
|
displayFn(ctx: IContextNode): string {
|
||||||
//return ctx.name ? ctx.name + ' | ' + ctx.id : '';
|
//return ctx.name ? ctx.name + ' | ' + ctx.id : '';
|
||||||
return ctx.name;
|
return ctx.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
instanceOfContextFn(context: any): context is IContextNode {
|
||||||
|
console.debug("*** In instanceOfContext: typeof_context: "+typeof context);
|
||||||
|
return !!context // truthy
|
||||||
|
&& typeof context !== 'string' // Not just string input in the autocomplete
|
||||||
|
&& 'name' in context; // Has some qualifying property of context type
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
displayFn(ctx: string): string {
|
displayFn(ctx: string): string {
|
||||||
const tmp = ctx ? ctx + ' (poi ci va id) ': '';
|
const tmp = ctx ? ctx + ' (poi ci va id) ': '';
|
||||||
|
@ -105,6 +125,8 @@ export class HomeComponent implements OnInit {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
getContexts(): string[] {
|
getContexts(): string[] {
|
||||||
if (this.account != null && this.account.resourceAccessDTO != null) {
|
if (this.account != null && this.account.resourceAccessDTO != null) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
@ -120,6 +142,8 @@ export class HomeComponent implements OnInit {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
copyUid(val: any): void {
|
copyUid(val: any): void {
|
||||||
if (val instanceof FormControl) {
|
if (val instanceof FormControl) {
|
||||||
|
|
Loading…
Reference in New Issue