Skip to content

Commit

Permalink
Merge pull request #109 from Dhanu-git20/master
Browse files Browse the repository at this point in the history
Fixed advice Module.
  • Loading branch information
opensource-emr authored Feb 22, 2021
2 parents b69abb2 + bdeaa01 commit 4cc8aff
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ <h1>Update Email Configuration</h1>
<div class="tab-pane fade" id="v-pills-addProvider" role="tabpanel" aria-labelledby="v-pills-addProvider-tab">
<div class="fewa-title">
<h1>Add Provider</h1>
<div class="message" *ngIf="this.addProviderMsg">Successfully added a provider {{this.addProviderObj.userName}}. User can now login using their assigned username and password at your practice website - https://www.fewatele.com/{{this.addProviderObj.practice}}/ or the user’s personal website https://www.fewatele.com/{{this.addProviderObj.practice}}/{{this.addProviderObj.userName}}</div>
<div class="errorMessage" *ngIf="this.addProblemMsg">There is a problem</div>
<div class="message" *ngIf="this.editProviderMsg">Successfully updated a provider. User can now login using their assigned username and password at your practice website - https://www.fewatele.com/{{this.addProviderObj.practice}}/ or the user’s personal website https://www.fewatele.com/{{this.addProviderObj.practice}}/{{this.addProviderObj.userName}}</div>
<div class="errorMessage" *ngIf="this.addProblemMsg">There is a problem</div>
<div class="message" *ngIf="this.removeProviderMsg">Successfully deleted a provider {{this.addProviderObj.userName}}</div>
<div class="errorMessage" *ngIf="this.removeAdminMsg">You can not delete Admin</div>
<div class="errorMessage" *ngIf="this.addProErrorMsg">Provider already exists</div>
</div>
<div class="tab-forms" style="max-height:546px;">
<form [formGroup]="addProviderForm">
Expand All @@ -220,6 +227,8 @@ <h1>Add Provider</h1>
<div *ngIf="addProviderFormControls.userName.touched && addProviderFormControls.userName.invalid" style="color: red;">
<div *ngIf="addProviderFormControls.userName.errors.required">User Name is required.
</div>
<div *ngIf="addProviderFormControls.userName.errors.validUserName">This username is already taken!
</div>
<!-- <div *ngIf="userFormControls.userName.errors.pattern">Invalid mobile
number.</div> -->
</div>
Expand All @@ -234,6 +243,8 @@ <h1>Add Provider</h1>
</div>
<div *ngIf="addProviderFormControls.email.errors.pattern">Invalid email address.
</div>
<div *ngIf="addProviderFormControls.email.errors.validEmail">This email is already taken!
</div>
</div>
</div>
</div>
Expand All @@ -250,16 +261,7 @@ <h1>Add Provider</h1>
</div>

<div class="row">
<div class="col-12 col-md-6">
<div class="message" *ngIf="this.addProviderMsg">Successfully added a provider {{this.addProviderObj.userName}}. User can now login using their assigned username and password at your practice website - https://www.fewatele.com/{{this.addProviderObj.practice}}/ or the user’s personal website https://www.fewatele.com/{{this.addProviderObj.practice}}/{{this.addProviderObj.userName}}</div>
<div class="errorMessage" *ngIf="this.addProblemMsg">There is a problem</div>
<div class="message" *ngIf="this.editProviderMsg">Successfully updated a provider. User can now login using their assigned username and password at your practice website - https://www.fewatele.com/{{this.addProviderObj.practice}}/ or the user’s personal website https://www.fewatele.com/{{this.addProviderObj.practice}}/{{this.addProviderObj.userName}}</div>
<div class="errorMessage" *ngIf="this.editProblemMsg">There is a problem</div>
<div class="message" *ngIf="this.removeProviderMsg">Successfully deleted a provider {{this.addProviderObj.userName}}</div>
<div class="errorMessage" *ngIf="this.removeAdminMsg">You can not delete Admin</div>
<div class="errorMessage" *ngIf="this.addProErrorMsg">Provider already exists</div>
</div>
<div class="col-12 col-md-6 text-right">
<div class="col-12 text-right">
<ul>
<li><button type="submit" (click)="resetAddProviderForm()" class="cancelBtn">Reset</button></li>
<li><button type="submit" [disabled]="!addProviderForm.valid" (click)="addProvider()" class="saveBtn">Save</button></li>&nbsp;&nbsp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@

.message{
color: blue;
text-align: center;
padding: 5px;
}
.errorMessage{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HttpClient, HttpParams, HttpEventType, HttpHeaders } from '@angular/com
import { Router } from '@angular/router';
import { Provider, Practice } from 'src/app/_helpers/models/domain-model';
import { Global } from 'src/app/_helpers/common/global.model';
import { FormGroup, Validators, FormBuilder, FormControl, FormArray } from '@angular/forms';
import { FormGroup, Validators, FormBuilder, FormControl, FormArray, AbstractControl } from '@angular/forms';
import { DomSanitizer } from '@angular/platform-browser';
import { NotificationService } from 'src/app/_helpers/common/notification.service';

Expand Down Expand Up @@ -40,9 +40,7 @@ export class AdminSettingComponent implements OnInit {
fileFormatMsg: boolean = false;
fileSizeMsg: boolean = false;
templateMsg: boolean = false;
editProblemMsg: boolean = false;
addProblemMsg: boolean = false;

adminForm: FormGroup = new FormGroup({});
practiceConfigForm: FormGroup = new FormGroup({});
addProviderForm: FormGroup = new FormGroup({});
Expand Down Expand Up @@ -82,9 +80,9 @@ export class AdminSettingComponent implements OnInit {

private initAddProviderForm() {
this.addProviderForm = this.fb.group({
userName: ['', Validators.required],
userName: ['', [Validators.required, ValidateUserName.bind(this)]],
password: ['', Validators.required],
email: ['', [Validators.required, Validators.pattern("^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$")]],
email: ['',[Validators.required, Validators.pattern("^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$"), ValidateEmail.bind(this)]],
});
this.displayProviderList();
}
Expand Down Expand Up @@ -127,7 +125,13 @@ export class AdminSettingComponent implements OnInit {
this.httpClient.post<any>(this.global.apiUrl + "Security/EditProvider", this.addProviderObj)
.subscribe
(res => {
if (res.message) { alert(res.message) }
if (res.message) {
// alert(res.message)
this.addProblemMsg = true;
setTimeout(() => {
this.addProblemMsg = false;
}, 10000);
}
else {
// "Successfully updated a provider. User can now login using their assigned username and password at your practice website - https://www.fewatele.com/" + this.addProviderObj.practice + "/ or the user’s personal website https://www.fewatele.com/" + this.addProviderObj.practice + "/" + this.addProviderObj.userName
this.editProviderMsg = true;
Expand All @@ -139,10 +143,6 @@ export class AdminSettingComponent implements OnInit {
},
err => {
//There is a problem
this.editProblemMsg = true;
setTimeout(() => {
this.editProblemMsg = false;
}, 5000);
});
this.resetAddProviderForm();
}
Expand Down Expand Up @@ -413,3 +413,16 @@ export class AdminSettingComponent implements OnInit {
this.showEditor = true;
}
}

export function ValidateUserName(control: AbstractControl) {
if (this.providerList.find(a => a.userName == control.value)) {
return { validUserName: true };
}
return null;
}
export function ValidateEmail(control: AbstractControl) {
if (this.providerList.find(a => a.email == control.value)) {
return { validEmail: true };
}
return null;
}
Loading

0 comments on commit 4cc8aff

Please sign in to comment.