Skip to content

Commit 4e6e767

Browse files
committed
Making email address required.
1 parent 2896d95 commit 4e6e767

File tree

3 files changed

+217
-164
lines changed

3 files changed

+217
-164
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,139 @@
11
<h3 mat-dialog-title>{{ (edit ? 'Edit employee' : 'New employee') | translate}}</h3>
2-
<div mat-dialog-content>
3-
<div class="d-flex flex-column">
4-
<mat-form-field>
5-
<mat-label>{{'First name' | translate }}</mat-label>
6-
<input
7-
matInput
8-
[disabled]="selectedDeviceUser.isBackendUser"
9-
[(ngModel)]="selectedDeviceUser.userFirstName"
10-
required
11-
type="text"
12-
id="firstName"
13-
name="userName">
14-
</mat-form-field>
15-
<mat-form-field>
16-
<mat-label>{{'Last name' | translate }}</mat-label>
17-
<input
18-
matInput
19-
[disabled]="selectedDeviceUser.isBackendUser"
20-
[(ngModel)]="selectedDeviceUser.userLastName"
21-
type="text"
22-
name="email"
23-
id="lastName"
24-
required>
25-
</mat-form-field>
26-
<mat-form-field>
27-
<mat-label>{{'PIN code' | translate }}</mat-label>
28-
<input
29-
matInput
30-
[(ngModel)]="selectedDeviceUser.pinCode"
31-
type="text"
32-
name="pinCode"
33-
onkeypress="return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13) ? null : event.charCode >= 48 && event.charCode <= 57"
34-
pattern="[0-9]*"
35-
id="pinCode"
36-
required>
37-
</mat-form-field>
38-
<mat-form-field>
39-
<mat-label>{{'Employee no' | translate }}</mat-label>
40-
<input
41-
matInput
42-
[(ngModel)]="selectedDeviceUser.employeeNo"
43-
type="text"
44-
name="employeeNo"
45-
id="employeeNo"
46-
required>
47-
</mat-form-field>
48-
<mat-form-field>
49-
<mat-label>{{'Language' | translate }}</mat-label>
50-
<mtx-select
51-
id="profileLanguageSelector"
52-
[bindLabel]="'name'"
53-
[bindValue]="'languageCode'"
54-
[clearable]="false"
55-
[(ngModel)]="selectedDeviceUser.languageCode"
56-
[disabled]="timeRegistrationEnabled || taskManagementEnabled || getAssignmentCount() > 0"
57-
[items]="activeLanguages">
58-
<ng-template ng-label-tmp let-item="item">
59-
{{item.name | translate}}
60-
</ng-template>
61-
<ng-template ng-option-tmp let-item="item">
62-
{{item.name | translate}}
63-
</ng-template>
64-
</mtx-select>
65-
</mat-form-field>
66-
<mat-slide-toggle
67-
*ngIf="authStateService.checkClaim('time_registration_enable')"
68-
color="primary"
69-
class="mb-2"
70-
id="timeRegistrationEnabledToggle"
71-
[checked]="selectedDeviceUser.timeRegistrationEnabled"
72-
[(ngModel)]="selectedDeviceUser.timeRegistrationEnabled">
73-
{{ "Timeregistration" | translate }}
74-
</mat-slide-toggle>
75-
<mat-slide-toggle
76-
*ngIf="authStateService.checkClaim('task_management_enable')"
77-
color="primary"
78-
class="mb-2"
79-
id="taskManagementEnabledToggle"
80-
[checked]="selectedDeviceUser.taskManagementEnabled"
81-
[disabled]="selectedDeviceUser.hasWorkOrdersAssigned"
82-
[(ngModel)]="selectedDeviceUser.taskManagementEnabled">
83-
{{ "Task management" | translate }}
84-
</mat-slide-toggle>
2+
<form [formGroup]="form">
3+
<div mat-dialog-content>
4+
<div class="d-flex flex-column">
5+
<mat-form-field>
6+
<mat-label>{{'First name' | translate }}</mat-label>
7+
<input
8+
matInput
9+
formControlName="userFirstName"
10+
required
11+
type="text"
12+
id="firstName"
13+
name="userName">
14+
<mat-error *ngIf="form.get('userFirstName').hasError('required')">
15+
Required
16+
</mat-error>
17+
</mat-form-field>
18+
<mat-form-field>
19+
<mat-label>{{'Last name' | translate }}</mat-label>
20+
<input
21+
matInput
22+
formControlName="userLastName"
23+
type="text"
24+
id="lastName"
25+
required>
26+
<mat-error *ngIf="form.get('userLastName').hasError('required')">
27+
Required
28+
</mat-error>
29+
</mat-form-field>
30+
<mat-form-field>
31+
<mat-label>{{'e-mail' | translate }}</mat-label>
32+
<input
33+
matInput
34+
formControlName="workerEmail"
35+
type="email"
36+
id="email"
37+
required>
38+
<mat-error *ngIf="form.get('workerEmail').hasError('invalidEmail')">
39+
Invalid email address
40+
</mat-error>
41+
<mat-error *ngIf="form.get('workerEmail').hasError('required')">
42+
Required
43+
</mat-error>
44+
</mat-form-field>
45+
<mat-form-field>
46+
<mat-label>{{'PIN code' | translate }}</mat-label>
47+
<input
48+
matInput
49+
formControlName="pinCode"
50+
type="text"
51+
name="pinCode"
52+
pattern="([0-9]*|\*{4})"
53+
id="pinCode">
54+
</mat-form-field>
55+
<mat-form-field>
56+
<mat-label>{{'Employee no' | translate }}</mat-label>
57+
<input
58+
matInput
59+
formControlName="employeeNo"
60+
type="text"
61+
id="employeeNo">
62+
</mat-form-field>
63+
<mat-form-field>
64+
<mat-label>{{'Language' | translate }}</mat-label>
65+
<mtx-select
66+
id="profileLanguageSelector"
67+
[bindLabel]="'name'"
68+
[bindValue]="'languageCode'"
69+
[clearable]="false"
70+
formControlName="languageCode"
71+
[items]="activeLanguages">
72+
<ng-template ng-label-tmp let-item="item">
73+
{{item.name | translate}}
74+
</ng-template>
75+
<ng-template ng-option-tmp let-item="item">
76+
{{item.name | translate}}
77+
</ng-template>
78+
</mtx-select>
79+
</mat-form-field>
80+
<mat-slide-toggle
81+
*ngIf="authStateService.checkClaim('time_registration_enable')"
82+
color="primary"
83+
class="mb-2"
84+
id="timeRegistrationEnabledToggle"
85+
formControlName="timeRegistrationEnabled">
86+
{{ "Timeregistration" | translate }}
87+
</mat-slide-toggle>
88+
<mat-slide-toggle
89+
*ngIf="authStateService.checkClaim('task_management_enable')"
90+
color="primary"
91+
class="mb-2"
92+
id="taskManagementEnabledToggle"
93+
formControlName="taskManagementEnabled">
94+
{{ "Task management" | translate }}
95+
</mat-slide-toggle>
8596

86-
<mtx-grid
87-
[data]="availableProperties"
88-
[columns]="tableHeaders"
89-
[cellTemplate]="{select: selectTpl}"
90-
[pageOnFront]="false"
91-
[rowStriped]="true"
92-
[showPaginator]="false"
93-
id="pairingModalTableBody"
94-
>
95-
</mtx-grid>
97+
<mtx-grid
98+
[data]="availableProperties"
99+
[columns]="tableHeaders"
100+
[cellTemplate]="{select: selectTpl}"
101+
[pageOnFront]="false"
102+
[rowStriped]="true"
103+
[showPaginator]="false"
104+
id="pairingModalTableBody"
105+
>
106+
</mtx-grid>
96107

97-
<ng-template #selectTpl let-row let-i="index">
98-
<div class="column-select">
99-
<mat-checkbox
100-
id="checkboxCreateAssignment{{ i }}"
101-
(change)="addToArray($event, getAssignmentByPropertyId(row.id).propertyId)"
102-
[checked]="getAssignmentIsCheckedByPropertyId(row.id)"
103-
[disabled]="getAssignmentIsLockedByPropertyId(row.id)"
104-
></mat-checkbox>
108+
<ng-template #selectTpl let-row let-i="index">
109+
<div class="column-select">
110+
<mat-checkbox
111+
id="checkboxCreateAssignment{{ i }}"
112+
(change)="addToArray($event, getAssignmentByPropertyId(row.id).propertyId)"
113+
[checked]="getAssignmentIsCheckedByPropertyId(row.id)"
114+
[disabled]="getAssignmentIsLockedByPropertyId(row.id)"
115+
></mat-checkbox>
116+
</div>
117+
</ng-template>
118+
<br>
119+
</div>
120+
<div mat-dialog-actions class="d-flex flex-row justify-content-end">
121+
<button
122+
mat-raised-button
123+
color="accent"
124+
(click)="edit ? updateSingle() : createDeviceUser()"
125+
[disabled]="form.invalid"
126+
id="{{edit ? 'saveEditBtn' : 'saveCreateBtn'}}"
127+
>
128+
{{(edit ? 'Save' : 'Create') | translate}}
129+
</button>
130+
<button
131+
mat-raised-button
132+
id="{{edit ? 'cancelEditBtn' : 'cancelCreateBtn'}}"
133+
(click)="hide()"
134+
>
135+
{{'Cancel' | translate}}
136+
</button>
105137
</div>
106-
</ng-template>
107-
<br>
108-
</div>
109-
<div mat-dialog-actions class="d-flex flex-row justify-content-end">
110-
<button
111-
mat-raised-button
112-
color="accent"
113-
(click)="edit ? updateSingle() : createDeviceUser()"
114-
[disabled]="!selectedDeviceUser.userFirstName || !selectedDeviceUser.userLastName"
115-
id="{{edit ? 'saveEditBtn' : 'saveCreateBtn'}}"
116-
>
117-
{{(edit ? 'Save' : 'Create') | translate}}
118-
</button>
119-
<button
120-
mat-raised-button
121-
id="{{edit ? 'cancelEditBtn' : 'cancelCreateBtn'}}"
122-
(click)="hide()"
123-
>
124-
{{'Cancel' | translate}}
125-
</button>
126-
</div>
127-
</div>
138+
</div>
139+
</form>

0 commit comments

Comments
 (0)