Skip to content

Commit

Permalink
Merge pull request #165 from KB-iGOT/designation-select-limit-fix
Browse files Browse the repository at this point in the history
org select limit fix
  • Loading branch information
sureshece16 authored Jan 18, 2025
2 parents e5626ff + 6f0b696 commit bd59be6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@
<div class="w-full flex flex-4 flex-row designations-card-container flex-wrap gap-5">
<ng-container *ngFor="let designation of igotDesignationsList let i = index">
<div class="flex flex-4 custom-user-card items-center justify-center" [ngClass]="{'active-card': (designation?.selected && !designation?.isOrgDesignation),
'disableCard': designation?.isOrgDesignation}">
'disableCard': designation?.isOrgDesignation}" (click)="selectDesignation(i)">
<div class="custom-user-desc">
<p [matTooltip]="designation?.designation" matTooltipPosition="above">{{designation?.designation |
titlecase}}</p>
</div>

<div class="check-action">
<mat-checkbox [checked]="designation?.selected" [disabled]="designation?.isOrgDesignation"
(change)="selectDesignation($event.checked, designation.id)"></mat-checkbox>
<!-- <mat-checkbox [checked]="designation?.selected" [disabled]="designation?.isOrgDesignation"
(change)="selectDesignation($event.checked, designation.id)"></mat-checkbox> -->
<mat-checkbox [checked]="designation?.selected" (click)="$event.preventDefault()"
[disabled]="designation?.isOrgDesignation"></mat-checkbox>
</div>
</div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,42 @@ export class ImportDesignationComponent implements OnInit, OnDestroy {
})
}

selectDesignation(checked: Boolean, id: number) {
const index = this.igotDesignationsList.findIndex((e: any) => e.id === id)
// selectDesignation(checked: Boolean, id: number) {

selectDesignation(index: number) {
// const index = this.igotDesignationsList.findIndex((e: any) => e.id === id)
const designation = this.igotDesignationsList[index]
if (checked) {
designation['selected'] = true
this.selectedDesignationsList.push(designation)
this.designationsService.updateSelectedDesignationList(this.selectedDesignationsList)
// this.igotDesignationsList.splice(index, 1)
// this.igotDesignationsList.unshift(designation)
} else {
this.removeDesignation([designation])
const maxSelectedDesignation = 1000
const errorMessages = `You have exceeded more than ${maxSelectedDesignation} designation please talk to support team for support`
if (designation && !designation.isOrgDesignation) {
const checked = designation['selected'] !== true ? true : false
if (checked) {
designation['selected'] = true
this.selectedDesignationsList.push(designation)
if (this.totalSelectedCount > maxSelectedDesignation) {
this.openSnackbar(errorMessages, 2000, 'error')
designation['selected'] = false
} else {
this.designationsService.updateSelectedDesignationList(this.selectedDesignationsList)
}

// this.igotDesignationsList.splice(index, 1)
// this.igotDesignationsList.unshift(designation)
} else {
this.removeDesignation([designation])
}
}
}

get selctedDesignationsCount() {
return this.selectedDesignationsList.length
}

get totalSelectedCount() {
const designationCount = this.designationsService.selecteDesignationCount
return designationCount
}

removeDesignation(designationToRemoveList: any[]) {
designationToRemoveList.forEach((designationToRemove: any) => {
this.selectedDesignationsList = this.selectedDesignationsList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export class DesignationsService {
this.selectedDesignationList = selectedList
}

get selecteDesignationCount(): number {
return this.orgDesignationList.length + this.selectedDesignationList.length
}

formateMasterDesignationList(response: any): Observable<any> {
const result: any = {
formatedDesignationsLsit: [],
Expand Down

0 comments on commit bd59be6

Please sign in to comment.