autocomplete of room search is added
This commit is contained in:
parent
7d6ebad5d5
commit
e177cf5184
|
@ -1,24 +1,37 @@
|
|||
<div class="app-layout-chat-left-sidenav-chat-header">
|
||||
<mat-form-field class="w-100-p" floatLabel="never">
|
||||
<input
|
||||
matInput
|
||||
#inputSearch
|
||||
type="text"
|
||||
maxlength="20"
|
||||
placeholder="대화방 이름 검색"
|
||||
value=""
|
||||
(keydown.enter)="onKeyDownEnter(inputSearch.value)"
|
||||
/>
|
||||
<button
|
||||
mat-button
|
||||
matSuffix
|
||||
mat-icon-button
|
||||
aria-label="Clear"
|
||||
(click)="inputSearch.value = ''; searchWord = ''; isSearch = false"
|
||||
>
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
<form [formGroup]="fgSearch">
|
||||
<mat-form-field class="w-100-p" floatLabel="never">
|
||||
<input
|
||||
matInput
|
||||
#inputSearch
|
||||
type="text"
|
||||
maxlength="20"
|
||||
placeholder="대화방 이름 검색"
|
||||
value=""
|
||||
formControlName="searchInput"
|
||||
[matAutocomplete]="auto"
|
||||
(keydown.enter)="onKeyDownEnter(inputSearch.value)"
|
||||
/>
|
||||
<mat-autocomplete #auto="matAutocomplete">
|
||||
<mat-option
|
||||
*ngFor="let filteredRecommendedWord of filteredRecommendedWordList"
|
||||
[value]="filteredRecommendedWord"
|
||||
>
|
||||
{{ filteredRecommendedWord }}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
|
||||
<button
|
||||
mat-button
|
||||
matSuffix
|
||||
mat-icon-button
|
||||
aria-label="Clear"
|
||||
(click)="inputSearch.value = ''; searchWord = ''; isSearch = false"
|
||||
>
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</mat-form-field>
|
||||
</form>
|
||||
</div>
|
||||
<div class="app-layout-chat-left-sidenav-chat-list" perfectScrollbar>
|
||||
<ucap-room-list-item
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
import * as AppStore from '@app/store';
|
||||
import * as ChatStore from '@app/store/messenger/chat';
|
||||
import * as RoomStore from '@app/store/messenger/room';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { tap, debounceTime } from 'rxjs/operators';
|
||||
import {
|
||||
RoomUserDetailData,
|
||||
RoomUserData
|
||||
|
@ -22,6 +22,7 @@ import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
|||
import { KEY_VER_INFO } from '@app/types/ver-info.type';
|
||||
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||||
import { MatMenuTrigger } from '@angular/material';
|
||||
import { FormGroup, FormBuilder } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout-chat-left-sidenav-chat',
|
||||
|
@ -43,20 +44,44 @@ export class ChatComponent implements OnInit, OnDestroy {
|
|||
loginResSubscription: Subscription;
|
||||
roomSubscription: Subscription;
|
||||
|
||||
isSearch = false;
|
||||
searchWord = '';
|
||||
fgSearch: FormGroup;
|
||||
recommendedWordList: string[];
|
||||
filteredRecommendedWordList: string[];
|
||||
|
||||
constructor(
|
||||
private store: Store<any>,
|
||||
private formBuilder: FormBuilder,
|
||||
private logger: NGXLogger,
|
||||
private sessionStorageService: SessionStorageService
|
||||
) {
|
||||
this.sessionVerinfo = this.sessionStorageService.get<VersionInfo2Response>(
|
||||
KEY_VER_INFO
|
||||
);
|
||||
this.recommendedWordList = [];
|
||||
}
|
||||
|
||||
isSearch = false;
|
||||
searchWord = '';
|
||||
|
||||
ngOnInit() {
|
||||
this.fgSearch = this.formBuilder.group({
|
||||
searchInput: null
|
||||
});
|
||||
|
||||
this.fgSearch
|
||||
.get('searchInput')
|
||||
.valueChanges.pipe(debounceTime(300))
|
||||
.subscribe(value => {
|
||||
if (value !== null && value.length > 0) {
|
||||
this.filteredRecommendedWordList = this.recommendedWordList.filter(
|
||||
v => {
|
||||
return v.includes(value);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.filteredRecommendedWordList = [];
|
||||
}
|
||||
});
|
||||
|
||||
this.roomSubscription = combineLatest([
|
||||
this.store.pipe(
|
||||
select(AppStore.MessengerSelector.SyncSelector.selectAllRoom)
|
||||
|
@ -73,6 +98,33 @@ export class ChatComponent implements OnInit, OnDestroy {
|
|||
this.roomList = room;
|
||||
this.roomUserList = roomUser;
|
||||
this.roomUserShortList = roomUserShort;
|
||||
|
||||
const recommendedWordList = [];
|
||||
for (const r of room) {
|
||||
if (!!r.roomName && '' !== r.roomName.trim()) {
|
||||
recommendedWordList.push(r.roomName);
|
||||
}
|
||||
}
|
||||
for (const ru of roomUser) {
|
||||
for (const u of ru.userInfos) {
|
||||
if (u.seq !== this.loginRes.userSeq) {
|
||||
if (!!u.name && '' !== u.name.trim()) {
|
||||
recommendedWordList.push(u.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const ru of roomUserShort) {
|
||||
for (const u of ru.userInfos) {
|
||||
if (u.seq !== this.loginRes.userSeq) {
|
||||
if (!!u.name && '' !== u.name.trim()) {
|
||||
recommendedWordList.push(u.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.recommendedWordList = [...recommendedWordList];
|
||||
})
|
||||
)
|
||||
.subscribe();
|
||||
|
|
|
@ -8,6 +8,7 @@ import { FlexLayoutModule } from '@angular/flex-layout';
|
|||
|
||||
import { ScrollingModule } from '@angular/cdk/scrolling';
|
||||
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatBadgeModule } from '@angular/material/badge';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
|
@ -46,6 +47,8 @@ import { DIALOGS } from './dialogs';
|
|||
ReactiveFormsModule,
|
||||
OverlayModule,
|
||||
ScrollingModule,
|
||||
|
||||
MatAutocompleteModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
MatBadgeModule,
|
||||
|
|
Loading…
Reference in New Issue
Block a user