Commit 2354e7e1 by Natthaphat

Myjob - ผู้ดูแลระบบ > การจัดการผู้สมัครงาน แก้ตาม Test filed

parent 83db1670
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
<th scope="col" class="text-start">{{ 'Candidate ID' | translate}}</th> <th scope="col" class="text-start">{{ 'Candidate ID' | translate}}</th>
<th scope="col" class="text-start">{{ 'Fullname' | translate}}</th> <th scope="col" class="text-start">{{ 'Fullname' | translate}}</th>
<th scope="col" class="text-start">{{ 'Email' | translate}}</th> <th scope="col" class="text-start">{{ 'Email' | translate}}</th>
<th scope="col" class="text-start">{{ 'Mobile' | translate}}</th>
<!-- <th scope="col" class="text-start">{{ 'User Group' | translate}}</th> --> <!-- <th scope="col" class="text-start">{{ 'User Group' | translate}}</th> -->
<th scope="col" class="text-start">{{ 'Status' | translate}}</th> <th scope="col" class="text-start">{{ 'Status' | translate}}</th>
<th scope="col" class="text-start">{{ 'Update Date' | translate}}</th> <th scope="col" class="text-start">{{ 'Update Date' | translate}}</th>
...@@ -107,12 +106,6 @@ ...@@ -107,12 +106,6 @@
class="ri-mail-line me-2 align-middle text-[.875rem] text-[#8c9097] dark:text-white/50 inline-flex"></i>{{item.email}}</span> class="ri-mail-line me-2 align-middle text-[.875rem] text-[#8c9097] dark:text-white/50 inline-flex"></i>{{item.email}}</span>
</div> </div>
</td> </td>
<td>
<div>
<span class="block"><i
class="ri-phone-line me-2 align-middle text-[.875rem] text-[#8c9097] dark:text-white/50 inline-flex"></i>{{item.phoneNumberProfile}}</span>
</div>
</td>
<!-- <td> <span <!-- <td> <span
class="badge bg-{{ item.role == 0 ? 'primary' : 'info'}} text-white">{{item.getRole()}}</span> class="badge bg-{{ item.role == 0 ? 'primary' : 'info'}} text-white">{{item.getRole()}}</span>
</td> --> </td> -->
...@@ -204,7 +197,8 @@ ...@@ -204,7 +197,8 @@
<div class="ti-modal-content"> <div class="ti-modal-content">
<div class="ti-modal-header"> <div class="ti-modal-header">
<h6 class="modal-title text-[1rem] font-semibold text-defaulttextcolor" id="mail-ComposeLabel"> <h6 class="modal-title text-[1rem] font-semibold text-defaulttextcolor" id="mail-ComposeLabel">
{{ (modalStatus == 'add' ? ('Create' | translate) : ('Edit' | translate)) + ' ' + ('User Information' | translate) }} {{ (modalStatus == 'add' ? ('Create' | translate) : ('Edit' | translate)) + ' ' + ('User Information' |
translate) }}
</h6> </h6>
<button type="button" class="hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor" <button type="button" class="hs-dropdown-toggle !text-[1rem] !font-semibold !text-defaulttextcolor"
...@@ -221,8 +215,9 @@ ...@@ -221,8 +215,9 @@
<span class="avatar avatar-xxl avatar-rounded"> <span class="avatar avatar-xxl avatar-rounded">
<img [src]="selectModel.getPicture()" alt="" id="profile-img"> <img [src]="selectModel.getPicture()" alt="" id="profile-img">
<span class="badge rounded-full bg-primary avatar-badge"> <span class="badge rounded-full bg-primary avatar-badge">
<input (click)="triggerFileInput()" ng2FileSelect [uploader]="uploaderProfile" type="file" name="photo" [disabled]="action === 'edit'" <input (click)="triggerFileInput()" ng2FileSelect [uploader]="uploaderProfile" type="file"
class="absolute w-full h-full opacity-[0]" id="profile-change"> name="photo" [disabled]="action === 'edit'" class="absolute w-full h-full opacity-[0]"
id="profile-change">
<i class="fe fe-camera text-[.625rem]"></i> <i class="fe fe-camera text-[.625rem]"></i>
</span> </span>
</span> </span>
...@@ -291,7 +286,8 @@ ...@@ -291,7 +286,8 @@
</div> </div>
<div class="xl:col-span-6 col-span-12" *ngIf="modalStatus=='edit'"> <div class="xl:col-span-6 col-span-12" *ngIf="modalStatus=='edit'">
<label for="deal-title" class="form-label">{{'Name-Surname(Thai)' | translate}}</label> <label for="deal-title" class="form-label">{{'Name-Surname(Thai)' | translate}}</label>
<input type="text" class="form-control" id="deal-title" placeholder="" [(ngModel)]="selectModel.thFullName" [disabled]="action === 'edit'"> <input type="text" class="form-control" id="deal-title" placeholder="" [(ngModel)]="selectModel.thFullName"
[disabled]="action === 'edit'">
<div class="text-danger" *ngIf="!selectModel.thFullName"> <div class="text-danger" *ngIf="!selectModel.thFullName">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
...@@ -307,19 +303,30 @@ ...@@ -307,19 +303,30 @@
</div> </div>
<div class="xl:col-span-6 col-span-12"> <div class="xl:col-span-6 col-span-12">
<label for="deal-title" class="form-label">{{'Email' | translate}}</label> <label for="deal-title" class="form-label">{{ 'Email' | translate }}</label>
<input type="text" class="form-control" id="deal-title" placeholder="" [(ngModel)]="selectModel.email" [disabled]="action === 'edit'"> <input type="text" class="form-control" id="deal-title" placeholder="" [(ngModel)]="selectModel.email"
[disabled]="action === 'edit'" (ngModelChange)="onEmailChange($event)" />
<div class="text-danger" *ngIf="!selectModel.email"> <div class="text-danger" *ngIf="!selectModel.email">
{{'Please fill in information' | translate}} {{ 'Please fill in information' | translate }}
</div>
<div class="text-danger" *ngIf="selectModel.email && (!selectModel.email.includes('@'))">
{{ 'Invalid email format @' | translate }}
</div>
<div class="text-danger" *ngIf="selectModel.email && selectModel.email.includes('@') && !selectModel.email.split('@')[1]?.includes('.')">
{{ 'Invalid email format .' | translate }}
</div>
<div class="text-danger" *ngIf="isEmailDuplicate && action !== 'edit'">
{{ 'This email already exists' | translate }}
</div> </div>
</div> </div>
<div class="xl:col-span-6 col-span-12"> <div class="xl:col-span-6 col-span-12">
<label for="deal-title" class="form-label">{{'Mobile' | translate}}</label> <label for="deal-title" class="form-label">{{'Password' | translate}}</label>
<input type="text" class="form-control" id="deal-title" placeholder="" [disabled]="action === 'edit'" <input type="password" class="form-control" id="deal-title" placeholder="" [disabled]="action === 'edit'"
[(ngModel)]="selectModel.phoneNumberProfile"> [(ngModel)]="selectModel.password">
<div class="text-danger" *ngIf="!selectModel.phoneNumberProfile"> <div class="text-danger" *ngIf="!selectModel.password && action !=='edit'">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
</div> </div>
...@@ -336,7 +343,7 @@ ...@@ -336,7 +343,7 @@
<div class="xl:col-span-12 col-span-12"> <div class="xl:col-span-12 col-span-12">
<label class="form-label">{{'Status' | translate}}</label> <label class="form-label">{{'Status' | translate}}</label>
<ng-select name="choices-multiple-remove-button2" id="choices-multiple-remove-button2" placeholder="" <ng-select name="choices-multiple-remove-button2" id="choices-multiple-remove-button2" placeholder=""
[(ngModel)]="selectModel.status"> [disabled]="action === 'edit'" [(ngModel)]="selectModel.status">
<ng-option [value]="0">{{'Unactive' | translate}}</ng-option> <ng-option [value]="0">{{'Unactive' | translate}}</ng-option>
<ng-option [value]="1">{{'Active' | translate}}</ng-option> <ng-option [value]="1">{{'Active' | translate}}</ng-option>
</ng-select> </ng-select>
...@@ -349,8 +356,26 @@ ...@@ -349,8 +356,26 @@
data-hs-overlay="#modal-detail"> data-hs-overlay="#modal-detail">
{{'Cancel' | translate}} {{'Cancel' | translate}}
</button> </button>
<button type="button" (click)="save()" class="ti-btn bg-primary text-white !font-medium">{{'Save' | <button type="button" (click)="save()" class="ti-btn bg-primary text-white !font-medium"
translate}}</button> [class.ti-btn-disabled]="
!selectModel.candidateId ||
!selectModel.thFirstname ||
!selectModel.thLastname ||
!selectModel.engFirstname ||
!selectModel.engLastname ||
(!selectModel.email || isEmailDuplicate || !selectModel.email.includes('@') || !selectModel.email.includes('.')) ||
!selectModel.password
" [disabled]="
!selectModel.candidateId ||
!selectModel.thFirstname ||
!selectModel.thLastname ||
!selectModel.engFirstname ||
!selectModel.engLastname ||
(!selectModel.email || isEmailDuplicate || !selectModel.email.includes('@') || !selectModel.email.includes('.')) ||
!selectModel.password
">
{{ 'Save' | translate }}
</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -24,7 +24,7 @@ import { TokenService } from "../../../../shared/services/token.service"; ...@@ -24,7 +24,7 @@ import { TokenService } from "../../../../shared/services/token.service";
NgSelectModule, NgSelectModule,
FormsModule, FormsModule,
FileUploadModule FileUploadModule
], ],
templateUrl: './user-setting.component.html', templateUrl: './user-setting.component.html',
styleUrl: './user-setting.component.css' styleUrl: './user-setting.component.css'
}) })
...@@ -47,6 +47,8 @@ export class UserSettingComponent { ...@@ -47,6 +47,8 @@ export class UserSettingComponent {
uploaderProfile: FileUploader | undefined; uploaderProfile: FileUploader | undefined;
uploadErrorMsg: string = ""; uploadErrorMsg: string = "";
modalStatus: "add" | "edit" = "add" modalStatus: "add" | "edit" = "add"
existingEmails: UserProfileModel[] = []
isEmailDuplicate = false;
get searchTerm(): string { get searchTerm(): string {
return this._searchTerm; return this._searchTerm;
} }
...@@ -123,9 +125,19 @@ export class UserSettingComponent { ...@@ -123,9 +125,19 @@ export class UserSettingComponent {
this.itemsList = result.map(item => new UserProfileModel(item, this.translate)); this.itemsList = result.map(item => new UserProfileModel(item, this.translate));
this.filterList = [...this.itemsList]; this.filterList = [...this.itemsList];
}); });
this.userService.getListsProfile().subscribe(email => {
this.existingEmails = email;
});
} }
onEmailChange(email: string) {
const lowerEmail = email.trim().toLowerCase();
this.isEmailDuplicate = this.existingEmails.some(
user => user.email && user.email.toLowerCase() === lowerEmail
);
}
filter(v: string): UserProfileModel[] { filter(v: string): UserProfileModel[] {
const search = v.toLowerCase(); const search = v.toLowerCase();
return this.itemsList?.filter(x => return this.itemsList?.filter(x =>
...@@ -162,6 +174,7 @@ export class UserSettingComponent { ...@@ -162,6 +174,7 @@ export class UserSettingComponent {
new() { new() {
this.action = 'add' this.action = 'add'
this.selectModel = new UserProfileModel() this.selectModel = new UserProfileModel()
this.selectModel.status = 1;
} }
view(item: UserProfileModel) { view(item: UserProfileModel) {
...@@ -183,6 +196,9 @@ export class UserSettingComponent { ...@@ -183,6 +196,9 @@ export class UserSettingComponent {
if (willDelete) { if (willDelete) {
if (this.action == 'add') { if (this.action == 'add') {
this.userService.save(this.selectModel).subscribe(result => { this.userService.save(this.selectModel).subscribe(result => {
if (this.selectModel.email) {
swal("Save Success!!", "อีเมลซ่ำ", "warning");
}
console.log(result) console.log(result)
swal("Save Success!!", "บันทึกข้อมูลสมาชิก", "success"); swal("Save Success!!", "บันทึกข้อมูลสมาชิก", "success");
this.ngOnInit() this.ngOnInit()
......
...@@ -97,13 +97,14 @@ export class UserProfileModel extends BaseModel { ...@@ -97,13 +97,14 @@ export class UserProfileModel extends BaseModel {
getPicture(): string { getPicture(): string {
if (this.picture) { if (this.picture) {
return environment.baseUrl + "/files/image/" + this.picture return environment.baseUrl + "/files/image/" + this.picture;
} else { } else {
return "" // รูป default ใน assets ต้องใช้ path แบบ relative สำหรับ Angular
return "assets/images/faces/1.jpg";
} }
} }
getFullname(): string { getFullname(): string {
return this.thFirstname + " " + this.thLastname; return this.thFirstname + " " + this.thLastname;
} }
......
...@@ -104,5 +104,8 @@ ...@@ -104,5 +104,8 @@
"Degree ID":"Degree ID", "Degree ID":"Degree ID",
"Degree":"Degree", "Degree":"Degree",
"Career Cluster Information":"ข้อมูลกลุ่มอาชีพ", "Career Cluster Information":"ข้อมูลกลุ่มอาชีพ",
"Career Cluster ID":"Career Cluster ID" "Career Cluster ID":"Career Cluster ID",
"Invalid email format @":"May be you forgot @ [ Ex. ] username@hostname.com",
"Invalid email format .":"Why after @ have not dot [ Ex. ] username@hostname.com",
"This email already exists":"This email already exists"
} }
...@@ -104,5 +104,8 @@ ...@@ -104,5 +104,8 @@
"Degree ID":"รหัสระดับการศึกษา", "Degree ID":"รหัสระดับการศึกษา",
"Degree":"ระดับการศึกษา", "Degree":"ระดับการศึกษา",
"Career Cluster Information":"ข้อมูลกลุ่มอาชีพ", "Career Cluster Information":"ข้อมูลกลุ่มอาชีพ",
"Career Cluster ID":"รหัสกลุ่มอาชีพ" "Career Cluster ID":"รหัสกลุ่มอาชีพ",
"Invalid email format @":"ไม่ได้ใส่ @ [ ตัวอย่าง ] username@hostname.com",
"Invalid email format .":"หลัง @ ไม่ได้ใส่ . หลังชื่อ [ ตัวอย่าง ] username@hostname.com",
"This email already exists":"อีเมลนี้มีอยู่แล้ว"
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment