From 4ebd0c88db1d0896a9def832d67b6870dc861efb Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 27 Sep 2023 00:39:33 -0700 Subject: [PATCH] Detect more focus loss, css cleanup, translation --- src-ui/messages.xlf | 76 +++++++++---------- .../file-drop/file-drop.component.html | 6 +- .../file-drop/file-drop.component.scss | 8 ++ .../file-drop/file-drop.component.spec.ts | 29 +++++++ .../file-drop/file-drop.component.ts | 13 +++- src-ui/src/styles.scss | 43 ----------- 6 files changed, 89 insertions(+), 86 deletions(-) diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 2caa5db3a..e5e3ab765 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -243,40 +243,33 @@ 13 - - Drop files to begin upload - - src/app/app.component.html - 7 - - Document added src/app/app.component.ts - 86 + 83 src/app/app.component.ts - 96 + 93 Document was added to paperless. src/app/app.component.ts - 88 + 85 src/app/app.component.ts - 98 + 95 Open document src/app/app.component.ts - 89 + 86 src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html @@ -287,35 +280,35 @@ Could not add : src/app/app.component.ts - 112 + 109 New document detected src/app/app.component.ts - 127 + 124 Document is being processed by paperless. src/app/app.component.ts - 129 + 126 Prev src/app/app.component.ts - 134 + 131 Next src/app/app.component.ts - 135 + 132 src/app/components/document-detail/document-detail.component.html @@ -326,105 +319,98 @@ End src/app/app.component.ts - 136 + 133 The dashboard can be used to show saved views, such as an 'Inbox'. Those settings are found under Settings > Saved Views once you have created some. src/app/app.component.ts - 142 + 139 Drag-and-drop documents here to start uploading or place them in the consume folder. You can also drag-and-drop documents anywhere on all other pages of the web app. Once you do, Paperless-ngx will start training its machine learning algorithms. src/app/app.component.ts - 149 + 146 The documents list shows all of your documents and allows for filtering as well as bulk-editing. There are three different view styles: list, small cards and large cards. A list of documents currently opened for editing is shown in the sidebar. src/app/app.component.ts - 154 + 151 The filtering tools allow you to quickly find documents using various searches, dates, tags, etc. src/app/app.component.ts - 161 + 158 Any combination of filters can be saved as a 'view' which can then be displayed on the dashboard and / or sidebar. src/app/app.component.ts - 167 + 164 Tags, correspondents, document types and storage paths can all be managed using these pages. They can also be created from the document edit view. src/app/app.component.ts - 172 + 169 Manage e-mail accounts and rules for automatically importing documents. src/app/app.component.ts - 180 + 177 Consumption templates give you finer control over the document ingestion process. src/app/app.component.ts - 188 + 185 File Tasks shows you documents that have been consumed, are waiting to be, or may have failed during the process. src/app/app.component.ts - 196 + 193 Check out the settings for various tweaks to the web app and toggle settings for saved views. src/app/app.component.ts - 204 + 201 Thank you! 🙏 src/app/app.component.ts - 212 + 209 There are <em>tons</em> more features and info we didn't cover here, but this should get you started. Check out the documentation or visit the project on GitHub to learn more or to report issues. src/app/app.component.ts - 214 + 211 Lastly, on behalf of every contributor to this community-supported project, thank you for using Paperless-ngx! src/app/app.component.ts - 216 - - - - Initiating upload... - - src/app/app.component.ts - 272 + 213 @@ -5120,6 +5106,20 @@ 80 + + Drop files to begin upload + + src/app/components/file-drop/file-drop.component.html + 6 + + + + Initiating upload... + + src/app/components/file-drop/file-drop.component.ts + 87 + + Add Template diff --git a/src-ui/src/app/components/file-drop/file-drop.component.html b/src-ui/src/app/components/file-drop/file-drop.component.html index 1d4b9e0e6..9e29ba6b5 100644 --- a/src-ui/src/app/components/file-drop/file-drop.component.html +++ b/src-ui/src/app/components/file-drop/file-drop.component.html @@ -1,9 +1,9 @@ -
+
-
-

Drop files to begin upload

+
+

Drop files to begin upload

{ component.onDrop(new Event('drop') as DragEvent) expect(settingsService.globalDropzoneActive).toBeTruthy() })) + + it('should hide if app loses focus', fakeAsync(() => { + const leaveSpy = jest.spyOn(component, 'onDragLeave') + jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) + settingsService.globalDropzoneEnabled = true + component.onDragOver(new Event('dragover') as DragEvent) + tick(1) + expect(component.hidden).toBeFalsy() + expect(component.fileIsOver).toBeTruthy() + jest.spyOn(document, 'hidden', 'get').mockReturnValue(true) + component.onVisibilityChange() + expect(leaveSpy).toHaveBeenCalled() + flush() + })) + + it('should hide on window blur', fakeAsync(() => { + const leaveSpy = jest.spyOn(component, 'onDragLeave') + jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) + settingsService.globalDropzoneEnabled = true + component.onDragOver(new Event('dragover') as DragEvent) + tick(1) + expect(component.hidden).toBeFalsy() + expect(component.fileIsOver).toBeTruthy() + jest.spyOn(document, 'hidden', 'get').mockReturnValue(true) + component.onWindowBlur() + expect(leaveSpy).toHaveBeenCalled() + flush() + })) }) diff --git a/src-ui/src/app/components/file-drop/file-drop.component.ts b/src-ui/src/app/components/file-drop/file-drop.component.ts index 833c84cbb..0c9637b79 100644 --- a/src-ui/src/app/components/file-drop/file-drop.component.ts +++ b/src-ui/src/app/components/file-drop/file-drop.component.ts @@ -57,8 +57,8 @@ export class FileDropComponent { immediate: boolean = false ) { if (!this.dragDropEnabled) return - event.preventDefault() - event.stopImmediatePropagation() + event?.preventDefault() + event?.stopImmediatePropagation() this.settings.globalDropzoneActive = false const ms = immediate ? 0 : 500 @@ -86,4 +86,13 @@ export class FileDropComponent { if (files.length > 0) this.toastService.showInfo($localize`Initiating upload...`, 3000) } + + @HostListener('window:blur', ['$event']) public onWindowBlur() { + if (this.fileIsOver) this.onDragLeave(null) + } + + @HostListener('document:visibilitychange', ['$event']) + public onVisibilityChange() { + if (document.hidden && this.fileIsOver) this.onDragLeave(null) + } } diff --git a/src-ui/src/styles.scss b/src-ui/src/styles.scss index 6065224ce..d93b6d8db 100644 --- a/src-ui/src/styles.scss +++ b/src-ui/src/styles.scss @@ -484,49 +484,6 @@ table.table { color: var(--bs-body-color); } -.main-dropzone { - height: 100%; - width: 100%; - - &.ngx-file-drop__drop-zone--over { - background-color: transparent !important; - } -} - -.global-dropzone-overlay { - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - background-color: hsla(var(--pngx-primary), var(--pngx-primary-lightness), .8); - z-index: 1055; // $zindex-modal - pointer-events: none !important; - user-select: none !important; - text-align: center; - padding-top: 25%; - - h2 { - color: var(--pngx-primary-text-contrast) - } -} - -.ngx-file-drop__drop-zone--over { - .global-dropzone-overlay { - opacity: 1; - pointer-events: all !important; - - * { - pointer-events: none; - } - } - - .main-wrapper { - pointer-events: none !important; - user-select: none !important; - } -} - .alert-primary { --bs-alert-color: var(--bs-primary); --bs-alert-bg: var(--pngx-primary-faded);