[ADF-4343] Fix bug closing dialog on Host Settings Component (#4541)

* [ADF-4343] Fix bug closing dialog on Host Settings Component

* [ADF-4343] Improve code
This commit is contained in:
davidcanonieto
2019-04-02 19:04:11 +01:00
committed by Eugenio Romano
parent 6213839289
commit a4fcedb44f
2 changed files with 8 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
<h3>{{'CORE.HOST_SETTINGS.TITLE' | translate}}</h3> <h3>{{'CORE.HOST_SETTINGS.TITLE' | translate}}</h3>
</mat-toolbar> </mat-toolbar>
<mat-card class="adf-setting-card"> <mat-card class="adf-setting-card">
<form id="host-form" [formGroup]="form" (submit)="onSubmit(form.value)"> <form id="host-form" [formGroup]="form" (submit)="onSubmit(form.value)" (keydown)="keyDownFunction($event)">
<mat-form-field floatLabel="{{'CORE.HOST_SETTINGS.PROVIDER' | translate }}" *ngIf="showSelectProviders"> <mat-form-field floatLabel="{{'CORE.HOST_SETTINGS.PROVIDER' | translate }}" *ngIf="showSelectProviders">
<mat-select id="adf-provider-selector" placeholder="Provider" [formControl]="providersControl"> <mat-select id="adf-provider-selector" placeholder="Provider" [formControl]="providersControl">

View File

@@ -21,6 +21,7 @@ import { AppConfigService, AppConfigValues } from '../app-config/app-config.serv
import { StorageService } from '../services/storage.service'; import { StorageService } from '../services/storage.service';
import { AlfrescoApiService } from '../services/alfresco-api.service'; import { AlfrescoApiService } from '../services/alfresco-api.service';
import { OauthConfigModel } from '../models/oauth-config.model'; import { OauthConfigModel } from '../models/oauth-config.model';
import { ENTER } from '@angular/cdk/keycodes';
@Component({ @Component({
selector: 'adf-host-settings', selector: 'adf-host-settings',
@@ -189,6 +190,12 @@ export class HostSettingsComponent implements OnInit {
this.success.emit(true); this.success.emit(true);
} }
keyDownFunction(event: any) {
if (event.keyCode === ENTER && this.form.valid) {
this.onSubmit(this.form.value);
}
}
private saveOAuthValues(values: any) { private saveOAuthValues(values: any) {
this.storageService.setItem(AppConfigValues.OAUTHCONFIG, JSON.stringify(values.oauthConfig)); this.storageService.setItem(AppConfigValues.OAUTHCONFIG, JSON.stringify(values.oauthConfig));
this.storageService.setItem(AppConfigValues.IDENTITY_HOST, values.identityHost); this.storageService.setItem(AppConfigValues.IDENTITY_HOST, values.identityHost);