Commit 1bc97f85 by Nattana Chaiyamat

จัดกลุ่มสมรรถนะ

parent a02b5d6b
...@@ -53,17 +53,18 @@ ...@@ -53,17 +53,18 @@
<!-- Content ของ div แรก --> <!-- Content ของ div แรก -->
<div class="flex gap-x-6"> <div class="flex gap-x-6">
<div class="flex items-center"> <div class="flex items-center">
<label for="hs-checkbox-group-1" <input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{dataSelectList.length}} [(ngModel)]="isDataListChecked">
Selected</label> <label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div> </div>
<div class="mx-1 flex items-center">
<div class="flex items-center"> <button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
<i (click)="toggleCheckbox()" class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
[ngClass]="{'ri-checkbox-multiple-line': !isChecked, 'ri-checkbox-multiple-fill': isChecked}" <i class="fs-l transition-all duration-200"
class="ri-checkbox-multiple-line text-gray-500 dark:text-white/70"></i> [ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
<label for="hs-checkbox-group-2" class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70" </button>
(click)="toggleCheckbox()">Select All</label> <label class="text-sm text-gray-500 ml-2">Select All</label>
</div> </div>
</div> </div>
</div> </div>
...@@ -96,7 +97,7 @@ ...@@ -96,7 +97,7 @@
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-20px m-0 shadow-md" <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-20px m-0 shadow-md"
data-hs-overlay="#edit-group-competencies-alert-delete-modal"> data-hs-overlay="#edit-group-competencies-alert-delete-modal" (click)="groupAssessmentIndex=-1">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
...@@ -151,7 +152,7 @@ ...@@ -151,7 +152,7 @@
<td class="text-center"> <td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" <input type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}" id="checkbox-{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}"
[(ngModel)]="item.check" (change)="checkSelect()"> [(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
<label <label
for="checkbox-{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}"> for="checkbox-{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}">
&nbsp;{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}} &nbsp;{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}
...@@ -165,7 +166,8 @@ ...@@ -165,7 +166,8 @@
</td> </td>
<td class="flex justify-center"> <td class="flex justify-center">
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#edit-group-competencies-alert-delete-modal"></i> data-hs-overlay="#edit-group-competencies-alert-delete-modal"
(click)="groupAssessmentIndex=i"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -258,7 +260,7 @@ ...@@ -258,7 +260,7 @@
<thead> <thead>
<tr> <tr>
<ng-container <ng-container
*ngFor="let item of ['รหัส','ชื่อประเภท','ระดับความหวัง','การจัดการ']; let f = first; let l = last; let i = index"> *ngFor="let item of ['รหัส','ชื่อประเภท','ระดับความคาดหวัง','การจัดการ']; let f = first; let l = last; let i = index">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary" <th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f||l"> [class.!text-center]="f||l">
<span class="text-sm">{{ item }}</span> <span class="text-sm">{{ item }}</span>
...@@ -305,13 +307,7 @@ ...@@ -305,13 +307,7 @@
<tr <tr
*ngFor="let item of dataListModalFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of dataListModalFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" {{item.data.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}
id="checkbox-{{item.data.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}"
[(ngModel)]="item.check" (change)="checkSelect()">
<label
for="checkbox-{{item.data.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}">
&nbsp;{{item.data.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}
</label>
</td> </td>
<td style="font-size: 12px; width: 60%;"> <td style="font-size: 12px; width: 60%;">
{{item.data.competencyIndicatorsCourses0.tdesc}} {{item.data.competencyIndicatorsCourses0.tdesc}}
......
...@@ -24,12 +24,18 @@ export class EditGroupCompetenciesComponent { ...@@ -24,12 +24,18 @@ export class EditGroupCompetenciesComponent {
search = "" search = ""
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
isChecked: boolean = false;
searchModal = "" searchModal = ""
currentPageModal = 1 currentPageModal = 1
dataLoading = false dataLoading = false
dataModalLoading = false dataModalLoading = false
groupAssessmentIndex = -1
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
constructor(private toastr: ToastrService, constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private groupAssessmentService: GroupAssessmentService, private groupAssessmentService: GroupAssessmentService,
...@@ -43,17 +49,6 @@ export class EditGroupCompetenciesComponent { ...@@ -43,17 +49,6 @@ export class EditGroupCompetenciesComponent {
onEdit() { onEdit() {
this.sendEdit.emit(false); this.sendEdit.emit(false);
} }
checkSelect() {
this.dataSelectList = this.dataList.filter(item => item.check).map(item => item.data);
}
toggleCheckbox() {
this.isChecked = !this.isChecked;
this.dataList.forEach((item) => {
item.check = this.isChecked;
});
this.checkSelect();
}
getGroupAssessmentById() { getGroupAssessmentById() {
this.dataLoading = true; this.dataLoading = true;
...@@ -76,6 +71,7 @@ export class EditGroupCompetenciesComponent { ...@@ -76,6 +71,7 @@ export class EditGroupCompetenciesComponent {
this.currentPage = 1; this.currentPage = 1;
const filteredData = this.dataListFilter(); const filteredData = this.dataListFilter();
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
dataListFilter() { dataListFilter() {
return this.dataList return this.dataList
...@@ -90,14 +86,12 @@ export class EditGroupCompetenciesComponent { ...@@ -90,14 +86,12 @@ export class EditGroupCompetenciesComponent {
.sort((a, b) => { .sort((a, b) => {
const topicA = a.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase(); const topicA = a.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase();
const topicB = b.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase(); const topicB = b.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase();
const expectationA = a.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLowerCase(); const expectationA = a.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLowerCase();
const expectationB = b.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLowerCase(); const expectationB = b.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLowerCase();
return topicA.localeCompare(topicB) || expectationA.localeCompare(expectationB); return topicA.localeCompare(topicB) || expectationA.localeCompare(expectationB);
}); });
} }
getIndicatorsCoursesList() { getIndicatorsCoursesList() {
...@@ -122,6 +116,8 @@ export class EditGroupCompetenciesComponent { ...@@ -122,6 +116,8 @@ export class EditGroupCompetenciesComponent {
competencyIndicatorsCourses1Mini: new MyCompetencyIndicatorsCourses1MiniModel(data) competencyIndicatorsCourses1Mini: new MyCompetencyIndicatorsCourses1MiniModel(data)
}) })
}) })
this.isDataListCheckedAll = false
this.dataListCheckAll()
} }
searchModalChange() { searchModalChange() {
...@@ -133,6 +129,9 @@ export class EditGroupCompetenciesComponent { ...@@ -133,6 +129,9 @@ export class EditGroupCompetenciesComponent {
dataListModalFilter() { dataListModalFilter() {
return this.dataListModal.filter(x => { return this.dataListModal.filter(x => {
const data = x.data const data = x.data
if (this.dataList.some(y => y.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation == data.competencyIndicatorsCourses0.expectation)) {
return
}
const match = data.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase().includes(this.searchModal.toLowerCase()) || const match = data.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase().includes(this.searchModal.toLowerCase()) ||
data.competencyIndicatorsCourses0.tdesc.toLowerCase().includes(this.searchModal.toLowerCase()) || data.competencyIndicatorsCourses0.tdesc.toLowerCase().includes(this.searchModal.toLowerCase()) ||
data.competencyIndicatorsCourses0.expectation.toLocaleLowerCase().includes(this.searchModal.toLocaleLowerCase()) data.competencyIndicatorsCourses0.expectation.toLocaleLowerCase().includes(this.searchModal.toLocaleLowerCase())
...@@ -141,7 +140,7 @@ export class EditGroupCompetenciesComponent { ...@@ -141,7 +140,7 @@ export class EditGroupCompetenciesComponent {
} }
saveGroupAssessment1() { saveGroupAssessment1() {
this.groupCompetencies.groupAssessment1List = this.dataList.map(x => x.data); this.groupCompetencies.groupAssessment1List = this.dataList.map(x => new MyGroupAssessment1ListModel(x.data))
this.groupAssessmentService.post(this.groupCompetencies).subscribe({ this.groupAssessmentService.post(this.groupCompetencies).subscribe({
next: (response) => { next: (response) => {
if (response.success) { if (response.success) {
...@@ -157,22 +156,36 @@ export class EditGroupCompetenciesComponent { ...@@ -157,22 +156,36 @@ export class EditGroupCompetenciesComponent {
} }
deleteGroupAssessmentById() { deleteGroupAssessmentById() {
const selectedItems = this.dataList.filter(item => item.check); this.dataList = this.dataList.filter((item, i) => (this.groupAssessmentIndex == -1 ? !item.check : i != this.groupAssessmentIndex));
this.isDataListCheckedAll = false
if (selectedItems.length > 0) { this.dataListCheckAll()
this.dataList = this.dataList.filter(item => !item.check);
} else if (this.dataList.length > 0) {
this.dataList.pop();
}
this.cdr.detectChanges(); this.cdr.detectChanges();
this.showAlert('ลบข้อมูลสำเร็จ', 'success');
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}) })
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.dataList
.filter(x => {
const data = x.data;
const match =
data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase().includes(this.search.toLowerCase()) ||
data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLowerCase().includes(this.search.toLowerCase());
return match;
}).forEach(x => (x.check = selectAll));
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.dataListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
} }
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