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,