Commit 31f15ab4 by Natthaphat

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

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