Commit 31f15ab4 by Natthaphat

Myjob - ผู้ดูแลระบบ > การจัดการ PDPA แก้ตามใบงาน

1. แก้ไขการกรอกวันที่
2. แก้ไข require
3. แก้ไข default สถานะเป็น ปิดใช้งาน
4. แก้ไขแจ้งเตือนการเปลี่ยนสถานะ กรณีมีสถานะ เปิดใช้งาน อยู่แล้ว
5. แก้ไขการแก้ไขเวอร์ชัน
6. แก้ไขการลบข้อมูล
parent 9aadc9ca
...@@ -69,16 +69,12 @@ ...@@ -69,16 +69,12 @@
</td> </td>
<td> <td>
<div> <div>
<span class="badge bg-info/10 text-primary"><i class="bi bi-clock me-1"></i>{{item.startDate <span class="badge bg-info/10 text-primary"><i class="bi bi-clock me-1"></i>{{item.startDate| date : 'dd/MM/yyyy hh:mm a' : '+0000'}}</span>
| date
: 'medium'}}</span>
</div> </div>
</td> </td>
<td> <td>
<div> <div>
<span class="badge bg-info/10 text-primary"><i class="bi bi-clock me-1"></i>{{item.endDate <span class="badge bg-info/10 text-primary"><i class="bi bi-clock me-1"></i>{{item.endDate| date : 'dd/MM/yyyy hh:mm a' : '+0000'}}</span>
| date
: 'medium'}}</span>
</div> </div>
</td> </td>
<td> <span <td> <span
...@@ -232,7 +228,8 @@ ...@@ -232,7 +228,8 @@
<div class="ti-modal-content"> <div class="ti-modal-content">
<div class="ti-modal-header flex justify-between items-center p-5"> <div class="ti-modal-header flex justify-between items-center p-5">
<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)) + ' ' + ('Version' | translate) }} : {{ (modalStatus == 'add' ? ('Create' | translate) : ('Edit' | translate)) + ' ' + ('Version' | translate) }}
:
<span class="text-danger" *ngIf="pdpa.version">({{ pdpa.version }})</span> <span class="text-danger" *ngIf="pdpa.version">({{ pdpa.version }})</span>
</h6> </h6>
...@@ -254,10 +251,10 @@ ...@@ -254,10 +251,10 @@
</div> --> </div> -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
<div class="flex flex-col"> <div class="flex flex-col">
<label class="ti-form-label mb-2 text-primary font-bold">{{'Version' | translate}} *</label> <label class="ti-form-label mb-2 text-primary font-bold">{{'Version' | translate}}
<input type="text" class="ti-form-input w-full" <span class="text-danger text-sm mt-1">*</span>
[ngClass]="{ '!bg-input-readonly': modalStatus === 'edit' }" [(ngModel)]="pdpa.version" </label>
[readonly]="modalStatus === 'edit'" /> <input type="number" class="ti-form-input w-full" [(ngModel)]="pdpa.version" />
<div class="text-danger text-sm mt-1" *ngIf="!pdpa.version"> <div class="text-danger text-sm mt-1" *ngIf="!pdpa.version">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
...@@ -286,7 +283,8 @@ ...@@ -286,7 +283,8 @@
<div class="flex flex-col"> <div class="flex flex-col">
<label class="ti-form-label mb-2 text-primary font-bold">{{'Start Date' | translate}} </label> <label class="ti-form-label mb-2 text-primary font-bold">{{'Start Date' | translate}} </label>
<input type="datetime-local" class="ti-form-input w-full" [(ngModel)]="pdpa.startDate" /> <input type="datetime-local" class="ti-form-input w-full" [(ngModel)]="pdpa.startDate"
max="9999-12-31T23:59" />
<div class="text-danger text-sm mt-1" *ngIf="!pdpa.startDate"> <div class="text-danger text-sm mt-1" *ngIf="!pdpa.startDate">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
...@@ -294,7 +292,8 @@ ...@@ -294,7 +292,8 @@
<div class="flex flex-col"> <div class="flex flex-col">
<label class="ti-form-label mb-2 text-primary font-bold">{{'End Date' | translate}}</label> <label class="ti-form-label mb-2 text-primary font-bold">{{'End Date' | translate}}</label>
<input type="datetime-local" class="ti-form-input w-full" [(ngModel)]="pdpa.endDate" /> <input type="datetime-local" class="ti-form-input w-full" [(ngModel)]="pdpa.endDate"
max="9999-12-31T23:59" />
<div class="text-danger text-sm mt-1" *ngIf="!pdpa.endDate"> <div class="text-danger text-sm mt-1" *ngIf="!pdpa.endDate">
{{'Please fill in information' | translate}} {{'Please fill in information' | translate}}
</div> </div>
...@@ -303,38 +302,59 @@ ...@@ -303,38 +302,59 @@
<div class="body-content pt-0"> <div class="body-content pt-0">
<nav class="flex space-x-2 border-b border-gray-200 mb-4"> <nav class="flex space-x-2 border-b border-gray-200 mb-4">
<a (click)="currentTab = 1" class="tab-btn" [ngClass]="{ <a (click)="currentTab = 1" class="tab-btn"
'!bg-primary border-primary !text-white': currentTab === 1 [ngClass]="{ '!bg-primary border-primary !text-white': currentTab === 1 }" href="javascript:void(0);">
}" href="javascript:void(0);"> {{ 'Thai' | translate }}
{{'Thai' |translate}} <span *ngIf="!pdpa.requestConsentThai" [ngClass]="{
'text-danger': currentTab !== 1,
'text-white': currentTab === 1
}" class="text-sm">&nbsp;*</span>
</a> </a>
<a (click)="currentTab = 2" class="tab-btn" [ngClass]="{
'!bg-primary border-primary !text-white': currentTab === 2 <a (click)="currentTab = 2" class="tab-btn"
}" href="javascript:void(0);"> [ngClass]="{ '!bg-primary border-primary !text-white': currentTab === 2 }" href="javascript:void(0);">
{{'Eng' | translate}} {{ 'Eng' | translate }}
<span *ngIf="!pdpa.requestConsentEng" [ngClass]="{
'text-danger': currentTab !== 2,
'text-white': currentTab === 2
}" class="text-sm">&nbsp;*</span>
</a> </a>
<a (click)="currentTab = 3" class="tab-btn" [ngClass]="{
'!bg-primary border-primary !text-white': currentTab === 3 <a (click)="currentTab = 3" class="tab-btn"
}" href="javascript:void(0);"> [ngClass]="{ '!bg-primary border-primary !text-white': currentTab === 3 }" href="javascript:void(0);">
{{'China' | translate}} {{ 'China' | translate }}
<span *ngIf="!pdpa.requestConsentChina" [ngClass]="{
'text-danger': currentTab !== 3,
'text-white': currentTab === 3
}" class="text-sm">&nbsp;*</span>
</a> </a>
</nav> </nav>
<div> <div>
<div *ngIf="currentTab == 1"> <div *ngIf="currentTab == 1">
<quill-editor [modules]="quillConfig" [styles]="{ 'height': '500px', 'overflow-y': 'auto' }" <quill-editor [modules]="quillConfig" [styles]="{ 'height': '500px', 'overflow-y': 'auto' }"
[(ngModel)]="pdpa.requestConsentThai" [ngModelOptions]="{ standalone: true }" [(ngModel)]="pdpa.requestConsentThai" [ngModelOptions]="{ standalone: true }"
theme="snow"></quill-editor> theme="snow"></quill-editor>
<div class="text-danger text-sm mt-1" *ngIf="!pdpa.requestConsentThai">
{{'Please fill in information' | translate}}
</div>
</div> </div>
<div *ngIf="currentTab == 2"> <div *ngIf="currentTab == 2">
<quill-editor [modules]="quillConfig" [styles]="{ 'height': '500px', 'overflow-y': 'auto' }" <quill-editor [modules]="quillConfig" [styles]="{ 'height': '500px', 'overflow-y': 'auto' }"
[(ngModel)]="pdpa.requestConsentEng" [ngModelOptions]="{ standalone: true }" [(ngModel)]="pdpa.requestConsentEng" [ngModelOptions]="{ standalone: true }"
theme="snow"></quill-editor> theme="snow"></quill-editor>
<div class="text-danger text-sm mt-1" *ngIf="!pdpa.requestConsentEng">
{{'Please fill in information' | translate}}
</div>
</div> </div>
<div *ngIf="currentTab == 3"> <div *ngIf="currentTab == 3">
<quill-editor [modules]="quillConfig" [styles]="{ 'height': '500px', 'overflow-y': 'auto' }" <quill-editor [modules]="quillConfig" [styles]="{ 'height': '500px', 'overflow-y': 'auto' }"
[(ngModel)]="pdpa.requestConsentChina" [ngModelOptions]="{ standalone: true }" [(ngModel)]="pdpa.requestConsentChina" [ngModelOptions]="{ standalone: true }"
theme="snow"></quill-editor> theme="snow"></quill-editor>
<div class="text-danger text-sm mt-1" *ngIf="!pdpa.requestConsentChina">
{{'Please fill in information' | translate}}
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -345,8 +365,22 @@ ...@@ -345,8 +365,22 @@
(click)="modalRef.close()" #closeModal> (click)="modalRef.close()" #closeModal>
{{'Cancel' | translate}} {{'Cancel' | translate}}
</button> </button>
<button type="button" (click)="save()" [disabled]="isSaving" <button type="button" (click)="save()" [disabled]="isSaving" class="ti-btn bg-primary text-white !font-medium"
class="ti-btn bg-primary text-white !font-medium"> [class.ti-btn-disabled]="
!pdpa.version ||
!pdpa.startDate ||
!pdpa.endDate ||
!pdpa.requestConsentThai ||
!pdpa.requestConsentEng ||
!pdpa.requestConsentChina
" [disabled]="
!pdpa.version ||
!pdpa.startDate ||
!pdpa.endDate ||
!pdpa.requestConsentThai ||
!pdpa.requestConsentEng ||
!pdpa.requestConsentChina
">
{{ isSaving ? ('Saving...' | translate) : ('Save' | translate) }} {{ isSaving ? ('Saving...' | translate) : ('Save' | translate) }}
</button> </button>
......
...@@ -32,7 +32,7 @@ import { MyPdpaModel, PdpaModel } from "../../models/pdpa.model"; ...@@ -32,7 +32,7 @@ import { MyPdpaModel, PdpaModel } from "../../models/pdpa.model";
FileUploadModule, FileUploadModule,
PdpaConfigComponent, PdpaConfigComponent,
QuillModule QuillModule
], ],
templateUrl: './pdpa-manage.component.html', templateUrl: './pdpa-manage.component.html',
styleUrl: './pdpa-manage.component.css' styleUrl: './pdpa-manage.component.css'
}) })
...@@ -132,6 +132,7 @@ export class PdpaManageComponent { ...@@ -132,6 +132,7 @@ export class PdpaManageComponent {
this.modalStatus = 'add' this.modalStatus = 'add'
this.pdpa = new MyPdpaConfigModel(); this.pdpa = new MyPdpaConfigModel();
this.openModal(); this.openModal();
this.pdpa.status = "0";
} }
view(item: MyPdpaConfigModel) { view(item: MyPdpaConfigModel) {
...@@ -157,38 +158,75 @@ export class PdpaManageComponent { ...@@ -157,38 +158,75 @@ export class PdpaManageComponent {
// ---------------------------------------------------- // ----------------------------------------------------
save() { save() {
swal({ this.pdpaService.getConfigList().subscribe({
title: "Are you sure?", next: configs => {
text: "คุณต้องการบันทึกหรือไม่", const isActiveExist = configs.some(cfg => cfg.status === "1" && cfg.version !== this.pdpa.version);
icon: "warning",
dangerMode: false, if (isActiveExist && this.pdpa.status === '1') {
buttons: ["Cancel", "Confirm"], // ถ้ามีเวอร์ชันอื่นที่เปิดใช้งานอยู่แล้ว และกำลังจะเปิดอีกเวอร์ชัน
}) swal({
.then((willDelete: any) => { title: "มีรายการที่เปิดใช้งานอยู่แล้ว",
if (willDelete) { text: "คุณแน่ใจหรือไม่ว่าต้องการเปิดใช้งานเวอร์ชั่นใหม่นี้?",
icon: "warning",
if (this.modalStatus == 'add') { buttons: ["ยกเลิก", "ยืนยัน"],
console.log(this.pdpa); dangerMode: false,
this.pdpaService.postConfig(this.pdpa).subscribe(result => { }).then((confirm: boolean) => {
swal("Save Success!!", "บันทึกเวอร์ชั่นสำเร็จ", "success"); if (confirm) {
this.ngOnInit() if (this.modalStatus === 'add') {
this.childModal?.nativeElement.click() this.pdpaService.postConfig(this.pdpa).subscribe(() => {
}) swal("บันทึกสำเร็จ", "บันทึกเวอร์ชั่นสำเร็จแล้ว", "success");
} else if (this.modalStatus == 'edit') { this.ngOnInit();
const respone = new MyPdpaConfigModel(this.pdpa); this.childModal?.nativeElement.click();
this.pdpaService.update(respone).subscribe(result => { });
console.log(result) } else if (this.modalStatus === 'edit') {
swal("Update Success!!", "บันทึกเวอร์ชั่นสำเร็จ", "success"); const respone = new MyPdpaConfigModel(this.pdpa);
this.ngOnInit() this.pdpaService.update(respone).subscribe(() => {
this.childModal?.nativeElement.click() swal("อัปเดตสำเร็จ", "บันทึกเวอร์ชั่นสำเร็จแล้ว", "success");
}) this.ngOnInit();
} this.childModal?.nativeElement.click();
});
}
}
});
} else {
// กรณีทั่วไป
swal({
title: "ยืนยันการบันทึก",
text: "คุณต้องการบันทึกหรือไม่?",
icon: "warning",
buttons: ["ยกเลิก", "ยืนยัน"],
dangerMode: false,
}).then((willSave: boolean) => {
if (willSave) {
if (this.modalStatus === 'add') {
this.pdpaService.postConfig(this.pdpa).subscribe(() => {
swal("บันทึกสำเร็จ", "บันทึกเวอร์ชั่นสำเร็จแล้ว", "success");
this.ngOnInit();
this.childModal?.nativeElement.click();
});
} else if (this.modalStatus === 'edit') {
const respone = new MyPdpaConfigModel(this.pdpa);
this.pdpaService.update(respone).subscribe(() => {
swal("อัปเดตสำเร็จ", "บันทึกเวอร์ชั่นสำเร็จแล้ว", "success");
this.ngOnInit();
this.childModal?.nativeElement.click();
});
}
}
});
} }
}); },
error: (error) => {
console.error('Error: ', error);
}
});
} }
deleteVersion(item: PdpaConfigModel) { deleteVersion(item: PdpaConfigModel) {
const versionText = `${this.translate.instant('Version')}: ${item.version}`; const versionText = `${this.translate.instant('Version')}: ${item.version || 'เวอร์ชั่นที่จะลบเป็นค่าว่าง'}`;
swal({ swal({
title: "Are you sure?", title: "Are you sure?",
text: `Confirm to delete :\n${versionText}\!`, text: `Confirm to delete :\n${versionText}\!`,
...@@ -211,7 +249,7 @@ export class PdpaManageComponent { ...@@ -211,7 +249,7 @@ export class PdpaManageComponent {
if (isSelected) { if (isSelected) {
const pdpa = this.itemsList.find(pdpa => pdpa.version === version) as MyPdpaConfigModel; const pdpa = this.itemsList.find(pdpa => pdpa.version === version) as MyPdpaConfigModel;
if (pdpa) { if (pdpa) {
pdpaConfig += `${this.translate.instant('Version')}: ${pdpa.version}\n`; pdpaConfig += `${this.translate.instant('Version')}: ${pdpa.version || 'เวอร์ชั่นที่จะลบเป็นค่าว่าง'}\n`;
} }
} }
}); });
......
...@@ -112,9 +112,7 @@ ...@@ -112,9 +112,7 @@
<td> <span <td> <span
class="badge bg-{{ item.status == 1 ? 'primary' : 'danger'}} text-white">{{item.getStatus()}}</span> class="badge bg-{{ item.status == 1 ? 'primary' : 'danger'}} text-white">{{item.getStatus()}}</span>
</td> </td>
<td><span class="badge bg-info/10 text-primary"><i class="bi bi-clock me-1"></i>{{item.lastModifiedDate <td><span class="badge bg-info/10 text-primary"><i class="bi bi-clock me-1"></i>{{item.lastModifiedDate| date : 'dd/MM/yyyy hh:mm a' : '+0000'}}</span>
| date
: 'medium'}}</span>
</td> </td>
<td> <td>
......
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