Skip to content

Commit

Permalink
fix add employee issues
Browse files Browse the repository at this point in the history
  • Loading branch information
suxrobGM committed Nov 4, 2023
1 parent 211a5c3 commit 315fca6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ <h1 class="text-center">Add a new employee</h1>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<p-dropdown formControlName="role" styleClass="w-100" [options]="roles"
optionValue="name" optionLabel="displayName" [showClear]="true" (onClear)="clearSelctedRole()">
optionValue="name" optionLabel="displayName"
[showClear]="true"
(onClear)="clearSelctedRole()">
</p-dropdown>
</div>

Expand All @@ -50,15 +52,15 @@ <h1 class="text-center">Add a new employee</h1>
type="submit"
class="p-button-raised mt-3"
icon="bi bi-pencil-square"
[disabled]="isLoading"
label="Add">
[disabled]="isLoading">
Add
</button>
<button pButton
type="button"
class="p-button-raised mt-3 ms-2"
icon="bi bi-arrow-left-square"
[routerLink]="['/employees']"
label="Back to list">
[routerLink]="['/employees']">
Back to list
</button>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ProgressSpinnerModule} from 'primeng/progressspinner';
import {CardModule} from 'primeng/card';
import {ConfirmDialogModule} from 'primeng/confirmdialog';
import {ToastModule} from 'primeng/toast';
import {ConfirmationService} from 'primeng/api';
import {EnumValue, SalaryType, SalaryTypeEnum, convertEnumToArray} from '@core/enums';
import {CreateEmployee, Role, User} from '@core/models';
import {ApiService, ToastService} from '@core/services';
Expand Down Expand Up @@ -38,6 +39,7 @@ import {ValidationSummaryComponent} from '@shared/components';
],
providers: [
UserService,
ConfirmationService
],
})
export class AddEmployeeComponent implements OnInit {
Expand All @@ -59,7 +61,7 @@ export class AddEmployeeComponent implements OnInit {

this.form = new FormGroup<CreateEmployeeForm>({
user: new FormControl(null, {validators: Validators.required}),
role: new FormControl(null, {validators: Validators.required}),
role: new FormControl(null),
salary: new FormControl<number>(0, {validators: Validators.required, nonNullable: true}),
salaryType: new FormControl<SalaryType>(SalaryType.None, {validators: Validators.required, nonNullable: true})
});
Expand All @@ -79,7 +81,7 @@ export class AddEmployeeComponent implements OnInit {

clearSelctedRole() {
this.form.patchValue({
role: {name: '', displayName: ' '},
role: null,
});
}

Expand Down

0 comments on commit 315fca6

Please sign in to comment.