From 52bf47e489531e65af8b27b6dfe9e36ffe4d9a4b Mon Sep 17 00:00:00 2001 From: leejinho Date: Thu, 26 Dec 2019 11:19:43 +0900 Subject: [PATCH] =?UTF-8?q?1.=20=EC=A1=B0=EC=A7=81=EB=8F=84=20order=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9.=202.=20=EC=AA=BD=EC=A7=80=20=EB=B3=B4?= =?UTF-8?q?=EB=82=B4=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20debounce=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9.=203.=20dialog=20=EC=97=90=20=EC=9E=AC=EB=8F=99=20foc?= =?UTF-8?q?us=20=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=EB=B2=84=ED=8A=BC=20focu?= =?UTF-8?q?sed=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/store/messenger/query/effects.ts | 3 ++ .../components/split-button.component.html | 6 ++- .../directives/click-debounce.directive.ts | 40 +++++++++++++++++++ .../src/lib/services/dialog.service.ts | 2 + .../src/lib/ucap-ui.module.ts | 4 +- 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 projects/ucap-webmessenger-ui/src/lib/directives/click-debounce.directive.ts diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/query/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/query/effects.ts index 063941ba..e969e38b 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/query/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/query/effects.ts @@ -48,6 +48,9 @@ export class Effects { departmentInfoList.push(...(res as DeptData).departmentInfos); break; case SSVC_TYPE_QUERY_DEPT_RES: + departmentInfoList.sort((a, b) => + a.order < b.order ? -1 : a.order > b.order ? 1 : 0 + ); this.store.dispatch( deptSuccess({ departmentInfoList diff --git a/projects/ucap-webmessenger-ui/src/lib/components/split-button.component.html b/projects/ucap-webmessenger-ui/src/lib/components/split-button.component.html index 3f57c581..ce367c14 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/split-button.component.html +++ b/projects/ucap-webmessenger-ui/src/lib/components/split-button.component.html @@ -4,7 +4,11 @@ [disabled]="disabled" #matMenuTrigger="matMenuTrigger" > - + diff --git a/projects/ucap-webmessenger-ui/src/lib/directives/click-debounce.directive.ts b/projects/ucap-webmessenger-ui/src/lib/directives/click-debounce.directive.ts new file mode 100644 index 00000000..ea8b4b9c --- /dev/null +++ b/projects/ucap-webmessenger-ui/src/lib/directives/click-debounce.directive.ts @@ -0,0 +1,40 @@ +import { + Directive, + EventEmitter, + HostListener, + Input, + OnDestroy, + OnInit, + Output +} from '@angular/core'; +import { Subject, Subscription } from 'rxjs'; +import { debounceTime } from 'rxjs/operators'; + +@Directive({ + selector: '[ucapDebounceClick]' +}) +export class ClickDebounceDirective implements OnInit, OnDestroy { + @Input() debounceTime = 500; + @Output() debounceClick = new EventEmitter(); + private clicks = new Subject(); + private subscription: Subscription; + + constructor() {} + + ngOnInit() { + this.subscription = this.clicks + .pipe(debounceTime(this.debounceTime)) + .subscribe(e => this.debounceClick.emit(e)); + } + + ngOnDestroy() { + this.subscription.unsubscribe(); + } + + @HostListener('click', ['$event']) + clickEvent(event) { + event.preventDefault(); + event.stopPropagation(); + this.clicks.next(event); + } +} diff --git a/projects/ucap-webmessenger-ui/src/lib/services/dialog.service.ts b/projects/ucap-webmessenger-ui/src/lib/services/dialog.service.ts index a6242291..a193cd2a 100644 --- a/projects/ucap-webmessenger-ui/src/lib/services/dialog.service.ts +++ b/projects/ucap-webmessenger-ui/src/lib/services/dialog.service.ts @@ -16,6 +16,8 @@ export class DialogService { config?: MatDialogConfig ): Promise { return new Promise((resolve, reject) => { + config = { ...config, autoFocus: false }; + const dialogRef = this.matDialog.open( componentOrTemplateRef, config diff --git a/projects/ucap-webmessenger-ui/src/lib/ucap-ui.module.ts b/projects/ucap-webmessenger-ui/src/lib/ucap-ui.module.ts index 7e5c52de..3f5fec6a 100644 --- a/projects/ucap-webmessenger-ui/src/lib/ucap-ui.module.ts +++ b/projects/ucap-webmessenger-ui/src/lib/ucap-ui.module.ts @@ -71,6 +71,7 @@ import { StringEmptyCheckPipe, StringFormatterPhonePipe } from './pipes/string.pipe'; +import { ClickDebounceDirective } from './directives/click-debounce.directive'; const COMPONENTS = [ FileUploadQueueComponent, @@ -94,7 +95,8 @@ const DIRECTIVES = [ ClickOutsideDirective, FileUploadForDirective, ImageDirective, - CdkVirtualScrollViewportPatchDirective + CdkVirtualScrollViewportPatchDirective, + ClickDebounceDirective ]; const PIPES = [ BytesPipe,