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