Commit 3c490f8b by Natthaphat

pdpa add edit delete

parent 36fa5d75
......@@ -2,4 +2,82 @@
display: flex;
height: auto;
flex-direction: column;
}
\ No newline at end of file
}
/* Base styling for the modal body content */
.ti-modal-body-content {
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
/* Form labels */
.ti-form-label {
font-size: 0.95rem;
color: #333;
}
/* Form inputs */
.ti-form-input {
border: 1px solid #d1d5db;
border-radius: 4px;
padding: 0.6rem 1rem;
font-size: 1rem;
transition: all 0.2s ease-in-out;
}
.ti-form-input:focus {
outline: none;
border-color: #3b82f6; /* Example primary color */
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
/* Read-only input styling */
.bg-input-readonly {
background-color: #e5e7eb;
cursor: not-allowed;
}
/* Error text */
.text-danger {
color: #ef4444;
}
/* Tab button styling */
.tab-btn {
display: flex;
justify-content: center;
align-items: center;
width: 120px; /* Consistent width for tabs */
padding: 0.75rem 1rem;
border: 1px solid #d1d5db;
border-bottom: none; /* Remove bottom border for active tab effect */
border-top-left-radius: 4px;
border-top-right-radius: 4px;
font-size: 0.95rem;
font-weight: 500;
text-align: center;
color: #6b7280;
transition: all 0.2s ease-in-out;
text-decoration: none; /* Remove underline from anchor tags */
}
.tab-btn:hover {
color: #111827;
background-color: #f3f4f6;
}
/* Active tab styling */
.tab-btn.hs-tab-active {
background-color: #3b82f6; /* Example primary color */
border-color: #3b82f6;
color: #ffffff;
}
/* Custom primary color (replace with your actual primary color if different) */
.text-primary {
color: #3b82f6;
}
.bg-primary {
background-color: #3b82f6;
}
\ No newline at end of file
......@@ -20,20 +20,9 @@
translate}}
</a>
<div>
<input class="form-control form-control" type="text" placeholder="ค้นหาสมาชิก"
<input class="form-control form-control" type="text" placeholder="ค้นหาเวอร์ชั่น"
aria-label=".form-control-sm example" [(ngModel)]='searchTerm'>
</div>
<!-- <div>
<input class="form-control form-control" type="text" placeholder="กรองตามบริษัท"
aria-label=".form-control-sm example" [(ngModel)]='searchTerm'>
</div> -->
<!-- <a href="javascript:void(0);" class="ti-btn ti-btn-primary-full !py-1 !px-2" aria-expanded="false">
เรียงตาม<i class="ri-arrow-down-s-line align-middle ms-1 inline-block"></i>
</a>
<ul class="hs-dropdown-menu ti-dropdown-menu hidden" role="menu">
<li><a class="ti-dropdown-item" href="javascript:void(0);">Newest</a></li>
<li><a class="ti-dropdown-item" href="javascript:void(0);">Oldest</a></li>
</ul> -->
</div>
</div>
<div class="box-body">
......@@ -62,29 +51,6 @@
[checked]="selectedItems.get(item.version)" (change)="onCheckboxChange(item.version)"
aria-label="..." value="">
</td>
<!-- <td>
<div class="flex items-center">
<span class="avatar avatar-sm p-1 me-1 bg-light !rounded-full">
<img [src]="item.getPicture()" alt="" id="profile-img">
</span>
<div class="ms-2">
<p class="font-semibold mb-0 flex items-center text-primary"><a (click)="view(item)">
{{item.getFullname()}}</a></p>
<p class="text-[0.75rem] text-muted mb-0">{{item.memberId}}</p>
</div>
</div>
</td> -->
<!-- <td>
<div class="flex">
<div class="ms-2">
<p class="font-semibold mb-0 flex items-center text-primary"><a (click)="view(item)"
data-hs-overlay="#modal-detail">
{{item.username}}</a></p>
<p class="text-[0.75rem] text-muted mb-0">{{item.memberId}}</p>
</div>
</div>
</td> -->
<td>
<div>
<span class="block">{{item.version}}</span>
......@@ -111,7 +77,7 @@
<a aria-label="anchor" (click)="view(item)"
class="ti-btn ti-btn-wave !gap-0 !m-0 bg-info/10 text-info hover:bg-info hover:text-white hover:border-info"><i
class="ri-pencil-line"></i></a>
<a aria-label="anchor" href="javascript:void(0);" (click)="deleteVersion(item.version)"
<a aria-label="anchor" href="javascript:void(0);" (click)="deleteVersion(item)"
class="ti-btn ti-btn-wave product-btn !gap-0 !m-0 bg-danger/10 text-danger hover:bg-danger hover:text-white hover:border-danger"><i
class="ri-delete-bin-line"></i></a>
</div>
......@@ -249,7 +215,6 @@
<!-- End:: Add Version Oldest -->
<ng-template #modalDetail let-modal>
<!-- <div id="modal-detail" class="hs-overlay hidden ti-modal [--overlay-backdrop:static]"> -->
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out">
<div class="ti-modal-content">
<div class="ti-modal-header flex justify-between items-center p-5">
......@@ -263,137 +228,117 @@
<i class="ri-close-line"></i>
</button>
</div>
<div class="ti-modal-body px-4">
<div class="!page">
<div class="grid grid-cols-12 gap-6">
<div class="xl:col-span-12 col-span-12">
<div class="box">
<div class="box-header flex justify-between items-center flex-wrap gap-4">
<!-- ฝั่งซ้าย -->
<div class="flex items-center gap-3">
<!-- <div class="box-title">
{{ 'Edit Version' | translate }}
<span class="badge bg-light text-default rounded-full ms-1 text-[0.75rem] align-middle">
{{ itemsList.length }}
</span>
</div> -->
<div class="ti-modal-body-content pt-6 pr-6 pl-6 pb-3 mb-4">
<div class="flex items-end justify-start md:justify-end">
<a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-primary-full w-full md:w-auto"
(click)="new()" data-hs-overlay="#modal-detail">
<i class="ri-add-line font-semibold align-middle"></i>
{{ 'Consent List' | translate }}
</a>
</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 *</label>
<input type="text" class="ti-form-input w-full"
[ngClass]="{ '!bg-input-readonly': modalStatus === 'edit' }" [(ngModel)]="consent.version"
[readonly]="modalStatus === 'edit'" />
<div class="text-danger text-sm mt-1" *ngIf="!consent.version">
Please fill in information
</div>
</div>
<div class="flex flex-col">
<label class="ti-form-label mb-2 text-primary font-bold">{{ 'Status' | translate }} </label>
</div>
<div class="flex flex-wrap gap-2">
<a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-primary-full me-2"
(click)="new()" data-hs-overlay="#modal-detail"><i
class="ri-add-line font-semibold align-middle"></i>{{ 'Consent List' |
translate}}
</a>
<div class="flex items-center space-x-6">
<label class="inline-flex items-center space-x-2">
<input type="radio" name="status" [(ngModel)]="consent.status" value="1" />
<span>{{ 'Active' | translate }}</span>
</label>
<label class="inline-flex items-center space-x-2">
<input type="radio" name="status" [(ngModel)]="consent.status" value="0" />
<span>{{ 'Unactive' | translate }}</span>
</label>
</div>
<a href="javascript:void(0);" class="hs-dropdown-toggle ti-btn ti-btn-danger-full me-2"
*ngIf="someSelected" (click)="deleteSelect()"><i
class="ri-delete-bin-line font-semibold align-middle"></i>{{ 'Delete' |
translate}}
</a>
<!-- <div>
<input class="form-control form-control" type="text" placeholder="ค้นหาสมาชิก"
aria-label=".form-control-sm example" [(ngModel)]='searchTerm'>
</div> -->
</div>
</div>
<div class="ti-modal-body-content " style="margin-top: 10px;">
<div class="sm:grid grid-cols-12 gap-x-6 space-y-4 lg:space-y-0">
<div
class="col-span-12 lg:col-span-5 sm:inline-flex sm:items-center space-y-2 sm:space-y-0 sm:space-x-3 w-full rtl:space-x-reverse"
style="margin-left: 10%;">
<label class="w-56 ti-form-label mb-0 text-primary font-bold">{{"Version" | translate}}
*</label>
<input type="text" class="my-auto ti-form-input w-full bg-input-readonly" readonly
[(ngModel)]="consent.version">
</div>
</div>
<div class="sm:grid grid-cols-12 gap-x-6 space-y-4 lg:space-y-0 mt-1">
<div
class="col-span-12 lg:col-span-5 sm:inline-flex sm:items-center space-y-2 sm:space-y-0 sm:space-x-3 w-full rtl:space-x-reverse"
style="margin-left: 10%;">
<label class="w-56 ti-form-label mb-0 text-primary font-bold">{{"Start Date" | translate}}
*</label>
<input type="text" class="my-auto ti-form-input w-full" [(ngModel)]="consent.startDate">
</div>
<div
class="col-span-12 lg:col-span-5 sm:inline-flex sm:items-center space-y-2 sm:space-y-0 sm:space-x-3 w-full rtl:space-x-reverse"
style="margin-left: 10%;">
<label class="w-56 ti-form-label mb-0 text-primary font-bold">{{"End Date" |
translate}}</label>
<input type="text" class="ti-form-input w-full" [(ngModel)]="consent.endDate">
</div>
</div>
<div class="text-danger text-sm mt-1" *ngIf="consent.status === null || consent.status === undefined">
Please fill in information
</div>
</div>
<div class="body-content mt-8">
<div class="!page">
<nav class="flex rtl:space-x-reverse space-x-2 border-b border-gray-200">
<a (click)="currentTab=1"
class="border w-32 justify-center rounded-4px hs-tab-active:!bg-primary hs-tab-active:border-primary hs-tab-active:!text-white -mb-px py-2 px-3 inline-flex items-center gap-2 font-size-16px font-weight-500 text-center text-gray-600 hover:text-gray-900 active"
href="javascript:void(0);" id="card-type-item-1" data-hs-tab="#card-type-1"
aria-controls="card-type-1">
ไทย
</a>
<a (click)="currentTab=2"
class="border w-32 justify-center rounded-4px hs-tab-active:!bg-primary hs-tab-active:border-primary hs-tab-active:!text-white -mb-px py-2 px-3 inline-flex items-center gap-2 font-size-16px font-weight-500 text-center text-gray-600 hover:text-gray-900"
href="javascript:void(0);" id="card-type-item-2" data-hs-tab="#card-type-2"
aria-controls="card-type-2">
อังกฤษ
</a>
<a (click)="currentTab=3"
class="border w-32 justify-center rounded-4px hs-tab-active:!bg-primary hs-tab-active:border-primary hs-tab-active:!text-white -mb-px py-2 px-3 inline-flex items-center gap-2 font-size-16px font-weight-500 text-center text-gray-600 hover:text-gray-900"
href="javascript:void(0);" id="card-type-item-3" data-hs-tab="#card-type-3"
aria-controls="card-type-3">
จีน
</a>
</nav>
<div class="pt-50px">
<div *ngIf="currentTab==1" id="card-type-1" role="tabpanel"
aria-labelledby="card-type-item-1">
<quill-editor [modules]="quillConfig" [styles]="{'max-height': '200px','overflow-y': 'auto'}"
[(ngModel)]="consent.requestConsentThai" [ngModelOptions]="{standalone: true}"
theme="snow">
</quill-editor>
</div>
<div *ngIf="currentTab==2" id="card-type-2" role="tabpanel"
aria-labelledby="card-type-item-2">
<quill-editor [modules]="quillConfig" [styles]="{'max-height': '200px','overflow-y': 'auto'}"
[(ngModel)]="consent.requestConsentEng" [ngModelOptions]="{standalone: true}"
theme="snow">
</quill-editor>
</div>
<div *ngIf="currentTab==3" id="card-type-3" role="tabpanel"
aria-labelledby="card-type-item-3">
<quill-editor [modules]="quillConfig" [styles]="{'max-height': '200px','overflow-y': 'auto'}"
[(ngModel)]="consent.requestConsentChina" [ngModelOptions]="{standalone: true}"
theme="snow">
</quill-editor>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="flex flex-col">
<label class="ti-form-label mb-2 text-primary font-bold">Start Date </label>
<input type="datetime-local" class="ti-form-input w-full" [(ngModel)]="consent.startDate" />
<div class="text-danger text-sm mt-1" *ngIf="!consent.startDate">
Please fill in information
</div>
</div>
<div class="flex flex-col">
<label class="ti-form-label mb-2 text-primary font-bold">End Date</label>
<input type="datetime-local" class="ti-form-input w-full" [(ngModel)]="consent.endDate" />
<div class="text-danger text-sm mt-1" *ngIf="!consent.endDate">
Please fill in information
</div>
</div>
</div>
<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);">
ไทย
</a>
<a (click)="currentTab = 2" class="tab-btn" [ngClass]="{
'!bg-primary border-primary !text-white': currentTab === 2
}" href="javascript:void(0);">
อังกฤษ
</a>
<a (click)="currentTab = 3" class="tab-btn" [ngClass]="{
'!bg-primary border-primary !text-white': currentTab === 3
}" href="javascript:void(0);">
จีน
</a>
</nav>
<div>
<div *ngIf="currentTab == 1">
<quill-editor [modules]="quillConfig" [styles]="{ 'height': '400px', 'overflow-y': 'auto' }"
[(ngModel)]="consent.requestConsentThai" [ngModelOptions]="{ standalone: true }"
theme="snow"></quill-editor>
</div>
<div *ngIf="currentTab == 2">
<quill-editor [modules]="quillConfig" [styles]="{ 'height': '400px', 'overflow-y': 'auto' }"
[(ngModel)]="consent.requestConsentEng" [ngModelOptions]="{ standalone: true }"
theme="snow"></quill-editor>
</div>
<div *ngIf="currentTab == 3">
<quill-editor [modules]="quillConfig" [styles]="{ 'height': '400px', 'overflow-y': 'auto' }"
[(ngModel)]="consent.requestConsentChina" [ngModelOptions]="{ standalone: true }"
theme="snow"></quill-editor>
</div>
</div>
</div>
</div>
<div class="ti-modal-footer flex justify-center gap-4">
<button type="button" class="hs-dropdown-toggle ti-btn ti-btn-light align-middle"
data-hs-overlay="#modal-detail">
<div class="ti-modal-footer flex justify-center gap-4 mb-3">
<button type="button" class="hs-dropdown-toggle ti-btn bg-danger align-middle text-white !font-medium"
(click)="modalRef.close()" #closeModal>
{{'Cancel' | translate}}
</button>
<button type="button" (click)="save()" class="ti-btn bg-primary text-white !font-medium">{{'Save' |
translate}}</button>
<button type="button" (click)="save()" [disabled]="isSaving"
class="ti-btn bg-primary text-white !font-medium">
{{ isSaving ? ('Saving...' | translate) : ('Save' | translate) }}
</button>
</div>
</div>
</div>
<!-- </div> -->
</ng-template>
</ng-container>
<ng-container *ngIf="edit">
<app-pdpa-config [pdpaconfig]="pdpaconfig" (sendEdit)="edit=false"></app-pdpa-config>
</ng-container>
</ng-container>
\ No newline at end of file
......@@ -40,23 +40,19 @@ import { MatDialog } from "@angular/material/dialog";
export class PdpaManageComponent {
quillConfig = {
toolbar: [
['link'], // เพิ่มปุ่มลิงก์
['bold', 'italic', 'underline', 'strike'], // toggled buttons
['link'],
['bold', 'italic', 'underline', 'strike'],
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }], // custom button values
[{ 'header': 1 }, { 'header': 2 }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'script': 'sub' }, { 'script': 'super' }], // superscript/subscript
[{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent
[{ 'direction': 'rtl' }], // text direction
[{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
[{ 'script': 'sub' }, { 'script': 'super' }],
[{ 'indent': '-1' }, { 'indent': '+1' }],
[{ 'direction': 'rtl' }],
[{ 'size': ['small', false, 'large', 'huge'] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
[{ 'color': [] }, { 'background': [] }],
[{ 'align': [] }],
['clean'], // remove formatting button
['clean'],
]
};
@ViewChild('closeModal') public childModal?: ElementRef;
......@@ -69,21 +65,16 @@ export class PdpaManageComponent {
currentTab = 1
// modalStatus = "new";
allSelected = false;
someSelected = false;
confirmPassword = ""
itemsList: MyPdpaConsentModel[] = []
filterList: MyPdpaConsentModel[] = []
consent: MyPdpaConsentModel = new MyPdpaConsentModel()
selectedItems = new Map<string, boolean>();
roleList: MyPdpaConsentModel[] = []
empList: MyPdpaConsentModel[] = []
descName = 'engName'
pageIndex = 0;
uploaderProfile: FileUploader | undefined;
uploadErrorMsg: string = "";
modalStatus: "add" | "edit" = "add"
isSaving = false;
get searchTerm(): string {
return this._searchTerm;
......@@ -99,23 +90,11 @@ export class PdpaManageComponent {
}
}
editVersion(version: string) {
this.pdpaService.getConfigList().subscribe(res => {
const matched = res.find(item => item.version === version);
if (matched) {
this.pdpaconfig = new MyPdpaConsentModel(matched, this.translate);
this.edit = true;
}
});
}
_searchTerm = "";
constructor(private pdpaService: PdpaService, public translate: TranslateService, private tokenService: TokenService, private router: Router, private modal: MatDialog) {
constructor(private pdpaService: PdpaService, public translate: TranslateService, private modal: MatDialog) {
}
ngOnInit(): void {
this.pdpaService.getConfigList().subscribe(res => {
this.itemsList = res.map(item => new MyPdpaConsentModel(item, this.translate));
......@@ -123,30 +102,6 @@ export class PdpaManageComponent {
});
}
createNewVersion() {
this.router.navigate(['/admin/pdpa-config/new']);
}
deleteVersion(version: string) {
swal({
title: "ยืนยันลบเวอร์ชัน?",
text: version,
icon: "warning",
dangerMode: true,
buttons: ["ยกเลิก", "ลบ"]
}).then(confirm => {
if (confirm) {
this.pdpaService.deleteConfig(version).subscribe(() => {
swal("สำเร็จ", "ลบเวอร์ชันเรียบร้อย", "success");
this.ngOnInit();
});
}
});
}
filter(v: string): MyPdpaConsentModel[] {
const search = v.toLowerCase();
return this.itemsList.filter(x =>
......@@ -157,107 +112,99 @@ export class PdpaManageComponent {
);
}
delete(item: PdpaModel) {
swal({
title: "Are you sure?",
text: "You won't be able to revert this!",
icon: "warning",
dangerMode: true,
buttons: ["Cancel", "Yes,Delete it!"],
})
.then((willDelete: any) => {
if (willDelete) {
this.pdpaService.deletePost(item).subscribe(result => {
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
this.ngOnInit()
})
}
});
}
new() {
this.modalStatus = 'add'
this.openModal()
this.consent = new MyPdpaConsentModel()
this.consent = new MyPdpaConsentModel(); // สร้างอ็อบเจกต์ใหม่เสมอเมื่อเปิดหน้าต่างเพิ่ม
this.openModal();
}
view(item: MyPdpaConsentModel) {
this.modalStatus = 'edit'
this.confirmPassword = ''
this.openModal()
this.modalStatus = 'edit';
// สร้าง MyPdpaConsentModel ใหม่จาก item เพื่อให้ไม่กระทบข้อมูลเดิม
// และเรียกใช้ formatDatesForDatetimeLocal เพื่อปรับรูปแบบวันที่
this.consent = new MyPdpaConsentModel(item, this.translate);
this.formatDatesForDatetimeLocal(this.consent); // เพิ่มโค้ดนี้
this.openModal();
}
// --- เพิ่มฟังก์ชันนี้เข้าไปในคลาส PdpaManageComponent ---
private formatDatesForDatetimeLocal(consentModel: MyPdpaConsentModel): void {
if (consentModel.startDate) {
// ตัดสตริงให้เหลือแค่ YYYY-MM-DDTHH:mm
consentModel.startDate = consentModel.startDate.substring(0, 16);
}
if (consentModel.endDate) {
// ตัดสตริงให้เหลือแค่ YYYY-MM-DDTHH:mm
consentModel.endDate = consentModel.endDate.substring(0, 16);
}
}
// ----------------------------------------------------
save() {
if (this.isSaving) return;
swal({
title: "Are you sure?",
text: "คุณต้องการบันทึกหรือไม่",
icon: "warning",
dangerMode: false,
buttons: ["Cancel", "Confirm"],
})
.then((willDelete: any) => {
if (willDelete) {
console.log(this.consent);
// if (this.modalStatus == 'add') {
// this.pdpaService.postPdpa(this.consent).subscribe(result => {
// console.log(result)
// swal("Save Success!!", "บันทึกข้อมูลสมาชิก", "success");
// this.ngOnInit()
// this.childModal?.nativeElement.click()
// })
// } else if (this.modalStatus == 'edit') {
// this.pdpaService.postPdpa(this.consent).subscribe(result => {
// console.log(result)
// swal("Update Success!!", "บันทึกข้อมูลสมาชิก", "success");
// this.ngOnInit()
// this.childModal?.nativeElement.click()
// })
// }
}
});
}).then(willSave => {
if (willSave) {
this.isSaving = true;
// 🔧 สร้าง payload เปล่า (ถ้ายังไม่ได้แก้ class)
const payload = {
version: this.consent.version,
startDate: this.consent.startDate,
endDate: this.consent.endDate,
status: this.consent.status,
requestConsentThai: this.consent.requestConsentThai,
requestConsentEng: this.consent.requestConsentEng,
requestConsentChina: this.consent.requestConsentChina
};
this.pdpaService.postConfig(payload).subscribe({
next: res => {
swal("Success", "บันทึกแล้ว", "success");
this.isSaving = false;
this.ngOnInit();
this.modalRef.close();
},
error: err => {
swal("Error", "เกิดข้อผิดพลาด", "error");
this.isSaving = false;
}
});
}
});
}
updatePagedItems() {
const startIndex = this.pageIndex * 10;
const endIndex = startIndex + 10;
this.filterList = this.itemsList.slice(startIndex, endIndex);
}
toggleAll(event: any) {
this.allSelected = event.target.checked;
this.selectedItems.clear();
this.itemsList.forEach(item => {
this.selectedItems.set(item.version, this.allSelected);
deleteVersion(item: PdpaConsentModel) {
swal({
title: "Are you sure?",
text: "You won't be able to revert this!",
icon: "warning",
dangerMode: true,
buttons: ["Cancel", "Yes,Delete it!"],
}).then((willDelete: any) => {
if (willDelete) {
this.pdpaService.deleteConfig(item.version).subscribe(result => {
swal("Delete Success!!", "ลบข้อมูลสำเร็จ", "success");
this.ngOnInit();
});
}
});
this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.version));
}
onCheckboxChange(version: string) {
const isSelected = this.selectedItems.get(version) || false;
this.selectedItems.set(version, !isSelected);
this.allSelected = this.itemsList.every(item => this.selectedItems.get(item.version));
this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.version));
}
deleteSelect() {
let employeeInfo = '';
this.selectedItems.forEach((isSelected, version) => {
if (isSelected) {
const user = this.itemsList.find(user => user.version === version) as MyPdpaConsentModel;
if (user) {
employeeInfo += `${this.translate.instant('version')}: ${user.version}\n`;
const pdpa = this.itemsList.find(pdpa => pdpa.version === version) as MyPdpaConsentModel;
if (pdpa) {
employeeInfo += `${this.translate.instant('version')}: ${pdpa.version}\n`;
}
}
});
......@@ -273,10 +220,10 @@ export class PdpaManageComponent {
if (willDelete) {
this.selectedItems.forEach((isSelected, version) => {
if (isSelected) {
const user = this.itemsList.find(user => user.version === version);
if (user) {
this.pdpaService.deletePost(user).subscribe(result => {
swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
const pdpa = this.itemsList.find(pdpa => pdpa.version === version);
if (pdpa) {
this.pdpaService.deleteConfig(version).subscribe(result => {
swal("Delete Success!!", "ลบข้อมูลที่เลือกสำเร็จ", "success");
this.ngOnInit();
});
}
......@@ -286,46 +233,32 @@ export class PdpaManageComponent {
});
}
// adjustSelect(status: number) {
// let title = "Are you sure?"
// let employeeInfo = ''; // ตัวแปรสำหรับเก็บข้อมูลพนักงาน
// this.selectedItems.forEach((isSelected, version) => {
// if (isSelected) {
// const user = this.itemsList.find(user => user.version === version);
// if (user) {
// employeeInfo += `${this.translate.instant('Fullname')}: ${user.getFullname()}\n`;
// }
// }
// });
// swal({
// title: title,
// text: employeeInfo,
// icon: "warning",
// dangerMode: false,
// buttons: ["Cancel", "Confirm"],
// })
// .then((willDelete: any) => {
// if (willDelete) {
// this.selectedItems.forEach((isSelected, version) => {
// if (isSelected) {
// const user = this.itemsList.find(user => user.version === version);
// if (user) {
// user.pdpa.status = status
// this.pdpaService.postPdpa(user).subscribe(result => {
// swal("Save Success!!", "บันทึกข้อมูลสำเร็จ", "success");
// this.ngOnInit();
// });
// }
// }
// });
// }
updatePagedItems() {
const startIndex = this.pageIndex * 10;
const endIndex = startIndex + 10;
this.filterList = this.itemsList.slice(startIndex, endIndex);
}
// });
// }
toggleAll(event: any) {
this.allSelected = event.target.checked;
this.selectedItems.clear();
this.itemsList.forEach(item => {
this.selectedItems.set(item.version, this.allSelected);
});
this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.version));
}
onCheckboxChange(version: string) {
const isSelected = this.selectedItems.get(version) || false;
this.selectedItems.set(version, !isSelected);
this.allSelected = this.itemsList.every(item => this.selectedItems.get(item.version));
this.someSelected = this.itemsList.some(item => this.selectedItems.get(item.version));
}
openModal() {
this.modalRef = this.modal.open(this.modalDetail, {
width: '1000px',
width: '1500px',
height: '750px'
})
}
......@@ -334,7 +267,7 @@ export class PdpaManageComponent {
}
filterEmp(empId: string) {
this.consent = this.empList.filter(e => e.version == empId)[0]
this.consent = this.itemsList.filter(e => e.version == empId)[0]
}
}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ export class MyPdpaModel extends BaseModel implements PdpaModel {
pdpa: PdpaConsentModel
consentStatus: boolean
constructor(data?: Partial<PdpaModel>, translateService?: TranslateService) {
super(data, translateService)
super(data)
this.profileId = data?.profileId || ''
this.thFirstname = data?.thFirstname || ''
this.engFirstname = data?.engFirstname || ''
......
......@@ -114,13 +114,6 @@ export class NavService implements OnDestroy {
title: 'จัดการบทความ',
type: 'link',
},
{
icon: 'user-check',
path: '/admin/admin-manage',
title: 'จัดการสิทธิ์ผู้ดูแลระบบ',
type: 'link',
},
{
icon: 'news',
......@@ -128,6 +121,14 @@ export class NavService implements OnDestroy {
title: 'จัดการ PDPA',
type: 'link',
},
{
icon: 'user-check',
path: '/admin/admin-manage',
title: 'จัดการสิทธิ์ผู้ดูแลระบบ',
type: 'link',
},
// { headTitle: 'User Management' },
];
......
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