Commit fe3d7fa2 by Nakarin Luankla

Merge branch 'DEV' of https://mygit.myhr.co.th/angular/myAppraisal into DEV

parents 3c5bbb03 f61fc5dd
...@@ -11,34 +11,31 @@ ...@@ -11,34 +11,31 @@
<a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary active" <a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary active"
href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1" href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1"
aria-controls="underline-1" aria-controls="underline-1"
(click)="pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','ตัวชี้วัดเเละหลักสูตร']"> (click)="currentPath = 1;pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','ตัวชี้วัดเเละหลักสูตร']">
ตัวชี้วัดเเละหลักสูตร ตัวชี้วัดเเละหลักสูตร
</a> </a>
<a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary" <a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary"
href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2" href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2"
aria-controls="underline-2" aria-controls="underline-2"
(click)="pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','จัดกลุ่มสมรรถนะ']"> (click)="currentPath = 2;pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','จัดกลุ่มสมรรถนะ']">
จัดกลุ่มสมรรถนะ จัดกลุ่มสมรรถนะ
</a> </a>
<a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary" <a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary"
href="javascript:void(0);" id="underline-item-3" data-hs-tab="#underline-3" href="javascript:void(0);" id="underline-item-3" data-hs-tab="#underline-3"
aria-controls="underline-3" aria-controls="underline-3"
(click)="pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','กำหนดผู้ประเมิน']"> (click)="currentPath = 3;pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','กำหนดผู้ประเมิน']">
กำหนดผู้ประเมิน กำหนดผู้ประเมิน
</a> </a>
</nav> </nav>
</div> </div>
<div class="mt-3 px-3rem !-mt-3 pt-50px"> <div class="mt-3 px-3rem !-mt-3 pt-50px">
<div id="underline-1" role="tabpanel" aria-labelledby="underline-item-1"> <div *ngIf="currentPath==1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-indicators-and-curriculum (sendPathTitle)="pathTitle=$event"></app-indicators-and-curriculum> <app-indicators-and-curriculum (sendPathTitle)="pathTitle=$event"></app-indicators-and-curriculum>
</div> </div>
<div id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2"> <div *ngIf="currentPath==2" id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2">
<app-group-competencies *ngIf="groupShow=='1'" [pathTitle]="pathTitle" <app-group-competencies (sendPathTitle)="pathTitle=$event" ></app-group-competencies>
(sendPathTitle)="pathTitle=$event" (sendGroupShow)="groupShow=$event"></app-group-competencies>
<app-edit-group-competencies *ngIf="groupShow=='2'" [pathTitle]="pathTitle"
(sendPathTitle)="pathTitle=$event" (sendGroupShow)="groupShow=$event"></app-edit-group-competencies>
</div> </div>
<div id="underline-3" class="hidden" role="tabpanel" aria-labelledby="underline-item-3"> <div *ngIf="currentPath==3" id="underline-3" class="hidden" role="tabpanel" aria-labelledby="underline-item-3">
<app-set-approvers [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-set-approvers> <app-set-approvers [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-set-approvers>
</div> </div>
</div> </div>
......
...@@ -7,5 +7,5 @@ import { Component } from '@angular/core'; ...@@ -7,5 +7,5 @@ import { Component } from '@angular/core';
}) })
export class CompetencyManagementComponent { export class CompetencyManagementComponent {
pathTitle = ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ','ตัวชี้วัดและหลักสูตร'] pathTitle = ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ','ตัวชี้วัดและหลักสูตร']
groupShow = '1' currentPath = 1
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex"> <div class="flex">
<button type="button" class="ti-btn ti-btn-outline ti-btn-outline-light h-20px m-0 shadow-md text-blue-500" <button type="button" class="ti-btn ti-btn-outline ti-btn-outline-light h-20px m-0 shadow-md text-blue-500"
(click)="onBack()"> (click)="onEdit()">
<i class="ti ti-chevron-left"></i> <i class="ti ti-chevron-left"></i>
ย้อนกลับ ย้อนกลับ
</button> </button>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="py-2 border-b-2 border-collapse "> <div *ngIf="pl" class="py-2 border-b-2 border-collapse ">
<div class="grid grid-cols-3 gap-6"> <div class="grid grid-cols-3 gap-6">
<div class="col-span-1"> <div class="col-span-1">
<label for="hs-trailing-button-add-on-with-icon" class="ti-form-label">รหัส</label> <label for="hs-trailing-button-add-on-with-icon" class="ti-form-label">รหัส</label>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<div class="col-span-1"> <div class="col-span-1">
<input type="text" id="input-label" <input type="text" id="input-label"
class="py-2 px-3 ltr:pr-11 rtl:pl-11 ti-form-input w-2/3 rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly" class="py-2 px-3 ltr:pr-11 rtl:pl-11 ti-form-input w-2/3 rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly"
readonly value="O1O2"> readonly [(ngModel)]="pl.plId">
</div> </div>
</div> </div>
<div class="grid grid-cols-3 gap-6 mt-5"> <div class="grid grid-cols-3 gap-6 mt-5">
...@@ -37,12 +37,12 @@ ...@@ -37,12 +37,12 @@
<div class="col-span-1"> <div class="col-span-1">
<input type="text" id="input-label" <input type="text" id="input-label"
class="py-2 px-3 ltr:pr-11 rtl:pl-11 ti-form-input w-2/3 rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly" class="py-2 px-3 ltr:pr-11 rtl:pl-11 ti-form-input w-2/3 rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly"
readonly value="พนักงานระดับ O1-O2"> readonly [(ngModel)]="pl.tdesc">
</div> </div>
<div class="col-span-1"> <div class="col-span-1">
<input type="text" id="input-label" <input type="text" id="input-label"
class="py-2 px-3 ltr:pr-11 rtl:pl-11 ti-form-input w-2/3 rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly" class="py-2 px-3 ltr:pr-11 rtl:pl-11 ti-form-input w-2/3 rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly"
readonly value="Employee level 01-02"> readonly [(ngModel)]="pl.edesc">
</div> </div>
</div> </div>
</div> </div>
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<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" <label for="hs-checkbox-group-1"
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{checkSelect()}} class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{dataSelectList.length}}
Selected</label> Selected</label>
</div> </div>
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
style="height: 40px;"> style="height: 40px;" [(ngModel)]="search" (ngModelChange)="searchChange()">
<div <div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i> <i class="ri-search-line text-gray"></i>
...@@ -128,59 +128,89 @@ ...@@ -128,59 +128,89 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody> <tbody *ngIf="dataLoading">
<tr *ngFor="let item of mockDataList;let i = index"> <tr>
<td class="flex justify-center items-center" style="height: 40px; font-size: 12px;"> <td class="text-center" colspan="100%">
<input class="mr-1" type="checkbox" style="transform: scale(0.7);" <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1"
[(ngModel)]="item.checked"> role="status" aria-label="loading">
<span style="display: inline-block;" class="w-10">{{ item.id}}</span> <span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&!dataListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&dataListFilter().length">
<tr
*ngFor="let item of dataListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}"
[(ngModel)]="item.check" (change)="checkSelect()">
<label
for="checkbox-{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}">
&nbsp;{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId}}
</label>
</td>
<td style="font-size: 12px; width: 60%;">
{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.tdesc}}
</td>
<td style="font-size: 12px;text-align: center;">
{{item.data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation}}
</td> </td>
<td style="font-size: 12px; width: 60%;">{{item.name}}</td>
<td style="font-size: 12px;text-align: center;">{{item.level}}</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"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
<div class="body-content" style="margin-top: 20px;"> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="nav-tabs"> <ul class="ti-pagination">
<div class="px-1 py-1 bg-white rounded-2 shadow justify-content-center align-items-center"> <li>
<div class="box-body"> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
<nav class="pagination-style-3 overflow-auto"> (click)="currentPage = (currentPage-1 || 1)">
<ul class="ti-pagination"> <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
<li> </a>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> </li>
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i> <li *ngFor="let item of page;let f = first;let l = last">
</a> <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
</li> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
<li><a class="page-link active" href="javascript:void(0);" aria-current="page">1</a> </a>
</li> </ng-container>
<li><a class="page-link" href="javascript:void(0);">2</a></li> <ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<li><a class="page-link" href="javascript:void(0);">3</a></li> <a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
<li><a class="page-link" href="javascript:void(0);">4</a></li> (click)="currentPage=item">{{item}}
<li><a class="page-link" href="javascript:void(0);">5</a></li> </a>
<li><a class="page-link" href="javascript:void(0);">...</a></li> </ng-container>
<li><a class="page-link" href="javascript:void(0);">31</a></li> <ng-container
<li> *ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i> </a>
</a> </ng-container>
</li> </li>
</ul> <li>
</nav> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
</div> (click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
</div> <i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul> </ul>
<ul class="nav-tabs mt-1"> <ul class="nav-tabs mt-3">
<p>Show 1 to 10 of 50 items</p> <span>Show {{((currentPage-1) * 10)+1}} to {{dataListFilter().length<10 ?dataListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - dataListFilter().length) )
:(currentPage * 10) ) }} of {{dataListFilter().length}} items</span>
</ul> </ul>
</div> </nav>
</div> </div>
...@@ -207,7 +237,8 @@ ...@@ -207,7 +237,8 @@
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name"> placeholder="Search by No. or Name" [(ngModel)]="searchModal"
(ngModelChange)="searchModalChange()">
<div <div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i> <i class="ri-search-line text-gray"></i>
...@@ -253,21 +284,45 @@ ...@@ -253,21 +284,45 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody> <tbody *ngIf="dataLoading">
<tr *ngFor="let item of[ <tr>
['CC-01', 'จิตสำนึกด้านความปลอดภัยและคุณภาพ (Safety & Quality)','1'], <td class="text-center" colspan="100%">
['CC-01', 'จิตสำนึกด้านความปลอดภัยและคุณภาพ (Safety & Quality)','2'], <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1"
['CC-01', 'จิตสำนึกด้านความปลอดภัยและคุณภาพ (Safety & Quality)','3'], role="status" aria-label="loading">
['CC-01', 'จิตสำนึกด้านความปลอดภัยและคุณภาพ (Safety & Quality)','4'], <span class="sr-only">Loading...</span>
['CC-01', 'จิตสำนึกด้านความปลอดภัยและคุณภาพ (Safety & Quality)','5'], </div>
['CC-01', 'จิตสำนึกด้านความปลอดภัยและคุณภาพ (Safety & Quality)','6']];let i = index"> </td>
<td class="flex justify-center" style="font-size: 12px;">{{item[0]}}</td> </tr>
<td style="font-size: 12px; width: 60%;">{{item[1]}}</td> </tbody>
<td style="font-size: 12px; width: 15%; text-align: center;">{{item[2]}}</td> <tbody *ngIf="!dataLoading&&!dataListModalFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&dataListModalFilter().length">
<tr
*ngFor="let item of dataListModalFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer"
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 style="font-size: 12px; width: 60%;">
{{item.data.competencyIndicatorsCourses0.tdesc}}
</td>
<td style="font-size: 12px;text-align: center;">
{{item.data.competencyIndicatorsCourses0.expectation}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<div class="px-1"> <div class="px-1">
<button type="button" <button type="button"
class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
(click)="selectIndicatorsCourses(item.data)"
data-hs-overlay="#edit-group-competencies-table-modal-select"> data-hs-overlay="#edit-group-competencies-table-modal-select">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Select Select
...@@ -279,39 +334,46 @@ ...@@ -279,39 +334,46 @@
</table> </table>
</div> </div>
</div> </div>
<div class="body-content" style="margin-top: 20px;"> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="nav-tabs"> <ul class="ti-pagination">
<div class="px-1 bg-white rounded-2 shadow justify-content-center align-items-center"> <li>
<div class="box-body"> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
<nav class="pagination-style-3 overflow-auto"> (click)="currentPage = (currentPage-1 || 1)">
<ul class="ti-pagination"> <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
<li> </a>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> </li>
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i> <li *ngFor="let item of page;let f = first;let l = last">
</a> <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
</li> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
<li><a class="page-link active" href="javascript:void(0);" class="ri-more-line"></i>
aria-current="page">1</a></li> </a>
<li><a class="page-link" href="javascript:void(0);">2</a></li> </ng-container>
<li><a class="page-link" href="javascript:void(0);">3</a></li> <ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<li><a class="page-link" href="javascript:void(0);">4</a></li> <a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
<li><a class="page-link" href="javascript:void(0);">5</a></li> (click)="currentPage=item">{{item}}
<li><a class="page-link" href="javascript:void(0);">...</a></li> </a>
<li><a class="page-link" href="javascript:void(0);">31</a></li> </ng-container>
<li> <ng-container
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> *ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
</a> class="ri-more-line"></i>
</li> </a>
</ul> </ng-container>
</nav> </li>
</div> <li>
</div> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul> </ul>
<ul class="nav-tabs mt-1"> <ul class="nav-tabs mt-3">
<p>Show 1 to 10 of 50 items</p> <span>Show {{((currentPage-1) * 10)+1}} to {{dataListModalFilter().length<10
?dataListModalFilter().length: (currentPage==page.length ? ((currentPage * 10) -
((currentPage * 10) - dataListModalFilter().length) ) :(currentPage * 10) ) }} of
{{dataListModalFilter().length}} items</span>
</ul> </ul>
</div> </nav>
</div> </div>
</div> </div>
</div> </div>
...@@ -345,7 +407,7 @@ ...@@ -345,7 +407,7 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#edit-group-competencies-alert-add-modal" (click)="addUser();showSuccess()"> data-hs-overlay="#edit-group-competencies-alert-add-modal" (click)="saveGroupAssessment1()">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
...@@ -381,8 +443,7 @@ ...@@ -381,8 +443,7 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#edit-group-competencies-alert-edit-modal" data-hs-overlay="#edit-group-competencies-alert-edit-modal">
(click)="addUser();showSuccessEdit()">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
...@@ -418,10 +479,11 @@ ...@@ -418,10 +479,11 @@
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#edit-group-competencies-alert-delete-modal" data-hs-overlay="#edit-group-competencies-alert-delete-modal"
(click)="addUser();showSuccessDelete()"> (click)="deleteGroupAssessmentById()">
ลบข้อมูล ลบข้อมูล
</a> </a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
......
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { GroupAssessmentModel, MyGroupAssessmentModel } from 'src/app/shared/model/group-assessment.model';
import { GroupAssessment1ListModel, MyGroupAssessment1ListModel } from 'src/app/shared/model/group-assessment1-list.model';
import { MyPLModel, PLModel } from 'src/app/shared/model/pl.model';
import { GroupAssessmentService } from 'src/app/shared/services/group-assessment.service';
import { IndicatorsCoursesService } from 'src/app/shared/services/indicators-courses.service';
import { CompetencyIndicatorsCourses1MiniModel, MyCompetencyIndicatorsCourses1MiniModel } from 'src/app/shared/model/competency-indicators-courses1-mini.model';
@Component({ @Component({
selector: 'app-edit-group-competencies', selector: 'app-edit-group-competencies',
...@@ -7,102 +13,154 @@ import { ToastrService } from 'ngx-toastr'; ...@@ -7,102 +13,154 @@ import { ToastrService } from 'ngx-toastr';
styleUrls: ['./edit-group-competencies.component.scss'] styleUrls: ['./edit-group-competencies.component.scss']
}) })
export class EditGroupCompetenciesComponent { export class EditGroupCompetenciesComponent {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ']; @Input() pl: PLModel = new MyPLModel()
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>(); @Output() sendEdit: EventEmitter<boolean> = new EventEmitter<boolean>();
@Output() sendGroupShow: EventEmitter<string> = new EventEmitter<string>(); groupCompetencies: GroupAssessmentModel = new MyGroupAssessmentModel()
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น dataSelectList: GroupAssessment1ListModel[] = [];
dataSelect: GroupAssessment1ListModel = new MyGroupAssessment1ListModel()
// ฟังก์ชันในการเปลี่ยนแท็บ dataList: { check: boolean, data: GroupAssessment1ListModel }[] = []
changeTab(tab: { id: string, text: string }) { dataListModal: { check: boolean, data: CompetencyIndicatorsCourses1MiniModel }[] = []
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', tab.text]);
this.activeTab = tab.id; search = ""
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
isChecked: boolean = false;
searchModal = ""
currentPageModal = 1
dataLoading = false
dataModalLoading = false
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private groupAssessmentService: GroupAssessmentService,
private indicatorsCoursesService: IndicatorsCoursesService
) { }
ngOnInit() {
this.getGroupAssessmentById()
this.getIndicatorsCoursesList()
} }
onBack() { onEdit() {
this.sendGroupShow.emit('1'); // เปลี่ยนกลับไปหน้า 1 this.sendEdit.emit(false);
} }
// การจัดการการเปิดปิด modal
modalOptions: {
[nameModal: string]: {
isModalOpen: boolean;
modalSize: string;
backdropClose: boolean;
};
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
};
mockDataList = [
{ checked: false, id: 'CC-01', name: 'จิตสำนึกด้านความปลอดภัยและคุณภาพ (Safety & Quality)', level: 'ระดับที่ 1' },
{ checked: false, id: 'CC-02', name: 'การทำงานเป็นทีมแบบ TAT (TAT Teamwork)', level: 'ระดับที่ 1' },
{ checked: false, id: 'CC-03', name: 'ความรับผิดชอบในหน้าที่และโปร่งใส (Accountability & Ethics)', level: 'ระดับที่ 1' },
{ checked: false, id: 'CC-04', name: 'การพัฒนาอย่างต่อเนื่อง (Readiness to Learn & Continous Improvement)', level: 'ระดับที่ 1' },
{ checked: false, id: 'CC-05', name: 'การคิดอย่างเป็นระบบ (Systematic Thinking)', level: 'ระดับที่ 1' }]
checkSelect() { checkSelect() {
return this.mockDataList.filter(item => item.checked).length; this.dataSelectList = this.dataList.filter(item => item.check).map(item => item.data);
}
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
this.modalOptions[name].isModalOpen = true;
this.currentModal = name; // ตั้งค่าค่าของ currentModal เป็น 'add' หรือ 'edit'
document.body.style.overflow = 'hidden';
} }
closeModal(name: string) { toggleCheckbox() {
this.modalOptions[name].isModalOpen = false; this.isChecked = !this.isChecked;
if (!this.isAnyModalOpen()) { this.dataList.forEach((item) => {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว item.check = this.isChecked;
} });
this.checkSelect();
} }
isAnyModalOpen(): boolean { getGroupAssessmentById() {
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่ this.dataLoading = true;
this.groupAssessmentService.getById(this.pl.plId).subscribe({
next: response => {
this.groupCompetencies = new MyGroupAssessmentModel({ ...response, personalLevel: new MyPLModel(this.pl) })
this.dataList = new MyGroupAssessmentModel(response).groupAssessment1List.map(x => ({ check: false, data: new MyGroupAssessment1ListModel(x) }))
this.dataLoading = false;
this.searchChange();
this.cdr.detectChanges();
},
error: error => {
this.dataLoading = false;
this.cdr.detectChanges();
}
});
} }
// ฟังก์ชัน toggle checkbox searchChange() {
isChecked: boolean = false; // ใช้สำหรับตรวจสอบสถานะของ checkbox this.currentPage = 1;
const filteredData = this.dataListFilter();
toggleCheckbox() { this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
this.isChecked = !this.isChecked; // สลับสถานะ }
this.mockDataList = this.mockDataList.map(x => ({ ...x, checked: this.isChecked })) dataListFilter() {
return this.dataList.filter(x => {
const data = x.data
const match = data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase().includes(this.search.toLowerCase()) ||
data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.competencyTopic.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
data.competencyIndicatorsCourses1Mini.competencyIndicatorsCourses0.expectation.toLocaleLowerCase().includes(this.search.toLocaleLowerCase())
return match;
});
} }
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล getIndicatorsCoursesList() {
addUser() { this.dataModalLoading = true
this.indicatorsCoursesService.getList().subscribe({
next: response => {
this.dataListModal = response.map(x => ({ check: false, data: new MyCompetencyIndicatorsCourses1MiniModel(x) }));
this.dataModalLoading = false;
this.searchModalChange();
this.cdr.detectChanges();
},
error: error => {
this.dataModalLoading = false;
this.cdr.detectChanges();
}
});
} }
currentModal = ""; selectIndicatorsCourses(data: CompetencyIndicatorsCourses1MiniModel) {
this.dataList.push({
check: false, data: new MyGroupAssessment1ListModel({
competencyIndicatorsCourses1Mini: new MyCompetencyIndicatorsCourses1MiniModel(data)
})
})
}
constructor(private toastr: ToastrService) { } searchModalChange() {
this.currentPage = 1;
const filteredData = this.dataListModalFilter();
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
}
showSuccess() { dataListModalFilter() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { return this.dataListModal.filter(x => {
timeOut: 3000, const data = x.data
positionClass: 'toast-top-right', const match = data.competencyIndicatorsCourses0.competencyTopic.competencyTopicId.toLowerCase().includes(this.searchModal.toLowerCase()) ||
data.competencyIndicatorsCourses0.tdesc.toLowerCase().includes(this.searchModal.toLowerCase()) ||
data.competencyIndicatorsCourses0.expectation.toLocaleLowerCase().includes(this.searchModal.toLocaleLowerCase())
return match;
}); });
} }
showSuccessEdit() { saveGroupAssessment1() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.groupCompetencies.groupAssessment1List = this.dataList.map(x => x.data);
timeOut: 3000, this.groupAssessmentService.post(this.groupCompetencies).subscribe({
positionClass: 'toast-top-right', next: (response) => {
console.log(response)
if (response.success) {
this.showAlert(response.message, 'success');
} else {
this.showAlert(response.message, 'error');
}
},
error: (error) => {
this.showAlert(error.message, 'error');
}
}); });
} }
showSuccessDelete() { deleteGroupAssessmentById() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', { const selectedItems = this.dataList.filter(item => item.check);
if (selectedItems.length > 0) {
this.dataList = this.dataList.filter(item => !item.check);
} else if (this.dataList.length > 0) {
this.dataList.pop();
}
this.cdr.detectChanges();
this.showAlert('ลบข้อมูลสำเร็จ', 'success');
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
} }
} }
<div class="w-full min-height-50px mb-10px justify-between items-center"> <ng-container *ngIf="!editTab">
<div class="flex"> <div class="w-full min-height-50px mb-10px justify-between items-center">
</div> <div class="flex">
<div class="flex justify-end">
<div class="px-1">
<div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name">
<div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i>
</div>
</div>
</div> </div>
<div class="px-1">
<button type="button"
class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-45px m-0 shadow-md"
data-hs-overlay="#group-competencies-modal-add">
<i class="ti ti-file-plus"></i>
import
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div>
</div>
</div>
<div class="flex justify-end">
<div class="page px-rem"> <div class="px-1">
<div class="overflow-auto shadow-md rounded-t-md"> <div class="relative shadow-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered"> <input type="text" id="hs-leading-icon" name="hs-leading-icon"
<thead> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
<tr> [(ngModel)]="search" (ngModelChange)="searchChange()">
<ng-container <div
*ngFor="let item of ['รหัส','ชื่อระดับพนักงาน (ไทย)','การจัดการ']; let f = first; let l = last; let i = index"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center"> <i class="ri-search-line text-gray"></i>
<span class="font-size-12px font-weight-700">{{ item }}</span> </div>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of[
['O1O2', 'พนักงานระดับ O1-O2'],
['O3O4', 'พนักงานระดับ O3-O4'],
['S1S2', 'พนักงานระดับ S1-S2'],
['S3S4', 'พนักงานระดับ S3-S4'],
['M1M2', 'พนักงานระดับ M1-M2'],
['M3M4', 'พนักงานระดับ M3-M4'],
['E1E2', 'พนักงานระดับ E1-E2'],
['E3E4', 'พนักงานระดับ E3-E4']];let i = index">
<td class="text-center">{{ item[0] }}</td>
<td>{{item[1]}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="onEdit()"></i>
</td>
</tr>
</tbody>
</table>
</div>
<div class="body-content" style="margin-top: 20px;">
<ul class="nav-tabs">
<div class="px-1 py-1 bg-white rounded-2 shadow justify-content-center align-items-center">
<div class="box-body">
<nav class="pagination-style-3 overflow-auto">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li><a class="page-link active" href="javascript:void(0);" aria-current="page">1</a></li>
<li><a class="page-link" href="javascript:void(0);">2</a></li>
<li><a class="page-link" href="javascript:void(0);">3</a></li>
<li><a class="page-link" href="javascript:void(0);">4</a></li>
<li><a class="page-link" href="javascript:void(0);">5</a></li>
<li><a class="page-link" href="javascript:void(0);">...</a></li>
<li><a class="page-link" href="javascript:void(0);">31</a></li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
</nav>
</div> </div>
</div> </div>
</ul> <div class="px-1">
<ul class="nav-tabs mt-1"> <button type="button"
<p>Show 1 to 10 of 50 items</p> class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-45px m-0 shadow-md"
</ul> data-hs-overlay="#group-competencies-modal-add">
</div> <i class="ti ti-file-plus"></i>
</div> import
</button>
<div id="group-competencies-alert-add-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#group-competencies-alert-add-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div> </div>
<div class="ti-modal-body "> <div class="px-1">
<p class="mt-1 text-gray-800 dark:text-white/70"> <button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
ยืนยันการบันทึกข้อมูลหรือไม่ <i class="ti ti-book fs-l"></i>
</p> Help
</button>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#group-competencies-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#group-competencies-alert-add-modal" (click)="addUser();showSuccess()">
บันทึกข้อมูล
</a>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="group-competencies-alert-edit-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#group-competencies-alert-edit-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการเเก้ไขข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#group-competencies-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#group-competencies-alert-edit-modal" (click)="addUser();showSuccessEdit()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="group-competencies-alert-delete-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#group-competencies-alert-delete-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการลบข้อมูลหรือไม่!
</p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="page px-rem">
<button type="button" <div class="overflow-auto shadow-md rounded-t-md">
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered">
data-hs-overlay="#group-competencies-alert-delete-modal"> <thead>
ย้อนกลับ <tr>
</button> <ng-container
<a class="ti-btn ti-btn-success" href="javascript:void(0);" *ngFor="let item of ['รหัส','ชื่อระดับพนักงาน (ไทย)','การจัดการ']; let f = first; let l = last; let i = index">
data-hs-overlay="#group-competencies-alert-delete-modal" <th scope="col"
(click)="addUser();showSuccessDelete()"> class="relative px-10px py-10px bg-soft-secondary text-primary !text-center">
ลบข้อมูล <span class="font-size-12px font-weight-700">{{ item }}</span>
</a> <div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
</div> <i class="ti ti-dots-vertical fs-l"></i>
</div> </div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="dataLoading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1"
role="status" aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&!dataListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&dataListFilter().length">
<tr
*ngFor="let item of dataListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
{{item.code}}
</td>
<td class="text-center">{{item.name}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="selectGroupCompetencies(item);editTab=true;pathTitleChange()"></i>
</td>
</tr>
</tbody>
</table>
</div> </div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link !pl-0" href="javascript:void(0);"
(click)="currentPage = (currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{dataListFilter().length<10 ?dataListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - dataListFilter().length)
) :(currentPage * 10) ) }} of {{dataListFilter().length}} items</span>
</ul>
</nav>
</div> </div>
</div> </ng-container>
\ No newline at end of file
<ng-container *ngIf="editTab">
<app-edit-group-competencies [pl]="groupCompetencies"
(sendEdit)="editTab=$event;pathTitleChange()" ></app-edit-group-competencies>
</ng-container>
\ No newline at end of file
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { MyPLModel, PLModel } from 'src/app/shared/model/pl.model';
import { PLService } from 'src/app/shared/services/pl.service';
export interface DataModel {
code: string
name: string
edesc: string
companyId: string
}
@Component({ @Component({
selector: 'app-group-competencies', selector: 'app-group-competencies',
...@@ -7,81 +15,66 @@ import { ToastrService } from 'ngx-toastr'; ...@@ -7,81 +15,66 @@ import { ToastrService } from 'ngx-toastr';
styleUrls: ['./group-competencies.component.scss'] styleUrls: ['./group-competencies.component.scss']
}) })
export class GroupCompetenciesComponent { export class GroupCompetenciesComponent {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>(); @Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
@Output() sendGroupShow: EventEmitter<string> = new EventEmitter<string>(); editTab = false
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น currentPage = 1
search = ""
page = Array.from({ length: 1 }, (_, i) => i + 1);
// ฟังก์ชันในการเปลี่ยนแท็บ dataList: DataModel[] = []
changeTab(tab: { id: string, text: string }) { dataSelect: DataModel = { code: '', name: '', edesc: '', companyId: '' }
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', tab.text]); groupCompetenciesList: PLModel[] = []
this.activeTab = tab.id; groupCompetencies: PLModel = new MyPLModel({})
} dataLoading = false
onEdit(){
this.sendGroupShow.emit('2');
}
// การจัดการการเปิดปิด modal
modalOptions: {
[nameModal: string]: {
isModalOpen: boolean;
modalSize: string;
backdropClose: boolean;
};
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
};
openModal(name: string, size: string, closeOnBackdrop?: boolean) { constructor(private toastr: ToastrService,
this.modalOptions[name].modalSize = size; private cdr: ChangeDetectorRef,
this.modalOptions[name].backdropClose = closeOnBackdrop || false; private pLService: PLService,
this.modalOptions[name].isModalOpen = true; ) {
this.currentModal = name; // ตั้งค่าค่าของ currentModal เป็น 'add' หรือ 'edit' this.pathTitleChange()
document.body.style.overflow = 'hidden';
} }
ngOnInit(): void {
closeModal(name: string) { this.getList()
this.modalOptions[name].isModalOpen = false;
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
} }
getList() {
isAnyModalOpen(): boolean { this.dataLoading = true
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่ this.pLService.getList().subscribe({
next: response => {
this.dataList = response.map(x => ({ code: x.plId, name: x.tdesc, edesc: x.edesc, companyId: x.companyId }))
this.groupCompetenciesList = response
this.dataLoading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.dataLoading = false
this.cdr.detectChanges()
}
})
} }
selectData(data?: DataModel) {
// ฟังก์ชัน toggle checkbox this.dataSelect = JSON.parse(JSON.stringify(data || { code: '', name: '', edesc: '', companyId: '' }))
isChecked: boolean = false; // ใช้สำหรับตรวจสอบสถานะของ checkbox
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ
} }
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล selectGroupCompetencies(data: DataModel) {
addUser() { const groupCompetencies = this.groupCompetenciesList.find(x => x.plId == data.code)
console.log('เพิ่มผู้ใช้งาน'); this.groupCompetencies = new MyPLModel(groupCompetencies)
}
pathTitleChange() {
this.sendPathTitle.emit(this.editTab ? ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ', 'แก้ไขกลุ่มสมรรถนะ'] : ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ'])
} }
deleteUser() { searchChange() {
console.log('ลบผู้ใช้งาน'); this.currentPage = 1;
const filteredData = this.dataListFilter();
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
} }
editUser() { dataListFilter() {
console.log('แก้ไขผู้ใช้งาน'); return this.dataList.filter(x => {
const match = x.code.toLocaleLowerCase().includes(this.search.toLocaleLowerCase()) || x.name.toLocaleLowerCase().includes(this.search.toLocaleLowerCase());
return match;
});
} }
currentModal = "";
constructor(private toastr: ToastrService) { }
showSuccess() { showSuccess() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
...@@ -103,4 +96,17 @@ export class GroupCompetenciesComponent { ...@@ -103,4 +96,17 @@ export class GroupCompetenciesComponent {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); });
} }
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addUser() {
console.log('เพิ่มผู้ใช้งาน');
}
deleteUser() {
console.log('ลบผู้ใช้งาน');
}
editUser() {
console.log('แก้ไขผู้ใช้งาน');
}
} }
<div class="w-full min-height-50px mb-10px justify-between items-center"> <div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex">
<!-- Content ของ div แรก --> <div class="flex items-center">
<div class="flex gap-x-6"> <input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
<div class="flex items-center"> [(ngModel)]="isDataListChecked">
<label for="hs-checkbox-group-1" <label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{dataSelectList.length}} {{numDataListChecked}} Selected</label>
Selected</label> </div>
</div> <div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
<div class="flex items-center"> class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i (click)="toggleCheckbox()" <i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line': !isChecked, 'ri-checkbox-multiple-fill': isChecked}" [ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
class="ri-checkbox-multiple-line text-gray-500 dark:text-white/70"></i> </button>
<label for="hs-checkbox-group-2" class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70" <label class="text-sm text-gray-500 ml-2">Select All</label>
(click)="toggleCheckbox()">Select All</label>
</div>
</div> </div>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
...@@ -35,7 +31,8 @@ ...@@ -35,7 +31,8 @@
<div class="px-1"> <div class="px-1">
<button type="button" <button type="button"
class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md" class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md"
data-hs-overlay="#competency-topic-upload-modal"> data-hs-overlay="#competency-topic-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ti ti-file-plus"></i> <i class="ti ti-file-plus"></i>
import import
</button> </button>
...@@ -103,7 +100,7 @@ ...@@ -103,7 +100,7 @@
*ngFor="let item of dataListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of dataListFilter()| 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" id="checkbox-{{item.data.id}}" <input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.id}}"
[(ngModel)]="item.check" (change)="checkSelect()"> [(ngModel)]="item.check" (change)="dataListCheck()">
<label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label> <label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label>
</td> </td>
<td>{{item.data.name}}</td> <td>{{item.data.name}}</td>
...@@ -179,7 +176,7 @@ ...@@ -179,7 +176,7 @@
<div class="ti-modal-center"> <div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="clearData(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -208,22 +205,26 @@ ...@@ -208,22 +205,26 @@
<input type="text" id="input-label" class="ti-form-input w-1/2" <input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.id"> [(ngModel)]="dataSelect.id">
<label for="detail_th" class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)</label> <label for="detail_th" class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-10" [(ngModel)]="dataSelect.name"> <input type="text" id="detail_th" class="ti-form-input h-10" [(ngModel)]="dataSelect.name">
<label for="detail_eng" class="ti-form-label mt-2rem">ชื่อหัวข้อ (อังกฤษ)</label> <label for="detail_eng" class="ti-form-label mt-2rem">ชื่อหัวข้อ (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-10" [(ngModel)]="dataSelect.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-10" [(ngModel)]="dataSelect.edesc">
<label for="detail_eng" class="ti-form-label mt-2rem">นิยามสมรรถนะ</label> <label for="detail_eng" class="ti-form-label mt-2rem">นิยามสมรรถนะ</label>
<textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50" <textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50"
[(ngModel)]="dataSelect.definition"> </textarea> [(ngModel)]="dataSelect.definition"> </textarea>
<label class="ti-form-label mt-2rem">ประเภท Competency</label> <label class="ti-form-label mt-2rem">ประเภท Competency*</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md w-1/2"> <div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10" class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10"
style="padding-right: 2.5rem;" [(ngModel)]="dataSelect.type.code"> style="padding-right: 2.5rem;" readonly [(ngModel)]="dataSelect.type.code">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500"
(click)="dataSelect.type.code=''">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#competency-topic-table-modal-select"> data-hs-overlay="#competency-topic-table-modal-select">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
...@@ -257,10 +258,12 @@ ...@@ -257,10 +258,12 @@
data-hs-overlay="#competency-topic-page-modal"> data-hs-overlay="#competency-topic-page-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#competency-topic-page-alert-modal"> data-hs-overlay="#competency-topic-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.type.code"
[disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.type.code">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -621,7 +624,7 @@ ...@@ -621,7 +624,7 @@
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1> <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2"> <div class="mt-2 p-2">
<div class="flex rounded-md"> <div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()" <input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer"> class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()" <button type="button" (click)="fileInput.click()"
...@@ -630,8 +633,9 @@ ...@@ -630,8 +633,9 @@
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()" <button type="submit" class="ti-btn ti-btn-secondary"
[disabled]="!selectedFile"> data-hs-overlay="#competency-topic-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
</div> </div>
......
...@@ -59,6 +59,10 @@ export class CompetencyTopic { ...@@ -59,6 +59,10 @@ export class CompetencyTopic {
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
selectedItems: string[] = []; selectedItems: string[] = [];
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
constructor(private toastr: ToastrService, constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private fileService: FileService, private fileService: FileService,
...@@ -70,18 +74,6 @@ export class CompetencyTopic { ...@@ -70,18 +74,6 @@ export class CompetencyTopic {
this.getCompetencytypeList() this.getCompetencytypeList()
} }
checkSelect() {
this.dataSelectList = this.competoncyTopicList.filter(item => item.check).map(item => item.data);
}
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ'
this.competoncyTopicList.forEach((item) => {
item.check = this.isChecked;
});
this.checkSelect();
}
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์" this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
...@@ -94,6 +86,7 @@ export class CompetencyTopic { ...@@ -94,6 +86,7 @@ export class CompetencyTopic {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true
this.fileService.upload(formData, 'competency_topic').subscribe({ this.fileService.upload(formData, 'competency_topic').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -102,9 +95,13 @@ export class CompetencyTopic { ...@@ -102,9 +95,13 @@ export class CompetencyTopic {
this.getCompetencytopicList() this.getCompetencytopicList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -167,6 +164,8 @@ export class CompetencyTopic { ...@@ -167,6 +164,8 @@ export class CompetencyTopic {
checked: false checked: false
} }
})) }))
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.dataLoading = false this.dataLoading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -180,11 +179,12 @@ export class CompetencyTopic { ...@@ -180,11 +179,12 @@ export class CompetencyTopic {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
dataListFilter() { dataListFilter() {
return this.competoncyTopicList.filter(x => { return this.competoncyTopicList.filter(x => {
const data = x.data const data = x.data
const match = data.id.toLowerCase().includes(this.search) || data.name.toLowerCase().includes(this.search) || data.code.toLowerCase().includes(this.search); const match = data.id?.toLowerCase().includes(this.search.toLowerCase()) || data.name?.toLowerCase().includes(this.search.toLowerCase()) || data.code?.toLowerCase().includes(this.search.toLowerCase());
return match; return match;
}); });
} }
...@@ -198,6 +198,7 @@ export class CompetencyTopic { ...@@ -198,6 +198,7 @@ export class CompetencyTopic {
competencyTopicId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, competencyDetail: this.dataSelect.definition, competencyTopicId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, competencyDetail: this.dataSelect.definition,
competencyType: new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.type.id, tdesc: this.dataSelect.type.name, edesc: this.dataSelect.type.edesc, shortName: this.dataSelect.type.code, expectationLevel: this.dataSelect.type.level }), competencyType: new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.type.id, tdesc: this.dataSelect.type.name, edesc: this.dataSelect.type.edesc, shortName: this.dataSelect.type.code, expectationLevel: this.dataSelect.type.level }),
}) })
this.dataLoading = true
this.competencytopicService.post(body).subscribe({ this.competencytopicService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -206,9 +207,13 @@ export class CompetencyTopic { ...@@ -206,9 +207,13 @@ export class CompetencyTopic {
this.getCompetencytopicList() this.getCompetencytopicList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -225,7 +230,7 @@ export class CompetencyTopic { ...@@ -225,7 +230,7 @@ export class CompetencyTopic {
competencyType: new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.type.id, tdesc: this.dataSelect.type.name, edesc: this.dataSelect.type.edesc, shortName: this.dataSelect.type.code, expectationLevel: this.dataSelect.type.level }), competencyType: new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.type.id, tdesc: this.dataSelect.type.name, edesc: this.dataSelect.type.edesc, shortName: this.dataSelect.type.code, expectationLevel: this.dataSelect.type.level }),
}) })
} }
console.log(body) this.dataLoading = true
this.competencytopicService.delete(body).subscribe({ this.competencytopicService.delete(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -234,9 +239,13 @@ export class CompetencyTopic { ...@@ -234,9 +239,13 @@ export class CompetencyTopic {
this.getCompetencytopicList() this.getCompetencytopicList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -247,4 +256,29 @@ export class CompetencyTopic { ...@@ -247,4 +256,29 @@ export class CompetencyTopic {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}) })
} }
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.setData()
} else if (modalStatus == 'edit') {
this.setData({ id: this.dataSelect.id, name: "", edesc: "", code: "", definition: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: this.dataSelect.checked })
}
}
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.competoncyTopicList.filter(x => {
const data = x.data
const match = data.id.toLowerCase().includes(this.search.toLowerCase()) || data.name.toLowerCase().includes(this.search.toLowerCase()) || data.code.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.competoncyTopicList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
} }
...@@ -10,24 +10,25 @@ ...@@ -10,24 +10,25 @@
<nav class="-mb-0.5 flex space-x-6 rtl:space-x-reverse"> <nav class="-mb-0.5 flex space-x-6 rtl:space-x-reverse">
<a class="text-base font-medium hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary active" <a class="text-base font-medium hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary active"
href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1" href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1"
aria-controls="underline-1" (click)=" currentPage = 1;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','ประเภทสมรรถนะ']"> aria-controls="underline-1"
(click)=" currentPage = 1;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','ประเภทสมรรถนะ']">
ประเภทสมรรถนะ ประเภทสมรรถนะ
</a> </a>
<a class="text-base font-medium hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary" <a class="text-base font-medium hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary"
href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2" href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2"
aria-controls="underline-2" (click)="currentPage = 2;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','หัวข้อสมรรถนะ']"> aria-controls="underline-2"
(click)="currentPage = 2;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','หัวข้อสมรรถนะ']">
หัวข้อสมรรถนะ หัวข้อสมรรถนะ
</a> </a>
</nav> </nav>
</div> </div>
<div class="mt-3 px-3rem !-mt-3 pt-50px"> <div class="mt-3 px-2rem !-mt-3 pt-50px">
<div *ngIf="currentPage == 1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1"> <div *ngIf="currentPage == 1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-type-registration [pathTitle]="pathTitle" <app-type-registration></app-type-registration>
(sendPathTitle)="pathTitle=$event"></app-type-registration>
</div> </div>
<div *ngIf="currentPage == 2" id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2"> <div *ngIf="currentPage == 2" id="underline-2" class="hidden" role="tabpanel"
<app-competency-topic [pathTitle]="pathTitle" aria-labelledby="underline-item-2">
(sendPathTitle)="pathTitle=$event"></app-competency-topic> <app-competency-topic [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-competency-topic>
</div> </div>
</div> </div>
</div> </div>
......
<div class="w-full min-height-50px mb-10px justify-between items-center"> <div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex">
<!-- Content ของ div แรก --> <div class="flex items-center">
<div class="flex gap-x-6"> <input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
<div class="flex items-center"> [(ngModel)]="isDataListChecked">
<label for="hs-checkbox-group-1" <label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{dataSelectList.length}} {{numDataListChecked}} Selected</label>
Selected</label> </div>
</div> <div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
<div class="flex items-center"> class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i (click)="toggleCheckbox()" <i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line': !isChecked, 'ri-checkbox-multiple-fill': isChecked}" [ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
class="ri-checkbox-multiple-line text-gray-500 dark:text-white/70"></i> </button>
<label for="hs-checkbox-group-2" class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70" <label class="text-sm text-gray-500 ml-2">Select All</label>
(click)="toggleCheckbox()">Select All</label>
</div>
</div> </div>
</div> </div>
...@@ -35,7 +32,8 @@ ...@@ -35,7 +32,8 @@
<div class="px-1"> <div class="px-1">
<button type="button" <button type="button"
class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md" class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md"
data-hs-overlay="#type-registration-component-upload-modal"> data-hs-overlay="#type-registration-component-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ti ti-file-plus"></i> <i class="ti ti-file-plus"></i>
import import
</button> </button>
...@@ -103,7 +101,7 @@ ...@@ -103,7 +101,7 @@
*ngFor="let item of dataListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of dataListFilter()| 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" id="checkbox-{{item.data.id}}" <input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.id}}"
[(ngModel)]="item.check" (change)="checkSelect()"> [(ngModel)]="item.check" (change)="dataListCheck()">
<label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label> <label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label>
</td> </td>
<td>{{item.data.name}}</td> <td>{{item.data.name}}</td>
...@@ -179,7 +177,8 @@ ...@@ -179,7 +177,8 @@
<div class="ti-modal-center"> <div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="clearData(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -223,10 +222,12 @@ ...@@ -223,10 +222,12 @@
data-hs-overlay="#type-registration-component-page-modal"> data-hs-overlay="#type-registration-component-page-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#type-registration-component-page-alert-modal"> data-hs-overlay="#type-registration-component-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.code||!dataSelect.level"
[disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.code||!dataSelect.level">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -243,7 +244,7 @@ ...@@ -243,7 +244,7 @@
<div class="flex justify-end"> <div class="flex justify-end">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#type-registration-component-page-alert-modal"> data-hs-overlay="#type-registration-component-page-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -309,7 +310,7 @@ ...@@ -309,7 +310,7 @@
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1> <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2"> <div class="mt-2 p-2">
<div class="flex rounded-md"> <div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()" <input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer"> class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()" <button type="button" (click)="fileInput.click()"
...@@ -318,8 +319,9 @@ ...@@ -318,8 +319,9 @@
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()" <button type="submit" class="ti-btn ti-btn-secondary"
[disabled]="!selectedFile"> data-hs-overlay="#type-registration-component-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
</div> </div>
......
...@@ -18,26 +18,21 @@ export interface DataModel { ...@@ -18,26 +18,21 @@ export interface DataModel {
styleUrls: ['./type-registration.component.scss'] styleUrls: ['./type-registration.component.scss']
}) })
export class TypeRegistration { export class TypeRegistration {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'ทะเบียนกำหนดชื่อ', 'ประเภทสมรรถนะ'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'ทะเบียนกำหนดชื่อ', tab.text]);
this.activeTab = tab.id;
}
isChecked: boolean = false; isChecked: boolean = false;
currentPage = 1 currentPage = 1
selectedItems: string[] = []; selectedItems: string[] = [];
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
dataSelectList: DataModel[] = []; dataSelectList: DataModel[] = [];
dataLoading = false dataLoading = false
dataSelect: DataModel = { id: "", companyId: "", edesc: "", name: "", code: "", level: "", checked: false } dataSelect: DataModel = { id: "", companyId: "", edesc: "", name: "", code: "", level: "", checked: false }
competoncy_typeList: { check: boolean; data: DataModel & { checked?: boolean } }[] = [] competoncy_typeList: { check: boolean; data: DataModel & { checked?: boolean } }[] = []
competoncy_type: CompetencytypeModel = new MyCompetencytypeModel({}) competoncy_type: CompetencytypeModel = new MyCompetencytypeModel({})
modalStatus = 'add' modalStatus: 'add' | 'edit' | 'delete' | 'deleteGroup' = 'add'
search = "" search = ""
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
...@@ -52,18 +47,6 @@ export class TypeRegistration { ...@@ -52,18 +47,6 @@ export class TypeRegistration {
this.getCompetencytypeList() this.getCompetencytypeList()
} }
checkSelect() {
this.dataSelectList = this.competoncy_typeList.filter(item => item.check).map(item => item.data);
}
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ'
this.competoncy_typeList.forEach((item) => {
item.check = this.isChecked;
});
this.checkSelect();
}
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์" this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
...@@ -76,6 +59,7 @@ export class TypeRegistration { ...@@ -76,6 +59,7 @@ export class TypeRegistration {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true
this.fileService.upload(formData, 'competency_type').subscribe({ this.fileService.upload(formData, 'competency_type').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -83,9 +67,13 @@ export class TypeRegistration { ...@@ -83,9 +67,13 @@ export class TypeRegistration {
this.getCompetencytypeList() this.getCompetencytypeList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -115,11 +103,12 @@ export class TypeRegistration { ...@@ -115,11 +103,12 @@ export class TypeRegistration {
next: response => { next: response => {
this.competoncy_typeList = response.map(x => ({ check: false, data: { id: x.competencyTypeId, companyId: x.companyId, edesc: x.edesc, name: x.tdesc, code: x.shortName, level: x.expectationLevel, checked: false } })) this.competoncy_typeList = response.map(x => ({ check: false, data: { id: x.competencyTypeId, companyId: x.companyId, edesc: x.edesc, name: x.tdesc, code: x.shortName, level: x.expectationLevel, checked: false } }))
this.dataLoading = false this.dataLoading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.dataLoading = false this.dataLoading = false
console.error('Error fetching employee types:', error);
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}) })
...@@ -127,21 +116,22 @@ export class TypeRegistration { ...@@ -127,21 +116,22 @@ export class TypeRegistration {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
dataListFilter() { dataListFilter() {
return this.competoncy_typeList.filter(x => { return this.competoncy_typeList.filter(x => {
const data = x.data const data = x.data
const match = data.id.toLowerCase().includes(this.search) || data.name.toLowerCase().includes(this.search) || data.code.toLowerCase().includes(this.search); const match = data.id.toLowerCase().includes(this.search.toLowerCase()) || data.name.toLowerCase().includes(this.search.toLowerCase()) || data.code.toLowerCase().includes(this.search.toLowerCase());
return match; return match;
}); });
} }
setData(data?: DataModel) { setData(data?: DataModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", companyId: "", name: "", edesc: "", code: "", level: "" })); this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", companyId: "", name: "", edesc: "", code: "", level: "", checked: false }));
} }
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล // ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addType_registration() { addType_registration() {
const body = new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, shortName: this.dataSelect.code, expectationLevel: this.dataSelect.level }) const body = new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, shortName: this.dataSelect.code, expectationLevel: this.dataSelect.level })
this.dataLoading = true
this.competencytypeService.post(body).subscribe({ this.competencytypeService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -149,9 +139,13 @@ export class TypeRegistration { ...@@ -149,9 +139,13 @@ export class TypeRegistration {
this.getCompetencytypeList() this.getCompetencytypeList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -163,6 +157,7 @@ export class TypeRegistration { ...@@ -163,6 +157,7 @@ export class TypeRegistration {
} else { } else {
body = this.competoncy_typeList.filter(x => x.check).map(x => new MyCompetencytypeModel({ competencyTypeId: x.data.id, tdesc: x.data.name, edesc: x.data.edesc, shortName: x.data.code, expectationLevel: x.data.level })); body = this.competoncy_typeList.filter(x => x.check).map(x => new MyCompetencytypeModel({ competencyTypeId: x.data.id, tdesc: x.data.name, edesc: x.data.edesc, shortName: x.data.code, expectationLevel: x.data.level }));
} }
this.dataLoading = true
this.competencytypeService.delete(body).subscribe({ this.competencytypeService.delete(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -170,10 +165,14 @@ export class TypeRegistration { ...@@ -170,10 +165,14 @@ export class TypeRegistration {
this.getCompetencytypeList(); this.getCompetencytypeList();
} else { } else {
this.showAlert(response.message, 'error'); this.showAlert(response.message, 'error');
this.dataLoading = false
this.cdr.detectChanges()
} }
}, },
error: error => { error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}); });
} }
...@@ -184,5 +183,30 @@ export class TypeRegistration { ...@@ -184,5 +183,30 @@ export class TypeRegistration {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}) })
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.competoncy_typeList.filter(x => {
const data = x.data
const match = data.id.toLowerCase().includes(this.search.toLowerCase()) || data.name.toLowerCase().includes(this.search.toLowerCase()) || data.code.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.competoncy_typeList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.setData()
} else if (modalStatus == 'edit') {
this.setData({ id: this.dataSelect.id, companyId: "", name: "", edesc: "", code: "", level: "", checked: this.dataSelect.checked })
}
}
} }
...@@ -134,6 +134,7 @@ import { FileService } from 'src/app/shared/services/file.service'; ...@@ -134,6 +134,7 @@ import { FileService } from 'src/app/shared/services/file.service';
import { CompetencyGroupGradeService } from 'src/app/shared/services/competency-group-grade.service'; import { CompetencyGroupGradeService } from 'src/app/shared/services/competency-group-grade.service';
import { IndicatorsCoursesService } from 'src/app/shared/services/indicators-courses.service'; import { IndicatorsCoursesService } from 'src/app/shared/services/indicators-courses.service';
import { IdpDevelopmentService } from 'src/app/shared/services/idp-development.service'; import { IdpDevelopmentService } from 'src/app/shared/services/idp-development.service';
import { GroupAssessmentService } from 'src/app/shared/services/group-assessment.service';
import { GroupApproveService } from 'src/app/shared/services/group-approve.service'; import { GroupApproveService } from 'src/app/shared/services/group-approve.service';
import { UserService } from 'src/app/shared/services/user.service'; import { UserService } from 'src/app/shared/services/user.service';
import { ManageUserComponent } from '../company-components/account-settings/manage-user/manage-user.component'; import { ManageUserComponent } from '../company-components/account-settings/manage-user/manage-user.component';
...@@ -302,6 +303,7 @@ export class CustomDateAdapter extends NativeDateAdapter { ...@@ -302,6 +303,7 @@ export class CustomDateAdapter extends NativeDateAdapter {
CompetencyGroupGradeService, CompetencyGroupGradeService,
IndicatorsCoursesService, IndicatorsCoursesService,
IdpDevelopmentService, IdpDevelopmentService,
GroupAssessmentService,
GroupApproveService, GroupApproveService,
UserService, UserService,
{ {
......
import { CompetencytopicModel, MyCompetencytopicModel } from "./competencytopic.model"
export interface CompetencyIndicatorsCourses0Model {
competencyTopic: CompetencytopicModel
companyId: string
edesc: string
tdesc: string
indicatorsCourseDetailTh: string
indicatorsCourseDetailEn: string
expectation:string
}
export class MyCompetencyIndicatorsCourses0Model implements CompetencyIndicatorsCourses0Model {
competencyTopic: CompetencytopicModel
companyId: string
edesc: string
tdesc: string
indicatorsCourseDetailTh: string
indicatorsCourseDetailEn: string
expectation:string
constructor(data: Partial<CompetencyIndicatorsCourses0Model>) {
this.competencyTopic = new MyCompetencytopicModel(data.competencyTopic || {})
this.companyId = data.companyId || ""
this.edesc = data.edesc || ""
this.tdesc = data.tdesc || ""
this.indicatorsCourseDetailTh = data.indicatorsCourseDetailTh || ""
this.indicatorsCourseDetailEn = data.indicatorsCourseDetailEn || ""
this.expectation = data.expectation || ""
}
}
...@@ -14,12 +14,12 @@ export class MyCompetencyIndicatorsCourses1ListModel implements CompetencyIndica ...@@ -14,12 +14,12 @@ export class MyCompetencyIndicatorsCourses1ListModel implements CompetencyIndica
competencyCourseId: string competencyCourseId: string
competencyCourse: CompetencyCourseModel[] competencyCourse: CompetencyCourseModel[]
competencyIndicatorsCourses2List: CompetencyIndicatorsCourses2ListModel[] competencyIndicatorsCourses2List: CompetencyIndicatorsCourses2ListModel[]
constructor(data: Partial<CompetencyIndicatorsCourses1ListModel>) { constructor(data?: Partial<CompetencyIndicatorsCourses1ListModel>) {
this.lineNo = data.lineNo ?? 0 this.lineNo = data?.lineNo ?? 0
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
this.competencyCourseId = data.competencyCourseId || "" this.competencyCourseId = data?.competencyCourseId || ""
this.competencyCourse = data.competencyCourse?.map(x => new MyCompetencyCourseModel(x)) || [] this.competencyCourse = data?.competencyCourse?.map(x => new MyCompetencyCourseModel(x)) || []
this.competencyIndicatorsCourses2List = data.competencyIndicatorsCourses2List?.map(x => new MyCompetencyIndicatorsCourses2ListModel(x)) || [] this.competencyIndicatorsCourses2List = data?.competencyIndicatorsCourses2List?.map(x => new MyCompetencyIndicatorsCourses2ListModel(x)) || []
} }
} }
import { CompetencyCourseModel, MyCompetencyCourseModel } from "./competency-course.model"
import { CompetencyIndicatorsCourses0Model, MyCompetencyIndicatorsCourses0Model } from "./competency-indicators-courses0.model"
export interface CompetencyIndicatorsCourses1MiniModel {
competencyIndicatorsCourses0: CompetencyIndicatorsCourses0Model
lineNo: number
companyId: string
competencyCourseId: string
competencyCourse: CompetencyCourseModel[]
}
export class MyCompetencyIndicatorsCourses1MiniModel implements CompetencyIndicatorsCourses1MiniModel {
competencyIndicatorsCourses0: CompetencyIndicatorsCourses0Model
lineNo: number
companyId: string
competencyCourseId: string
competencyCourse: CompetencyCourseModel[]
constructor(data?: Partial<CompetencyIndicatorsCourses1MiniModel>) {
this.competencyIndicatorsCourses0 = new MyCompetencyIndicatorsCourses0Model(data?.competencyIndicatorsCourses0 || {})
this.lineNo = data?.lineNo ?? 0
this.companyId = data?.companyId || ""
this.competencyCourseId = data?.competencyCourseId || ""
this.competencyCourse = data?.competencyCourse?.map(x => new MyCompetencyCourseModel(x)) || []
}
}
import { GroupAssessment1ListModel, MyGroupAssessment1ListModel } from "./group-assessment1-list.model"
import { MyPLModel, PLModel } from "./pl.model"
export interface GroupAssessmentModel {
personalLevel: PLModel
companyId: string
groupAssessment1List: GroupAssessment1ListModel[]
}
export class MyGroupAssessmentModel implements GroupAssessmentModel {
personalLevel: PLModel
companyId: string
groupAssessment1List: GroupAssessment1ListModel[]
constructor(data?: Partial<GroupAssessmentModel>) {
this.personalLevel = new MyPLModel(data?.personalLevel || {})
this.companyId = data?.companyId || ""
this.groupAssessment1List = data?.groupAssessment1List?.map(x => new MyGroupAssessment1ListModel(x)) || []
}
}
import { CompetencyIndicatorsCourses1MiniModel, MyCompetencyIndicatorsCourses1MiniModel } from "./competency-indicators-courses1-mini.model"
export interface GroupAssessment1ListModel {
competencyIndicatorsCourses1Mini: CompetencyIndicatorsCourses1MiniModel
companyId: string
}
export class MyGroupAssessment1ListModel implements GroupAssessment1ListModel {
competencyIndicatorsCourses1Mini: CompetencyIndicatorsCourses1MiniModel
companyId: string
constructor(data?: Partial<GroupAssessment1ListModel>) {
this.competencyIndicatorsCourses1Mini = new MyCompetencyIndicatorsCourses1MiniModel(data?.competencyIndicatorsCourses1Mini || {})
this.companyId = data?.companyId || ""
}
}
...@@ -9,6 +9,7 @@ export interface IndicatorsCoursesModel { ...@@ -9,6 +9,7 @@ export interface IndicatorsCoursesModel {
tdesc: string tdesc: string
indicatorsCourseDetailTh: string indicatorsCourseDetailTh: string
indicatorsCourseDetailEn: string indicatorsCourseDetailEn: string
expectation:string
competencyIndicatorsCourses1List: CompetencyIndicatorsCourses1ListModel[] competencyIndicatorsCourses1List: CompetencyIndicatorsCourses1ListModel[]
} }
...@@ -19,15 +20,17 @@ export class MyIndicatorsCoursesModel implements IndicatorsCoursesModel { ...@@ -19,15 +20,17 @@ export class MyIndicatorsCoursesModel implements IndicatorsCoursesModel {
tdesc: string tdesc: string
indicatorsCourseDetailTh: string indicatorsCourseDetailTh: string
indicatorsCourseDetailEn: string indicatorsCourseDetailEn: string
expectation:string
competencyIndicatorsCourses1List: CompetencyIndicatorsCourses1ListModel[] competencyIndicatorsCourses1List: CompetencyIndicatorsCourses1ListModel[]
constructor(data: Partial<IndicatorsCoursesModel>) { constructor(data?: Partial<IndicatorsCoursesModel>) {
this.competencyTopic = new MyCompetencytopicModel(data.competencyTopic || {}) this.competencyTopic = new MyCompetencytopicModel(data?.competencyTopic || {})
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
this.edesc = data.edesc || "" this.edesc = data?.edesc || ""
this.tdesc = data.tdesc || "" this.tdesc = data?.tdesc || ""
this.indicatorsCourseDetailTh = data.indicatorsCourseDetailTh || "" this.indicatorsCourseDetailTh = data?.indicatorsCourseDetailTh || ""
this.indicatorsCourseDetailEn = data.indicatorsCourseDetailEn || "" this.indicatorsCourseDetailEn = data?.indicatorsCourseDetailEn || ""
this.competencyIndicatorsCourses1List = data.competencyIndicatorsCourses1List?.map(x => new MyCompetencyIndicatorsCourses1ListModel(x)) || [] this.expectation = data?.expectation || ""
this.competencyIndicatorsCourses1List = data?.competencyIndicatorsCourses1List?.map(x => new MyCompetencyIndicatorsCourses1ListModel(x)) || []
} }
} }
...@@ -11,11 +11,11 @@ export class MyPLModel implements PLModel { ...@@ -11,11 +11,11 @@ export class MyPLModel implements PLModel {
tdesc: string; tdesc: string;
edesc: string; edesc: string;
companyId: string companyId: string
constructor(data: Partial<PLModel>) { constructor(data?: Partial<PLModel>) {
this.plId = data.plId || "" this.plId = data?.plId || ""
this.tdesc = data.tdesc || "" this.tdesc = data?.tdesc || ""
this.edesc = data.edesc || "" this.edesc = data?.edesc || ""
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
} }
} }
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AlertModel } from '../model/alert.model';
import { GroupAssessmentModel } from '../model/group-assessment.model';
@Injectable({
providedIn: 'root'
})
export class GroupAssessmentService {
api = "/groupassessment"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getById(plId: string): Observable<GroupAssessmentModel> {
return this.http.get<GroupAssessmentModel>(this.urlApi + "/" + plId)
}
getList(): Observable<GroupAssessmentModel[]> {
return this.http.get<GroupAssessmentModel[]>(this.urlApi + "/lists")
}
post(body: GroupAssessmentModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body)
}
delete(body: GroupAssessmentModel | GroupAssessmentModel[]): Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
return this.http.delete<AlertModel>(this.urlApi, options)
}
}
\ No newline at end of file
...@@ -13,7 +13,7 @@ export class IndicatorsCoursesService { ...@@ -13,7 +13,7 @@ export class IndicatorsCoursesService {
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
} }
getList(): Observable<IndicatorsCoursesModel[]> { getList(): Observable<IndicatorsCoursesModel[]> {
return this.http.get<IndicatorsCoursesModel[]>(this.urlApi + "/lists") return this.http.get<IndicatorsCoursesModel[]>(this.urlApi + "/lists/indicators-courses")
} }
getById(competencyIndicatorsId: string): Observable<IndicatorsCoursesModel> { getById(competencyIndicatorsId: string): Observable<IndicatorsCoursesModel> {
return this.http.get<IndicatorsCoursesModel>(this.urlApi + "/" + competencyIndicatorsId) return this.http.get<IndicatorsCoursesModel>(this.urlApi + "/" + competencyIndicatorsId)
......
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