1
0
mirror of https://github.com/NicolasConstant/sengi synced 2025-02-10 00:40:36 +01:00

disable column editing when clicking out

This commit is contained in:
Nicolas Constant 2019-08-05 17:59:04 -04:00
parent 63475fd813
commit caa0964116
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 30 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input, HostListener, ElementRef, Output, EventEmitter } from '@angular/core';
import { Store } from '@ngxs/store'; import { Store } from '@ngxs/store';
import { faChevronLeft, faChevronRight, faTimes } from "@fortawesome/free-solid-svg-icons"; import { faChevronLeft, faChevronRight, faTimes } from "@fortawesome/free-solid-svg-icons";
@ -18,14 +18,33 @@ export class StreamEditionComponent implements OnInit {
hideReplies: boolean; hideReplies: boolean;
hideBots: boolean; hideBots: boolean;
private init: boolean;
@Input() streamElement: StreamElement; @Input() streamElement: StreamElement;
constructor(private readonly store: Store) { } @Output('closed') public closedEvent = new EventEmitter();
@HostListener('document:click', ['$event'])
clickout(event) {
if (!this.init) return;
if (!this.eRef.nativeElement.contains(event.target)) {
this.closedEvent.emit(null);
}
}
constructor(
private readonly store: Store,
private eRef: ElementRef) { }
ngOnInit() { ngOnInit() {
this.hideBoosts = this.streamElement.hideBoosts; this.hideBoosts = this.streamElement.hideBoosts;
this.hideReplies = this.streamElement.hideReplies; this.hideReplies = this.streamElement.hideReplies;
this.hideBots = this.streamElement.hideBots; this.hideBots = this.streamElement.hideBots;
setTimeout(() => {
this.init = true;
}, 0);
} }
settingsChanged(): boolean { settingsChanged(): boolean {

View File

@ -16,7 +16,9 @@
</a> </a>
</div> </div>
<app-stream-edition class="stream-edition" *ngIf="editionPanelIsOpen" [streamElement]="streamElement"> <app-stream-edition class="stream-edition" *ngIf="editionPanelIsOpen"
[streamElement]="streamElement"
(closed)="streamEditionClosed()">
</app-stream-edition> </app-stream-edition>
<app-stream-statuses class="stream-statuses" <app-stream-statuses class="stream-statuses"

View File

@ -95,5 +95,10 @@ export class StreamComponent implements OnInit {
this.editionPanelIsOpen = !this.editionPanelIsOpen; this.editionPanelIsOpen = !this.editionPanelIsOpen;
return false; return false;
} }
streamEditionClosed(): boolean {
this.editionPanelIsOpen = false;
return false;
}
} }