Skip to content

Commit 0335f7f

Browse files
Merge pull request #252 from sohailamjad12/search_preffered_issue
Karma Quest: https://karmayogibharat.atlassian.net/browse/KB-5265 fixed preffered search issue
2 parents 8e3eecb + 3c28e31 commit 0335f7f

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
<mat-form-field appearance="outline" class="w-full placeholder-text field-height" fxFlex="40">
214214
<mat-select placeholder="Choose the Assignee" formControlName="assignee">
215215
<input #search autocomplete="off" placeholder="Search" class="assigneeSearch"
216-
(keyup)="searchValueData('assigneeText')" (keydown.space)="$event.stopPropagation()" formControlName="assigneeText" matInput>
216+
(keydown.space)="$event.stopPropagation()" formControlName="assigneeText" matInput>
217217
<mat-option *ngFor="let option of filteredAssigneeType" [value]="option">{{option.orgName}}</mat-option>
218218

219219
</mat-select>
@@ -243,7 +243,7 @@
243243
</mat-select-trigger>
244244
<mat-optgroup>
245245
<mat-form-field floatLabel="never">
246-
<input #search autocomplete="off" placeholder="Search" (keyup)="searchValueData('providerText')" (keydown.space)="$event.stopPropagation()"
246+
<input #search autocomplete="off" placeholder="Search" (keydown.space)="$event.stopPropagation()"
247247
formControlName="providerText" matInput>
248248
<button [disableRipple]="true" *ngIf="search.value" matSuffix mat-icon-button aria-label="Clear"
249249
(click)="clearSearch($event,'providerText')"><mat-icon>close</mat-icon></button>
@@ -252,7 +252,8 @@
252252
<mat-optgroup *ngIf="filteredRequestType.length === 0">
253253
<div>No results found!</div>
254254
</mat-optgroup>
255-
<mat-option *ngFor="let option of filteredRequestType" [disabled]="isOptionDisabled(option)" [value]="option">{{option.orgName}}</mat-option>
255+
<mat-option *ngFor="let option of filteredRequestType" [ngClass]="{'hideOptions': (option.hideOption && option.hideOption === 'hide')}"
256+
[disabled]="isOptionDisabled(option)" [value]="option">{{option.orgName}}</mat-option>
256257

257258
</mat-select>
258259
</mat-form-field>

project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@
173173
}
174174
}
175175
}
176+
177+
.hideOptions {
178+
display: none;
179+
}
176180
::ng-deep .tooltip-sec {
177181
background-color: 000000 !important;
178182
font-size: 12px !important;

project/ws/app/src/lib/routes/home/routes/request/request-copy-details/request-copy-details.component.ts

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class RequestCopyDetailsComponent implements OnInit {
115115
this.actionBtnName = params.name
116116
}
117117
})
118-
118+
this.valuechangeFuctions()
119119
}
120120

121121
getRequestDataById() {
@@ -161,7 +161,7 @@ export class RequestCopyDetailsComponent implements OnInit {
161161
if (this.filteredRequestType) {
162162
const abc = this.filteredRequestType.filter(option =>
163163
this.requestObjData.preferredProvider.some((res: any) =>
164-
res.providerName === option.orgName
164+
res.providerId === option.id
165165
)
166166
)
167167
this.requestForm.controls['providers'].setValue(abc)
@@ -170,7 +170,7 @@ export class RequestCopyDetailsComponent implements OnInit {
170170
if (this.filteredAssigneeType) {
171171
if (this.requestObjData.assignedProvider) {
172172
const assignData = this.filteredAssigneeType.find(option =>
173-
this.requestObjData.assignedProvider.providerName === option.orgName
173+
this.requestObjData.assignedProvider.providerId === option.id
174174
)
175175
if (assignData) {
176176
this.requestForm.controls['assignee'].setValue(assignData)
@@ -184,17 +184,19 @@ export class RequestCopyDetailsComponent implements OnInit {
184184
this.router.navigateByUrl('/app/home/all-request')
185185
}
186186

187-
searchValueData(searchValue: any) {
188-
if (searchValue === 'providerText') {
187+
188+
valuechangeFuctions() {
189+
if (this.requestForm.controls['providerText']) {
189190
this.requestForm.controls['providerText'].valueChanges.pipe(
190191
debounceTime(100),
191192
distinctUntilChanged(),
192193
startWith(''),
193194
).subscribe((newValue: any) => {
194-
this.filteredRequestType = this.filterOrgValues(newValue, this.requestTypeData)
195+
this.filteredRequestType = this.getHiddenOptions(newValue, this.requestTypeData)
195196
})
196197
}
197-
if (searchValue === 'assigneeText') {
198+
199+
if (this.requestForm.controls['assigneeText']) {
198200
this.requestForm.controls['assigneeText'].valueChanges.pipe(
199201
debounceTime(100),
200202
distinctUntilChanged(),
@@ -206,6 +208,28 @@ export class RequestCopyDetailsComponent implements OnInit {
206208

207209
}
208210

211+
// searchValueData(searchValue: any) {
212+
// if (searchValue === 'providerText') {
213+
// this.requestForm.controls['providerText'].valueChanges.pipe(
214+
// debounceTime(100),
215+
// distinctUntilChanged(),
216+
// startWith(''),
217+
// ).subscribe((newValue: any) => {
218+
// this.filteredRequestType = this.filterOrgValues(newValue, this.requestTypeData)
219+
// })
220+
// }
221+
// if (searchValue === 'assigneeText') {
222+
// this.requestForm.controls['assigneeText'].valueChanges.pipe(
223+
// debounceTime(100),
224+
// distinctUntilChanged(),
225+
// startWith(''),
226+
// ).subscribe((newValue: any) => {
227+
// this.filteredAssigneeType = this.filterOrgValues(newValue, this.requestTypeData)
228+
// })
229+
// }
230+
231+
// }
232+
209233
filterValues(searchValue: string, array: any) {
210234
return array.filter((value: any) =>
211235
value.name.toLowerCase().includes(searchValue.toLowerCase()))
@@ -216,6 +240,19 @@ export class RequestCopyDetailsComponent implements OnInit {
216240
value.orgName.toLowerCase().includes(searchValue.toLowerCase()))
217241
}
218242

243+
getHiddenOptions(searchValue: string, array: any) {
244+
const hiddenOptions: any = []
245+
array.forEach((element: any) => {
246+
if (element.orgName.toLowerCase().includes(searchValue.toLowerCase())) {
247+
element['hideOption'] = 'show'
248+
} else {
249+
element['hideOption'] = 'hide'
250+
}
251+
hiddenOptions.push(element)
252+
})
253+
return hiddenOptions
254+
}
255+
219256
getFilterEntity() {
220257
const filterObj = {
221258
search: {

0 commit comments

Comments
 (0)