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"
|
||||
[translateValues]="{ username: account.login }">You are logged in as user "{{account.login}}".</span>
|
||||
</div>
|
||||
<!--
|
||||
<div class="d-inline-block my-3">
|
||||
<mat-form-field>
|
||||
<mat-label>Your Contexts</mat-label>
|
||||
|
@ -31,8 +32,9 @@
|
|||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
-->
|
||||
|
||||
<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'],
|
||||
providers: [ContextsLoaderService],
|
||||
})
|
||||
|
||||
export class HomeComponent implements OnInit {
|
||||
account: Account | null = null;
|
||||
|
||||
|
@ -32,8 +33,6 @@ export class HomeComponent implements OnInit {
|
|||
chooseContextForm: FormGroup | any;
|
||||
resType: string;
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
private accountService: AccountService,
|
||||
private loginService: LoginService,
|
||||
|
@ -84,12 +83,23 @@ export class HomeComponent implements OnInit {
|
|||
|
||||
|
||||
//PER VALIDAZIONE FORM
|
||||
/*
|
||||
checkForErrorsIn(formControl: AbstractControl): string {
|
||||
if (formControl.hasError('required')) {
|
||||
return 'Value is required!';
|
||||
}
|
||||
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 {
|
||||
|
@ -98,6 +108,16 @@ export class HomeComponent implements OnInit {
|
|||
}
|
||||
|
||||
|
||||
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 {
|
||||
const tmp = ctx ? ctx + ' (poi ci va id) ': '';
|
||||
|
@ -105,6 +125,8 @@ export class HomeComponent implements OnInit {
|
|||
return tmp;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
getContexts(): string[] {
|
||||
if (this.account != null && this.account.resourceAccessDTO != null) {
|
||||
// eslint-disable-next-line no-console
|
||||
|
@ -120,6 +142,8 @@ export class HomeComponent implements OnInit {
|
|||
return [];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
copyUid(val: any): void {
|
||||
if (val instanceof FormControl) {
|
||||
|
|
Loading…
Reference in New Issue