From 01c131e8d7ecc2eac68e16a679c40b1156b41391 Mon Sep 17 00:00:00 2001 From: Mohammad Amoush Date: Sat, 7 Dec 2019 16:57:51 -0500 Subject: Adding hang-up functionality --- src/client/views/DocumentDecorations.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/client/views/DocumentDecorations.tsx') diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index b46caf3ea..719a0203b 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -39,6 +39,8 @@ library.add(faCloudUploadAlt); library.add(faSyncAlt); library.add(faShare); +export type CloseCall = (toBeDeleted: DocumentView[]) => void; + @observer export class DocumentDecorations extends React.Component<{}, { value: string }> { static Instance: DocumentDecorations; @@ -69,6 +71,8 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> @observable public isAnimatingFetch = false; @observable public isAnimatingPulse = false; @observable public openHover = false; + @observable private addedCloseCalls: CloseCall[] = []; + constructor(props: Readonly<{}>) { super(props); @@ -77,6 +81,14 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> reaction(() => SelectionManager.SelectedDocuments().slice(), docs => this._edtingTitle = false); } + addCloseCall = (handler: CloseCall) => { + const currentOffset = this.addedCloseCalls.length - 1; + this.addedCloseCalls.push((toBeDeleted: DocumentView[]) => { + this.addedCloseCalls.splice(currentOffset, 1); + handler(toBeDeleted); + }); + } + @action titleChanged = (event: any) => { this._title = event.target.value; }; @action titleBlur = () => { this._edtingTitle = false; }; @action titleEntered = (e: any) => { @@ -239,10 +251,12 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> e.stopPropagation(); if (e.button === 0) { const recent = Cast(CurrentUserUtils.UserDocument.recentlyClosed, Doc) as Doc; - SelectionManager.SelectedDocuments().map(dv => { + const selectedDocuments = SelectionManager.SelectedDocuments(); + selectedDocuments.map(dv => { recent && Doc.AddDocToList(recent, "data", dv.props.Document, undefined, true, true); dv.props.removeDocument && dv.props.removeDocument(dv.props.Document); }); + this.addedCloseCalls.forEach(handler => handler(selectedDocuments)); SelectionManager.DeselectAll(); document.removeEventListener("pointermove", this.onCloseMove); document.removeEventListener("pointerup", this.onCloseUp); -- cgit v1.2.3-70-g09d2 From c056ed67110038527872100b08f8d2ff20ecd032 Mon Sep 17 00:00:00 2001 From: Mohammad Amoush <47069173+mamoush34@users.noreply.github.com> Date: Sun, 19 Jan 2020 16:08:01 +0300 Subject: working condition --- src/client/views/DocumentDecorations.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/client/views/DocumentDecorations.tsx') diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index bacbcaa97..9496375f4 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -85,6 +85,14 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> @action titleChanged = (event: any) => this._accumulatedTitle = event.target.value; + addCloseCall = (handler: CloseCall) => { + const currentOffset = this.addedCloseCalls.length - 1; + this.addedCloseCalls.push((toBeDeleted: DocumentView[]) => { + this.addedCloseCalls.splice(currentOffset, 1); + handler(toBeDeleted); + }); + } + titleBlur = undoBatch(action((commit: boolean) => { this._edtingTitle = false; if (commit) { @@ -241,6 +249,8 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> const recent = Cast(CurrentUserUtils.UserDocument.recentlyClosed, Doc) as Doc; const selected = SelectionManager.SelectedDocuments().slice(); SelectionManager.DeselectAll(); + this.addedCloseCalls.forEach(handler => handler(selected)); + selected.map(dv => { recent && Doc.AddDocToList(recent, "data", dv.props.Document, undefined, true, true); dv.props.removeDocument && dv.props.removeDocument(dv.props.Document); -- cgit v1.2.3-70-g09d2