mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-01 01:05:16 +00:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b94d85fd4 | ||
|
|
254e36ef0b | ||
|
|
480695a80d | ||
|
|
29d56ea28b | ||
|
|
6a1af9e1e5 | ||
|
|
45e99cde5a | ||
|
|
7ea58eaf46 | ||
|
|
a19804a0b7 | ||
|
|
3289be7383 | ||
|
|
d98918dd97 | ||
|
|
34c88613f6 | ||
|
|
13acdabb47 | ||
|
|
b67cfdf3fd | ||
|
|
98d2ddd1c6 | ||
|
|
91b35eada6 | ||
|
|
11248f776d | ||
|
|
331fa13088 | ||
|
|
ebddd5687c | ||
|
|
2925b8de81 | ||
|
|
5e397e1222 | ||
|
|
6f99ad9469 |
No files matched your search
@@ -10,9 +10,11 @@ if [[ -n "${PAPERLESS_CONSUMER_DISABLE}" ]]; then
|
||||
else
|
||||
cd ${PAPERLESS_SRC_DIR}
|
||||
|
||||
# Django system checks already ran once in init-system-checks, skip repeating them
|
||||
|
||||
if [[ -n "${USER_IS_NON_ROOT}" ]]; then
|
||||
exec python3 manage.py document_consumer
|
||||
exec python3 manage.py document_consumer --skip-checks
|
||||
else
|
||||
exec s6-setuidgid paperless python3 manage.py document_consumer
|
||||
exec s6-setuidgid paperless python3 manage.py document_consumer --skip-checks
|
||||
fi
|
||||
fi
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
cd ${PAPERLESS_SRC_DIR}
|
||||
|
||||
# Django system checks already ran once in init-system-checks, skip repeating them
|
||||
if [[ -n "${USER_IS_NON_ROOT}" ]]; then
|
||||
exec /usr/local/bin/celery --app paperless beat --loglevel INFO
|
||||
exec /usr/local/bin/celery --skip-checks --app paperless beat --loglevel INFO
|
||||
else
|
||||
exec s6-setuidgid paperless /usr/local/bin/celery --app paperless beat --loglevel INFO
|
||||
exec s6-setuidgid paperless /usr/local/bin/celery --skip-checks --app paperless beat --loglevel INFO
|
||||
fi
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
cd ${PAPERLESS_SRC_DIR}
|
||||
|
||||
# Django system checks already ran once in init-system-checks, skip repeating them
|
||||
if [[ -n "${USER_IS_NON_ROOT}" ]]; then
|
||||
exec /usr/local/bin/celery --app paperless worker --loglevel INFO --without-mingle --without-gossip
|
||||
exec /usr/local/bin/celery --skip-checks --app paperless worker --loglevel INFO --without-mingle --without-gossip
|
||||
else
|
||||
exec s6-setuidgid paperless /usr/local/bin/celery --app paperless worker --loglevel INFO --without-mingle --without-gossip
|
||||
exec s6-setuidgid paperless /usr/local/bin/celery --skip-checks --app paperless worker --loglevel INFO --without-mingle --without-gossip
|
||||
fi
|
||||
@@ -1,5 +1,29 @@
|
||||
# Changelog
|
||||
|
||||
## paperless-ngx 3.4.1
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix the id\_\_ schemae in the right place [@shamoon](https://github.com/shamoon) ([#14604](https://github.com/paperless-ngx/paperless-ngx/pull/14604))
|
||||
- Fix: drop redundant change perms checks on cards open button [@shamoon](https://github.com/shamoon) ([#14601](https://github.com/paperless-ngx/paperless-ngx/pull/14601))
|
||||
- Tweak/fix: make new pdf controls mostly hidden [@shamoon](https://github.com/shamoon) ([#14595](https://github.com/paperless-ngx/paperless-ngx/pull/14595))
|
||||
- Tweak/fix: move preview button in doc list [@shamoon](https://github.com/shamoon) ([#14594](https://github.com/paperless-ngx/paperless-ngx/pull/14594))
|
||||
- Fix: checksum light mode display and cf dropdown mobile position [@shamoon](https://github.com/shamoon) ([#14590](https://github.com/paperless-ngx/paperless-ngx/pull/14590))
|
||||
|
||||
### All App Changes
|
||||
|
||||
<details>
|
||||
<summary>6 changes</summary>
|
||||
|
||||
- Fix the id\_\_ schemae in the right place [@shamoon](https://github.com/shamoon) ([#14604](https://github.com/paperless-ngx/paperless-ngx/pull/14604))
|
||||
- Fix: drop redundant change perms checks on cards open button [@shamoon](https://github.com/shamoon) ([#14601](https://github.com/paperless-ngx/paperless-ngx/pull/14601))
|
||||
- Chore: Improve idle memory via more lazy imports [@stumpylog](https://github.com/stumpylog) ([#14599](https://github.com/paperless-ngx/paperless-ngx/pull/14599))
|
||||
- Tweak/fix: make new pdf controls mostly hidden [@shamoon](https://github.com/shamoon) ([#14595](https://github.com/paperless-ngx/paperless-ngx/pull/14595))
|
||||
- Tweak/fix: move preview button in doc list [@shamoon](https://github.com/shamoon) ([#14594](https://github.com/paperless-ngx/paperless-ngx/pull/14594))
|
||||
- Fix: checksum light mode display and cf dropdown mobile position [@shamoon](https://github.com/shamoon) ([#14590](https://github.com/paperless-ngx/paperless-ngx/pull/14590))
|
||||
|
||||
</details>
|
||||
|
||||
## paperless-ngx 3.4.0
|
||||
|
||||
### Features / Enhancements
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "paperless-ngx"
|
||||
version = "3.4.0"
|
||||
version = "3.4.1"
|
||||
description = """\
|
||||
A community-supported supercharged document management system: scan, index and archive all your physical documents\
|
||||
"""
|
||||
|
||||
@@ -43,6 +43,7 @@ def configure_environment(instance_root: Path) -> None:
|
||||
|
||||
|
||||
def seed_database() -> None:
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management import call_command
|
||||
from django.utils import timezone
|
||||
@@ -63,11 +64,18 @@ def seed_database() -> None:
|
||||
username="playwright",
|
||||
password="playwright", # NOSONAR
|
||||
)
|
||||
User.objects.create_user(
|
||||
viewer = User.objects.create_user(
|
||||
username="viewer",
|
||||
password="viewer", # NOSONAR
|
||||
)
|
||||
|
||||
viewer.user_permissions.add(
|
||||
Permission.objects.get(
|
||||
content_type__app_label="documents",
|
||||
codename="view_uisettings",
|
||||
),
|
||||
)
|
||||
|
||||
inbox = Tag.objects.create(name="Inbox", is_inbox_tag=True, owner=admin)
|
||||
quick_filter = Tag.objects.create(name="Another Sample Tag", owner=admin)
|
||||
Tag.objects.create(name="TagWithPartial", owner=admin)
|
||||
|
||||
@@ -80,12 +80,21 @@ test('should show a list of notes', async ({ page }) => {
|
||||
|
||||
test('should support quick filters', async ({ page }) => {
|
||||
await page.goto('/documents/1/details')
|
||||
// filter button is available before tags have loaded
|
||||
const selectedTags = page.locator('pngx-input-tags .ng-value pngx-tag')
|
||||
await expect(selectedTags).toHaveCount(2)
|
||||
await expect(
|
||||
selectedTags.getByText('Another Sample Tag', { exact: true })
|
||||
).toBeVisible()
|
||||
await expect(selectedTags.getByText('Inbox', { exact: true })).toBeVisible()
|
||||
await page
|
||||
.getByRole('button', { name: 'Filter documents with these Tags' })
|
||||
.click()
|
||||
await expect(page).toHaveURL(
|
||||
/tags__id__all=2,1&sort=created&reverse=1&page=1/
|
||||
)
|
||||
await expect(page).toHaveURL((url) => {
|
||||
const tags = url.searchParams.get('tags__id__all')?.split(',').sort()
|
||||
return url.pathname === '/documents' && tags?.join(',') === '1,2'
|
||||
})
|
||||
await expect(page.locator('pngx-document-list')).toHaveText(/one document/i)
|
||||
})
|
||||
|
||||
test('should finish reloading the preview after a remote document update', async ({
|
||||
|
||||
@@ -6,8 +6,15 @@ test.use({
|
||||
},
|
||||
})
|
||||
|
||||
test('should not allow user to edit settings', async ({ page }) => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const settingsLoaded = page.waitForResponse((response) =>
|
||||
response.url().endsWith('/api/ui_settings/')
|
||||
)
|
||||
await page.goto('/dashboard')
|
||||
expect((await settingsLoaded).status()).toBe(200)
|
||||
})
|
||||
|
||||
test('should not allow user to edit settings', async ({ page }) => {
|
||||
await expect(page.getByRole('link', { name: 'Settings' })).not.toBeAttached()
|
||||
await page.goto('/settings')
|
||||
await expect(page.locator('body')).toHaveText(
|
||||
@@ -16,7 +23,6 @@ test('should not allow user to edit settings', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('should not allow user to view documents', async ({ page }) => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(
|
||||
page.locator('nav').getByRole('link', { name: 'Documents' })
|
||||
).not.toBeAttached()
|
||||
@@ -31,7 +37,6 @@ test('should not allow user to view documents', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('should not allow user to view correspondents', async ({ page }) => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'Attributes' })
|
||||
).not.toBeAttached()
|
||||
@@ -42,7 +47,6 @@ test('should not allow user to view correspondents', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('should not allow user to view tags', async ({ page }) => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'Attributes' })
|
||||
).not.toBeAttached()
|
||||
@@ -53,7 +57,6 @@ test('should not allow user to view tags', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('should not allow user to view document types', async ({ page }) => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'Attributes' })
|
||||
).not.toBeAttached()
|
||||
@@ -64,7 +67,6 @@ test('should not allow user to view document types', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('should not allow user to view storage paths', async ({ page }) => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'Attributes' })
|
||||
).not.toBeAttached()
|
||||
@@ -75,7 +77,6 @@ test('should not allow user to view storage paths', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('should not allow user to view logs', async ({ page }) => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(page.getByRole('link', { name: 'Logs' })).not.toBeAttached()
|
||||
await page.goto('/logs')
|
||||
await expect(page.locator('body')).toHaveText(
|
||||
@@ -84,7 +85,6 @@ test('should not allow user to view logs', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('should not allow user to view tasks', async ({ page }) => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(page.getByRole('link', { name: 'Tasks' })).not.toBeAttached()
|
||||
await page.goto('/tasks')
|
||||
await expect(page.locator('body')).toHaveText(
|
||||
|
||||
+28
-28
@@ -1402,7 +1402,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">239,240</context>
|
||||
<context context-type="linenumber">240,241</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/data/document.ts</context>
|
||||
@@ -1733,7 +1733,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">248,249</context>
|
||||
<context context-type="linenumber">249,250</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/filter-editor/filter-editor.component.html</context>
|
||||
@@ -1768,7 +1768,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">257,258</context>
|
||||
<context context-type="linenumber">258,259</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/filter-editor/filter-editor.component.html</context>
|
||||
@@ -1811,7 +1811,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">221,222</context>
|
||||
<context context-type="linenumber">222,223</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/filter-editor/filter-editor.component.html</context>
|
||||
@@ -2289,7 +2289,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">266,267</context>
|
||||
<context context-type="linenumber">267,268</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/manage/share-links/share-link-bundle-list/share-link-bundle-list.component.html</context>
|
||||
@@ -4115,7 +4115,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">388</context>
|
||||
<context context-type="linenumber">391</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="7515883357904500238" datatype="html">
|
||||
@@ -4389,7 +4389,7 @@
|
||||
<source>Create new field</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-dropdown/custom-fields-dropdown.component.html</context>
|
||||
<context context-type="linenumber">20</context>
|
||||
<context context-type="linenumber">19</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="6973528734330066202" datatype="html">
|
||||
@@ -4786,7 +4786,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">275,276</context>
|
||||
<context context-type="linenumber">276,277</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/data/document.ts</context>
|
||||
@@ -6604,7 +6604,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">218,219</context>
|
||||
<context context-type="linenumber">219,220</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/filter-editor/filter-editor.component.ts</context>
|
||||
@@ -8410,7 +8410,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">320</context>
|
||||
<context context-type="linenumber">321</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="78870852467682010" datatype="html">
|
||||
@@ -8425,7 +8425,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">360</context>
|
||||
<context context-type="linenumber">363</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="157572966557284263" datatype="html">
|
||||
@@ -8440,7 +8440,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">367</context>
|
||||
<context context-type="linenumber">370</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="883965278435032344" datatype="html">
|
||||
@@ -8458,7 +8458,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">388</context>
|
||||
<context context-type="linenumber">391</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="872092479747931526" datatype="html">
|
||||
@@ -9919,7 +9919,7 @@
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">336</context>
|
||||
<context context-type="linenumber">339</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="106713086593101376" datatype="html">
|
||||
@@ -10234,21 +10234,21 @@
|
||||
<source>Sort by title</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">213</context>
|
||||
<context context-type="linenumber">214</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="6232673011753681091" datatype="html">
|
||||
<source>Sort by owner</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">226</context>
|
||||
<context context-type="linenumber">227</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="3715596725146409911" datatype="html">
|
||||
<source>Owner</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">230,231</context>
|
||||
<context context-type="linenumber">231,232</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/data/document.ts</context>
|
||||
@@ -10263,49 +10263,49 @@
|
||||
<source>Sort by notes</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">235</context>
|
||||
<context context-type="linenumber">236</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="5499001829734502606" datatype="html">
|
||||
<source>Sort by document type</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">244</context>
|
||||
<context context-type="linenumber">245</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="6213829731736042759" datatype="html">
|
||||
<source>Sort by storage path</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">253</context>
|
||||
<context context-type="linenumber">254</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="3406167410329973166" datatype="html">
|
||||
<source>Sort by created date</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">262</context>
|
||||
<context context-type="linenumber">263</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="3769035778779263084" datatype="html">
|
||||
<source>Sort by added date</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">271</context>
|
||||
<context context-type="linenumber">272</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="4874754501044009042" datatype="html">
|
||||
<source>Sort by number of pages</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">280</context>
|
||||
<context context-type="linenumber">281</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="3817498941817715969" datatype="html">
|
||||
<source>Pages</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">284,285</context>
|
||||
<context context-type="linenumber">285,286</context>
|
||||
</context-group>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/data/document.ts</context>
|
||||
@@ -10324,28 +10324,28 @@
|
||||
<source> Shared </source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">288</context>
|
||||
<context context-type="linenumber">289</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="5083658411133224968" datatype="html">
|
||||
<source>Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">294,295</context>
|
||||
<context context-type="linenumber">295,296</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
<context context-type="linenumber">327</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
<context context-type="linenumber">335</context>
|
||||
</context-group>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "paperless-ngx-ui",
|
||||
"version": "3.4.0",
|
||||
"version": "3.4.1",
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
"ng": "ng",
|
||||
|
||||
+347
@@ -0,0 +1,347 @@
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="advanced-search-dialog-title" i18n>
|
||||
Advanced search
|
||||
</h4>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
aria-label="Close"
|
||||
i18n-aria-label
|
||||
(click)="cancel()"
|
||||
></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@if (unreadable) {
|
||||
<div class="alert alert-warning d-flex flex-wrap gap-2 align-items-center">
|
||||
<div class="flex-grow-1">
|
||||
<span i18n
|
||||
>The current query uses syntax this editor can't show. It still works
|
||||
as typed.</span
|
||||
>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-outline-secondary"
|
||||
(click)="startOver()"
|
||||
i18n
|
||||
>
|
||||
Start a new query
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
groupTemplate;
|
||||
context: { group: root, parent: null, depth: 0 }
|
||||
"
|
||||
></ng-container>
|
||||
|
||||
<div class="mt-4">
|
||||
<label
|
||||
class="form-label small text-muted"
|
||||
for="advanced-search-preview"
|
||||
i18n
|
||||
>Query</label
|
||||
>
|
||||
<pre
|
||||
id="advanced-search-preview"
|
||||
class="query-preview mb-0 p-2 rounded border"
|
||||
>@if (generatedQuery) {{{ generatedQuery }}} @else {<span class="text-muted fst-italic" i18n>Nothing to search for yet</span>}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-secondary"
|
||||
(click)="cancel()"
|
||||
i18n
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
(click)="apply()"
|
||||
[disabled]="!generatedQuery"
|
||||
i18n
|
||||
>
|
||||
Apply
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<ng-template
|
||||
#groupTemplate
|
||||
let-group="group"
|
||||
let-parent="parent"
|
||||
let-depth="depth"
|
||||
>
|
||||
<div class="d-flex w-100 gap-2">
|
||||
<div class="d-flex flex-grow-1 flex-column">
|
||||
<div class="d-flex align-items-center flex-wrap">
|
||||
<div
|
||||
class="btn-group btn-group-xs"
|
||||
role="group"
|
||||
aria-label="Match"
|
||||
i18n-aria-label
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
class="btn-check"
|
||||
[(ngModel)]="group.operator"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[value]="LogicalOperator.Or"
|
||||
id="advancedSearchAny_{{ idFor(group) }}"
|
||||
name="advancedSearchAny_{{ idFor(group) }}"
|
||||
/>
|
||||
<label
|
||||
class="btn btn-outline-primary"
|
||||
for="advancedSearchAny_{{ idFor(group) }}"
|
||||
i18n
|
||||
>Any</label
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
class="btn-check"
|
||||
[(ngModel)]="group.operator"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[value]="LogicalOperator.And"
|
||||
id="advancedSearchAll_{{ idFor(group) }}"
|
||||
name="advancedSearchAll_{{ idFor(group) }}"
|
||||
/>
|
||||
<label
|
||||
class="btn btn-outline-primary"
|
||||
for="advancedSearchAll_{{ idFor(group) }}"
|
||||
i18n
|
||||
>All</label
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
class="btn-check"
|
||||
[(ngModel)]="group.operator"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[value]="LogicalOperator.Not"
|
||||
id="advancedSearchNot_{{ idFor(group) }}"
|
||||
name="advancedSearchNot_{{ idFor(group) }}"
|
||||
/>
|
||||
<label
|
||||
class="btn btn-outline-secondary"
|
||||
for="advancedSearchNot_{{ idFor(group) }}"
|
||||
i18n
|
||||
>Not</label
|
||||
>
|
||||
</div>
|
||||
<span class="small text-muted ms-2">
|
||||
@switch (group.operator) {
|
||||
@case (LogicalOperator.And) {
|
||||
<ng-container i18n>match all of these</ng-container>
|
||||
}
|
||||
@case (LogicalOperator.Or) {
|
||||
<ng-container i18n>match any of these</ng-container>
|
||||
}
|
||||
@case (LogicalOperator.Not) {
|
||||
<ng-container i18n>match none of these</ng-container>
|
||||
}
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
<div class="list-group list-group-flush">
|
||||
@for (element of group.children; track element) {
|
||||
<div class="list-group-item px-0 d-flex flex-nowrap">
|
||||
@if (element.type === ElementType.Group) {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
groupTemplate;
|
||||
context: { group: element, parent: group, depth: depth + 1 }
|
||||
"
|
||||
></ng-container>
|
||||
} @else {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
atomTemplate;
|
||||
context: { atom: element, parent: group }
|
||||
"
|
||||
></ng-container>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="btn-group-vertical align-self-start ms-2 ps-2 border-start"
|
||||
role="group"
|
||||
aria-label="Group actions"
|
||||
i18n-aria-label
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-outline-secondary text-primary"
|
||||
title="Add condition"
|
||||
i18n-title
|
||||
(click)="addAtom(group)"
|
||||
[disabled]="group.children.length >= maxAtoms"
|
||||
>
|
||||
<i-bs name="node-plus"></i-bs>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-outline-secondary text-primary"
|
||||
title="Add group"
|
||||
i18n-title
|
||||
(click)="addGroup(group)"
|
||||
[disabled]="depth >= maxDepth"
|
||||
>
|
||||
<i-bs name="braces"></i-bs>
|
||||
</button>
|
||||
@if (parent) {
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-outline-secondary text-danger"
|
||||
aria-label="Remove group"
|
||||
i18n-aria-label
|
||||
(click)="remove(parent, group)"
|
||||
>
|
||||
<i-bs name="x-circle"></i-bs>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #atomTemplate let-atom="atom" let-parent="parent">
|
||||
<div class="d-flex align-items-center gap-1 w-100">
|
||||
<div class="input-group input-group-sm flex-wrap">
|
||||
<select
|
||||
class="form-select flex-grow-0 w-auto"
|
||||
[(ngModel)]="atom.field"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
(ngModelChange)="onFieldChange(atom)"
|
||||
aria-label="Field"
|
||||
i18n-aria-label
|
||||
>
|
||||
@for (fieldGroup of fieldGroups; track fieldGroup.label) {
|
||||
<optgroup [label]="fieldGroup.label">
|
||||
@for (field of fieldGroup.fields; track field) {
|
||||
<option [ngValue]="field">{{ fieldLabels[field] }}</option>
|
||||
}
|
||||
</optgroup>
|
||||
}
|
||||
</select>
|
||||
<select
|
||||
class="form-select flex-grow-0 w-auto"
|
||||
[(ngModel)]="atom.operator"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
(ngModelChange)="onOperatorChange(atom)"
|
||||
aria-label="Condition"
|
||||
i18n-aria-label
|
||||
>
|
||||
@for (operator of operatorsFor(atom); track operator) {
|
||||
<option [ngValue]="operator">
|
||||
{{ operatorLabel(atom, operator) }}
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
|
||||
@switch (atom.operator) {
|
||||
@case (Operator.DateKeyword) {
|
||||
<select
|
||||
class="form-select"
|
||||
[(ngModel)]="atom.value"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
aria-label="Period"
|
||||
i18n-aria-label
|
||||
>
|
||||
<option [ngValue]="''" disabled i18n>Choose a period</option>
|
||||
@for (keyword of dateKeywords; track keyword) {
|
||||
<option [ngValue]="keyword">
|
||||
{{ dateKeywordLabels[keyword] }}
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
}
|
||||
@case (Operator.WithinLast) {
|
||||
<input
|
||||
class="form-control amount"
|
||||
type="number"
|
||||
min="1"
|
||||
[(ngModel)]="atom.value"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
aria-label="Amount"
|
||||
i18n-aria-label
|
||||
/>
|
||||
<select
|
||||
class="form-select"
|
||||
[(ngModel)]="atom.unit"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
aria-label="Unit"
|
||||
i18n-aria-label
|
||||
>
|
||||
@for (unit of dateUnits; track unit) {
|
||||
<option [ngValue]="unit">{{ dateUnitLabels[unit] }}</option>
|
||||
}
|
||||
</select>
|
||||
}
|
||||
@case (Operator.Between) {
|
||||
<input
|
||||
class="form-control"
|
||||
[type]="kindOf(atom) === FieldKind.Date ? 'date' : 'number'"
|
||||
[(ngModel)]="atom.value"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
aria-label="From"
|
||||
i18n-aria-label
|
||||
/>
|
||||
<span class="input-group-text" i18n>and</span>
|
||||
<input
|
||||
class="form-control"
|
||||
[type]="kindOf(atom) === FieldKind.Date ? 'date' : 'number'"
|
||||
[(ngModel)]="atom.valueTo"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
aria-label="To"
|
||||
i18n-aria-label
|
||||
/>
|
||||
}
|
||||
@default {
|
||||
@if (kindOf(atom) === FieldKind.Date) {
|
||||
<input
|
||||
class="form-control"
|
||||
type="date"
|
||||
[(ngModel)]="atom.value"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
aria-label="Date"
|
||||
i18n-aria-label
|
||||
/>
|
||||
} @else if (kindOf(atom) === FieldKind.Number) {
|
||||
<input
|
||||
class="form-control"
|
||||
type="number"
|
||||
min="0"
|
||||
[(ngModel)]="atom.value"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
aria-label="Number"
|
||||
i18n-aria-label
|
||||
/>
|
||||
} @else {
|
||||
<input
|
||||
class="form-control"
|
||||
type="text"
|
||||
[(ngModel)]="atom.value"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[placeholder]="placeholderFor(atom)"
|
||||
aria-label="Value"
|
||||
i18n-aria-label
|
||||
/>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-link btn-sm text-danger px-1"
|
||||
type="button"
|
||||
(click)="remove(parent, atom)"
|
||||
aria-label="Remove condition"
|
||||
i18n-aria-label
|
||||
>
|
||||
<i-bs name="x-circle"></i-bs>
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
.query-preview {
|
||||
font-size: 0.8125rem;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
background-color: var(--pngx-bg-darker);
|
||||
border-color: var(--bs-border-color) !important;
|
||||
}
|
||||
|
||||
.input-group .amount {
|
||||
flex: 0 1 5rem;
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { allIcons, NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
|
||||
import {
|
||||
AdvancedSearchDateUnit,
|
||||
AdvancedSearchField,
|
||||
AdvancedSearchLogicalOperator,
|
||||
AdvancedSearchOperator,
|
||||
AdvancedSearchQueryAtom,
|
||||
AdvancedSearchQueryElementType,
|
||||
AdvancedSearchQueryGroup,
|
||||
} from 'src/app/data/advanced-search-query'
|
||||
import { AdvancedSearchDialogComponent } from './advanced-search-dialog.component'
|
||||
|
||||
describe('AdvancedSearchDialogComponent', () => {
|
||||
let component: AdvancedSearchDialogComponent
|
||||
let fixture: ComponentFixture<AdvancedSearchDialogComponent>
|
||||
let activeModal: NgbActiveModal
|
||||
|
||||
const firstAtom = (): AdvancedSearchQueryAtom =>
|
||||
component.root.children[0] as AdvancedSearchQueryAtom
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
AdvancedSearchDialogComponent,
|
||||
NgxBootstrapIconsModule.pick(allIcons),
|
||||
],
|
||||
providers: [NgbActiveModal],
|
||||
}).compileComponents()
|
||||
|
||||
fixture = TestBed.createComponent(AdvancedSearchDialogComponent)
|
||||
activeModal = TestBed.inject(NgbActiveModal)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should start with one empty condition and nothing to search for', () => {
|
||||
expect(component.root.children).toHaveLength(1)
|
||||
expect(component.generatedQuery).toBe('')
|
||||
expect(component.unreadable).toBeFalsy()
|
||||
})
|
||||
|
||||
it('should show an existing query as conditions', () => {
|
||||
component.query = 'title:invoice AND NOT tag:paid'
|
||||
expect(component.unreadable).toBeFalsy()
|
||||
expect(component.root.children).toHaveLength(2)
|
||||
expect(component.generatedQuery).toBe('title:invoice AND NOT tag:paid')
|
||||
})
|
||||
|
||||
it('should flag a query it cannot show and start empty', () => {
|
||||
component.query = 'title:invoice^2'
|
||||
expect(component.unreadable).toBeTruthy()
|
||||
expect(component.generatedQuery).toBe('')
|
||||
})
|
||||
|
||||
it('should clear the warning when starting a new query', () => {
|
||||
component.query = 'title:invoice^2'
|
||||
component.startOver()
|
||||
expect(component.unreadable).toBeFalsy()
|
||||
expect(component.root.children).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should treat an empty query as a fresh start', () => {
|
||||
component.query = ' '
|
||||
expect(component.unreadable).toBeFalsy()
|
||||
expect(component.root.children).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should write the query as conditions are filled in', () => {
|
||||
const atom = firstAtom()
|
||||
atom.field = AdvancedSearchField.Title
|
||||
atom.value = 'unpaid invoice'
|
||||
expect(component.generatedQuery).toBe('title:unpaid AND title:invoice')
|
||||
})
|
||||
|
||||
it('should offer the conditions of the chosen field', () => {
|
||||
const atom = firstAtom()
|
||||
atom.field = AdvancedSearchField.Added
|
||||
component.onFieldChange(atom)
|
||||
expect(component.operatorsFor(atom)).toContain(
|
||||
AdvancedSearchOperator.WithinLast
|
||||
)
|
||||
expect(component.operatorsFor(atom)).not.toContain(
|
||||
AdvancedSearchOperator.Phrase
|
||||
)
|
||||
})
|
||||
|
||||
it('should keep a condition the new field still offers', () => {
|
||||
const atom = firstAtom()
|
||||
atom.operator = AdvancedSearchOperator.Phrase
|
||||
atom.field = AdvancedSearchField.Correspondent
|
||||
component.onFieldChange(atom)
|
||||
expect(atom.operator).toBe(AdvancedSearchOperator.Phrase)
|
||||
})
|
||||
|
||||
it('should replace a condition the new field does not offer, and clear the value', () => {
|
||||
const atom = firstAtom()
|
||||
atom.operator = AdvancedSearchOperator.Phrase
|
||||
atom.value = 'invoice'
|
||||
atom.field = AdvancedSearchField.ASN
|
||||
component.onFieldChange(atom)
|
||||
expect(atom.operator).toBe(AdvancedSearchOperator.Equals)
|
||||
expect(atom.value).toBe('')
|
||||
})
|
||||
|
||||
it('should give a within-the-last condition a unit to start from', () => {
|
||||
const atom = firstAtom()
|
||||
atom.field = AdvancedSearchField.Added
|
||||
atom.operator = AdvancedSearchOperator.WithinLast
|
||||
component.onOperatorChange(atom)
|
||||
expect(atom.unit).toBe(AdvancedSearchDateUnit.Day)
|
||||
atom.value = '3'
|
||||
expect(component.generatedQuery).toBe('added:[-3 days to now]')
|
||||
})
|
||||
|
||||
it('should label date comparisons as dates', () => {
|
||||
const atom = firstAtom()
|
||||
atom.field = AdvancedSearchField.Created
|
||||
expect(
|
||||
component.operatorLabel(atom, AdvancedSearchOperator.AtLeast)
|
||||
).toEqual('is on or after')
|
||||
atom.field = AdvancedSearchField.ASN
|
||||
expect(
|
||||
component.operatorLabel(atom, AdvancedSearchOperator.AtLeast)
|
||||
).toEqual('is at least')
|
||||
})
|
||||
|
||||
it('should add and remove conditions', () => {
|
||||
component.addAtom(component.root)
|
||||
expect(component.root.children).toHaveLength(2)
|
||||
component.remove(component.root, component.root.children[1])
|
||||
expect(component.root.children).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should add a group, which starts as Any', () => {
|
||||
component.addGroup(component.root)
|
||||
const group = component.root.children[1] as AdvancedSearchQueryGroup
|
||||
expect(group.type).toBe(AdvancedSearchQueryElementType.Group)
|
||||
expect(group.operator).toBe(AdvancedSearchLogicalOperator.Or)
|
||||
expect(group.children).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('should give every group its own id, once', () => {
|
||||
component.addGroup(component.root)
|
||||
const group = component.root.children[1] as AdvancedSearchQueryGroup
|
||||
expect(component.idFor(component.root)).not.toEqual(component.idFor(group))
|
||||
expect(component.idFor(group)).toEqual(component.idFor(group))
|
||||
})
|
||||
|
||||
it('should apply the query and close', () => {
|
||||
const emitSpy = jest.spyOn(component.queryApplied, 'emit')
|
||||
const closeSpy = jest.spyOn(activeModal, 'close')
|
||||
const atom = firstAtom()
|
||||
atom.value = 'invoice'
|
||||
component.apply()
|
||||
expect(emitSpy).toHaveBeenCalledWith('content:invoice')
|
||||
expect(closeSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should close without applying on cancel', () => {
|
||||
const emitSpy = jest.spyOn(component.queryApplied, 'emit')
|
||||
const closeSpy = jest.spyOn(activeModal, 'close')
|
||||
component.cancel()
|
||||
expect(emitSpy).not.toHaveBeenCalled()
|
||||
expect(closeSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should show the query it will apply', () => {
|
||||
component.query = 'content:invoice OR content:receipt'
|
||||
fixture.detectChanges()
|
||||
const preview = fixture.nativeElement.querySelector(
|
||||
'#advanced-search-preview'
|
||||
)
|
||||
expect(preview.textContent).toContain('content:invoice OR content:receipt')
|
||||
})
|
||||
|
||||
it('should not offer to apply an empty query', () => {
|
||||
fixture.detectChanges()
|
||||
const apply = Array.from(
|
||||
fixture.nativeElement.querySelectorAll('.modal-footer button')
|
||||
).pop() as HTMLButtonElement
|
||||
expect(apply.disabled).toBeTruthy()
|
||||
})
|
||||
})
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
import { NgTemplateOutlet } from '@angular/common'
|
||||
import { Component, EventEmitter, inject, Input, Output } from '@angular/core'
|
||||
import { FormsModule } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
|
||||
import {
|
||||
ADVANCED_SEARCH_DATE_KEYWORD_LABELS,
|
||||
ADVANCED_SEARCH_DATE_KEYWORDS,
|
||||
ADVANCED_SEARCH_DATE_OPERATOR_LABELS,
|
||||
ADVANCED_SEARCH_DATE_UNIT_LABELS,
|
||||
ADVANCED_SEARCH_FIELD_GROUPS,
|
||||
ADVANCED_SEARCH_FIELD_KINDS,
|
||||
ADVANCED_SEARCH_FIELD_LABELS,
|
||||
ADVANCED_SEARCH_MAX_ATOMS,
|
||||
ADVANCED_SEARCH_MAX_DEPTH,
|
||||
ADVANCED_SEARCH_OPERATOR_LABELS,
|
||||
ADVANCED_SEARCH_OPERATORS_BY_KIND,
|
||||
AdvancedSearchDateUnit,
|
||||
AdvancedSearchField,
|
||||
AdvancedSearchFieldKind,
|
||||
AdvancedSearchLogicalOperator,
|
||||
AdvancedSearchOperator,
|
||||
AdvancedSearchQueryAtom,
|
||||
AdvancedSearchQueryElement,
|
||||
AdvancedSearchQueryElementType,
|
||||
AdvancedSearchQueryGroup,
|
||||
} from 'src/app/data/advanced-search-query'
|
||||
import {
|
||||
parseAdvancedSearchQuery,
|
||||
serializeAdvancedSearchQuery,
|
||||
} from 'src/app/utils/advanced-search-query'
|
||||
import { LoadingComponentWithPermissions } from '../../loading-component/loading.component'
|
||||
|
||||
@Component({
|
||||
selector: 'pngx-advanced-search-dialog',
|
||||
templateUrl: './advanced-search-dialog.component.html',
|
||||
styleUrl: './advanced-search-dialog.component.scss',
|
||||
imports: [FormsModule, NgTemplateOutlet, NgxBootstrapIconsModule],
|
||||
})
|
||||
export class AdvancedSearchDialogComponent extends LoadingComponentWithPermissions {
|
||||
private activeModal = inject(NgbActiveModal)
|
||||
|
||||
public readonly ElementType = AdvancedSearchQueryElementType
|
||||
public readonly LogicalOperator = AdvancedSearchLogicalOperator
|
||||
public readonly Operator = AdvancedSearchOperator
|
||||
public readonly FieldKind = AdvancedSearchFieldKind
|
||||
public readonly fieldGroups = ADVANCED_SEARCH_FIELD_GROUPS
|
||||
public readonly fieldLabels = ADVANCED_SEARCH_FIELD_LABELS
|
||||
public readonly dateKeywords = ADVANCED_SEARCH_DATE_KEYWORDS
|
||||
public readonly dateKeywordLabels = ADVANCED_SEARCH_DATE_KEYWORD_LABELS
|
||||
public readonly dateUnits = Object.values(AdvancedSearchDateUnit)
|
||||
public readonly dateUnitLabels = ADVANCED_SEARCH_DATE_UNIT_LABELS
|
||||
public readonly maxDepth = ADVANCED_SEARCH_MAX_DEPTH
|
||||
public readonly maxAtoms = ADVANCED_SEARCH_MAX_ATOMS
|
||||
|
||||
@Output()
|
||||
public queryApplied = new EventEmitter<string>()
|
||||
|
||||
public root: AdvancedSearchQueryGroup = this.emptyRoot()
|
||||
|
||||
// True when the query in the search box uses syntax the editor cannot show
|
||||
public unreadable: boolean = false
|
||||
|
||||
private _query: string = ''
|
||||
|
||||
@Input()
|
||||
set query(query: string) {
|
||||
this._query = query ?? ''
|
||||
const parsed = parseAdvancedSearchQuery(this._query)
|
||||
this.unreadable = !!this._query.trim() && !parsed
|
||||
this.root = parsed ?? this.emptyRoot()
|
||||
}
|
||||
|
||||
get query(): string {
|
||||
return this._query
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.loading.set(false)
|
||||
}
|
||||
|
||||
// Stable ids for the radio groups, without putting them in the query model
|
||||
private ids = new WeakMap<object, number>()
|
||||
private nextId = 0
|
||||
|
||||
public idFor(element: AdvancedSearchQueryElement): number {
|
||||
if (!this.ids.has(element)) {
|
||||
this.ids.set(element, this.nextId++)
|
||||
}
|
||||
return this.ids.get(element)
|
||||
}
|
||||
|
||||
private emptyRoot(): AdvancedSearchQueryGroup {
|
||||
return {
|
||||
type: AdvancedSearchQueryElementType.Group,
|
||||
operator: AdvancedSearchLogicalOperator.And,
|
||||
children: [this.newAtom()],
|
||||
}
|
||||
}
|
||||
|
||||
private newAtom(): AdvancedSearchQueryAtom {
|
||||
return {
|
||||
type: AdvancedSearchQueryElementType.Atom,
|
||||
field: AdvancedSearchField.Content,
|
||||
operator: AdvancedSearchOperator.AllWords,
|
||||
value: '',
|
||||
}
|
||||
}
|
||||
|
||||
public get generatedQuery(): string {
|
||||
return serializeAdvancedSearchQuery(this.root)
|
||||
}
|
||||
|
||||
public kindOf(atom: AdvancedSearchQueryAtom): AdvancedSearchFieldKind {
|
||||
return ADVANCED_SEARCH_FIELD_KINDS[atom.field]
|
||||
}
|
||||
|
||||
public operatorsFor(atom: AdvancedSearchQueryAtom): AdvancedSearchOperator[] {
|
||||
return ADVANCED_SEARCH_OPERATORS_BY_KIND[this.kindOf(atom)]
|
||||
}
|
||||
|
||||
public operatorLabel(
|
||||
atom: AdvancedSearchQueryAtom,
|
||||
operator: AdvancedSearchOperator
|
||||
): string {
|
||||
return this.kindOf(atom) === AdvancedSearchFieldKind.Date
|
||||
? (ADVANCED_SEARCH_DATE_OPERATOR_LABELS[operator] ??
|
||||
ADVANCED_SEARCH_OPERATOR_LABELS[operator])
|
||||
: ADVANCED_SEARCH_OPERATOR_LABELS[operator]
|
||||
}
|
||||
|
||||
public placeholderFor(atom: AdvancedSearchQueryAtom): string {
|
||||
switch (atom.operator) {
|
||||
case AdvancedSearchOperator.Phrase:
|
||||
return $localize`phrase`
|
||||
case AdvancedSearchOperator.StartsWith:
|
||||
return $localize`beginning of a word`
|
||||
default:
|
||||
return $localize`words`
|
||||
}
|
||||
}
|
||||
|
||||
public onFieldChange(atom: AdvancedSearchQueryAtom) {
|
||||
// Keep the condition only if the new field still offers it
|
||||
if (!this.operatorsFor(atom).includes(atom.operator)) {
|
||||
atom.operator = this.operatorsFor(atom)[0]
|
||||
}
|
||||
this.clearValues(atom)
|
||||
}
|
||||
|
||||
public onOperatorChange(atom: AdvancedSearchQueryAtom) {
|
||||
this.clearValues(atom)
|
||||
}
|
||||
|
||||
private clearValues(atom: AdvancedSearchQueryAtom) {
|
||||
atom.value = ''
|
||||
atom.valueTo = undefined
|
||||
atom.unit =
|
||||
atom.operator === AdvancedSearchOperator.WithinLast
|
||||
? AdvancedSearchDateUnit.Day
|
||||
: undefined
|
||||
}
|
||||
|
||||
public addAtom(group: AdvancedSearchQueryGroup) {
|
||||
group.children.push(this.newAtom())
|
||||
}
|
||||
|
||||
public addGroup(group: AdvancedSearchQueryGroup) {
|
||||
group.children.push({
|
||||
type: AdvancedSearchQueryElementType.Group,
|
||||
operator: AdvancedSearchLogicalOperator.Or,
|
||||
children: [this.newAtom()],
|
||||
})
|
||||
}
|
||||
|
||||
public remove(
|
||||
parent: AdvancedSearchQueryGroup,
|
||||
element: AdvancedSearchQueryElement
|
||||
) {
|
||||
parent.children = parent.children.filter((child) => child !== element)
|
||||
}
|
||||
|
||||
public startOver() {
|
||||
this.unreadable = false
|
||||
this.root = this.emptyRoot()
|
||||
}
|
||||
|
||||
public apply() {
|
||||
this.queryApplied.emit(this.generatedQuery)
|
||||
this.activeModal.close()
|
||||
}
|
||||
|
||||
public cancel() {
|
||||
this.activeModal.close()
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -11,14 +11,12 @@
|
||||
</div>
|
||||
@for (field of filteredFields; track field.id) {
|
||||
<button type="button" class="list-group-item list-group-item-action bg-light" (click)="addField(field)" #button>
|
||||
<small class="d-flex">{{field.name}} <small class="ms-auto text-muted">{{getDataTypeLabel(field.data_type)}}</small></small>
|
||||
<div class="d-flex">{{field.name}} <small class="ms-auto text-muted">{{getDataTypeLabel(field.data_type)}}</small></div>
|
||||
</button>
|
||||
}
|
||||
@if (!filterText?.length || filteredFields.length === 0) {
|
||||
<button type="button" class="list-group-item list-group-item-action bg-light" (click)="createField(filterText)" [disabled]="!canCreateFields" #button>
|
||||
<small>
|
||||
<i-bs width=".9em" height=".9em" name="asterisk" class="me-1"></i-bs><ng-container i18n>Create new field</ng-container>
|
||||
</small>
|
||||
<i-bs width=".9em" height=".9em" name="asterisk" class="me-1"></i-bs><ng-container i18n>Create new field</ng-container>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@
|
||||
<a class="btn btn-sm btn-outline-secondary" (click)="clickMoreLike.emit()">
|
||||
<i-bs name="diagram-3" class="me-1"></i-bs><span class="d-none d-md-inline" i18n>More like this</span>
|
||||
</a>
|
||||
<a routerLink="/documents/{{document().id}}" class="btn btn-sm btn-outline-secondary" *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Document }">
|
||||
<a routerLink="/documents/{{document().id}}" class="btn btn-sm btn-outline-secondary">
|
||||
<i-bs name="file-earmark-richtext" class="me-1"></i-bs><span class="d-none d-md-inline" i18n>Open</span>
|
||||
</a>
|
||||
<pngx-preview-popup [document]="document()" #popupPreview>
|
||||
|
||||
-2
@@ -10,7 +10,6 @@ import {
|
||||
NgbTooltipModule,
|
||||
} from '@ng-bootstrap/ng-bootstrap'
|
||||
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
|
||||
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
||||
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
|
||||
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
|
||||
import { IsNumberPipe } from 'src/app/pipes/is-number.pipe'
|
||||
@@ -52,7 +51,6 @@ describe('DocumentCardLargeComponent', () => {
|
||||
DocumentCardLargeComponent,
|
||||
DocumentTitlePipe,
|
||||
CustomDatePipe,
|
||||
IfPermissionsDirective,
|
||||
SafeUrlPipe,
|
||||
IsNumberPipe,
|
||||
PreviewPopupComponent,
|
||||
|
||||
-2
@@ -20,7 +20,6 @@ import {
|
||||
Document,
|
||||
} from 'src/app/data/document'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
||||
import { CorrespondentNamePipe } from 'src/app/pipes/correspondent-name.pipe'
|
||||
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
|
||||
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
|
||||
@@ -51,7 +50,6 @@ import { LoadingComponentWithPermissions } from '../../loading-component/loading
|
||||
CorrespondentNamePipe,
|
||||
DocumentTypeNamePipe,
|
||||
StoragePathNamePipe,
|
||||
IfPermissionsDirective,
|
||||
CustomDatePipe,
|
||||
RouterModule,
|
||||
NgbTooltipModule,
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="btn-group w-100">
|
||||
@if (document()) {
|
||||
<a routerLink="/documents/{{document().id}}" class="btn btn-sm btn-outline-secondary" title="Open" i18n-title *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Document }" i18n-title>
|
||||
<a routerLink="/documents/{{document().id}}" class="btn btn-sm btn-outline-secondary" title="Open" i18n-title>
|
||||
<i-bs name="file-earmark-richtext"></i-bs>
|
||||
</a>
|
||||
<pngx-preview-popup [document]="document()" #popupPreview>
|
||||
|
||||
-2
@@ -20,7 +20,6 @@ import {
|
||||
Document,
|
||||
} from 'src/app/data/document'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
||||
import { CorrespondentNamePipe } from 'src/app/pipes/correspondent-name.pipe'
|
||||
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
|
||||
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
|
||||
@@ -51,7 +50,6 @@ import { LoadingComponentWithPermissions } from '../../loading-component/loading
|
||||
CorrespondentNamePipe,
|
||||
DocumentTypeNamePipe,
|
||||
StoragePathNamePipe,
|
||||
IfPermissionsDirective,
|
||||
CustomDatePipe,
|
||||
RouterModule,
|
||||
NgbTooltipModule,
|
||||
|
||||
@@ -208,7 +208,8 @@
|
||||
i18n>Correspondent</th>
|
||||
}
|
||||
@if (activeDisplayFields.includes(DisplayField.TITLE)) {
|
||||
<th class="cursor-pointer ps-5"
|
||||
<th style="width: 2rem"><!-- Preview --></th>
|
||||
<th class="cursor-pointer"
|
||||
pngxSortable="title"
|
||||
title="Sort by title" i18n-title
|
||||
[currentSortField]="list.sortField"
|
||||
@@ -321,15 +322,17 @@
|
||||
}
|
||||
</td>
|
||||
}
|
||||
@if (activeDisplayFields.includes(DisplayField.TITLE)) {
|
||||
<td class="pe-0 text-end align-baseline" (mouseleave)="popupPreview.close()">
|
||||
<pngx-preview-popup [document]="d" linkClasses="btn btn-sm btn-link text-secondary px-1" linkTitle="Preview document" (click)="$event.stopPropagation()" i18n-linkTitle #popupPreview>
|
||||
<i-bs name="eye"></i-bs>
|
||||
</pngx-preview-popup>
|
||||
</td>
|
||||
}
|
||||
@if (activeDisplayFields.includes(DisplayField.TITLE) || activeDisplayFields.includes(DisplayField.TAGS)) {
|
||||
<td width="30%" class="position-relative" [class.ps-5]="activeDisplayFields.includes(DisplayField.TITLE)">
|
||||
<td width="30%" class="align-baseline">
|
||||
@if (activeDisplayFields.includes(DisplayField.TITLE)) {
|
||||
<div class="d-inline-block" (mouseleave)="popupPreview.close()">
|
||||
<pngx-preview-popup class="position-absolute start-0" [document]="d" linkClasses="btn btn-sm btn-link text-secondary" linkTitle="Preview document" (click)="$event.stopPropagation()" i18n-linkTitle #popupPreview>
|
||||
<i-bs name="eye"></i-bs>
|
||||
</pngx-preview-popup>
|
||||
<a routerLink="/documents/{{d.id}}" title="Edit document" i18n-title style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>
|
||||
</div>
|
||||
<a routerLink="/documents/{{d.id}}" title="Edit document" i18n-title style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>
|
||||
}
|
||||
@if (activeDisplayFields.includes(DisplayField.TAGS)) {
|
||||
@for (tagID of d.tags; track tagID) {
|
||||
|
||||
@@ -87,10 +87,6 @@ $paperless-card-breakpoints: (
|
||||
}
|
||||
}
|
||||
|
||||
.table .ps-5 {
|
||||
padding-left: 2.2rem !important;
|
||||
}
|
||||
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
}
|
||||
</select>
|
||||
}
|
||||
@if (advancedSearchEditorAvailable) {
|
||||
<button class="btn btn-sm btn-outline-primary" type="button" (click)="openAdvancedSearchEditor()"
|
||||
title="Edit query" i18n-title [disabled]="disabled">
|
||||
<i-bs name="sliders"></i-bs>
|
||||
</button>
|
||||
}
|
||||
@if (_textFilter) {
|
||||
<button class="btn btn-link btn-sm px-2 position-absolute top-0 end-0 z-10" (click)="resetTextField()" aria-label="Clear search" i18n-aria-label>
|
||||
<i-bs width="1em" height="1em" name="x"></i-bs>
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
NgbDatepickerModule,
|
||||
NgbDropdownItem,
|
||||
NgbDropdownModule,
|
||||
NgbModal,
|
||||
NgbModalRef,
|
||||
NgbTypeaheadModule,
|
||||
} from '@ng-bootstrap/ng-bootstrap'
|
||||
import { NgSelectComponent, NgSelectModule } from '@ng-select/ng-select'
|
||||
@@ -2551,4 +2553,45 @@ describe('FilterEditorComponent', () => {
|
||||
|
||||
expect(component.textFilter).toEqual('help ')
|
||||
})
|
||||
|
||||
it('should open the advanced search editor with the current query and apply the result', () => {
|
||||
const modalService: NgbModal = TestBed.inject(NgbModal)
|
||||
let modal: NgbModalRef
|
||||
modalService.activeInstances.subscribe(
|
||||
(instances) => (modal = instances[0])
|
||||
)
|
||||
component.textFilterTarget = 'fulltext-query'
|
||||
component.updateTextFilter('title:invoice')
|
||||
fixture.detectChanges()
|
||||
|
||||
const editorButton = fixture.debugElement.query(
|
||||
By.css('button[title="Edit query"]')
|
||||
)
|
||||
expect(editorButton).not.toBeNull()
|
||||
editorButton.triggerEventHandler('click')
|
||||
fixture.detectChanges()
|
||||
|
||||
expect(modal.componentInstance.query).toEqual('title:invoice')
|
||||
|
||||
const rulesSpy = jest.spyOn(component.filterRulesChange, 'next')
|
||||
modal.componentInstance.queryApplied.emit('title:invoice AND NOT tag:paid')
|
||||
expect(component.textFilter).toEqual('title:invoice AND NOT tag:paid')
|
||||
expect(documentService.searchQuery).toEqual(
|
||||
'title:invoice AND NOT tag:paid'
|
||||
)
|
||||
expect(rulesSpy).toHaveBeenCalledWith([
|
||||
{
|
||||
rule_type: FILTER_FULLTEXT_QUERY,
|
||||
value: 'title:invoice AND NOT tag:paid',
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('should not offer the advanced search editor for other targets', () => {
|
||||
component.textFilterTarget = 'title-content'
|
||||
fixture.detectChanges()
|
||||
expect(
|
||||
fixture.debugElement.query(By.css('button[title="Edit query"]'))
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -15,12 +15,13 @@ import {
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
|
||||
import {
|
||||
NgbDropdownModule,
|
||||
NgbModal,
|
||||
NgbTypeahead,
|
||||
NgbTypeaheadModule,
|
||||
} from '@ng-bootstrap/ng-bootstrap'
|
||||
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
|
||||
import { TourNgBootstrap } from 'ngx-ui-tour-ng-bootstrap'
|
||||
import { Observable, Subject, from } from 'rxjs'
|
||||
import { first, Observable, Subject, from } from 'rxjs'
|
||||
import {
|
||||
catchError,
|
||||
debounceTime,
|
||||
@@ -121,6 +122,7 @@ import {
|
||||
PermissionsFilterDropdownComponent,
|
||||
PermissionsSelectionModel,
|
||||
} from '../../common/permissions-filter-dropdown/permissions-filter-dropdown.component'
|
||||
import { AdvancedSearchDialogComponent } from '../../common/advanced-search-dialog/advanced-search-dialog.component'
|
||||
import { LoadingComponentWithPermissions } from '../../loading-component/loading.component'
|
||||
|
||||
const TEXT_FILTER_TARGET_TITLE = 'title'
|
||||
@@ -286,6 +288,7 @@ export class FilterEditorComponent
|
||||
permissionsService = inject(PermissionsService)
|
||||
private customFieldService = inject(CustomFieldsService)
|
||||
private searchService = inject(SearchService)
|
||||
private modalService = inject(NgbModal)
|
||||
|
||||
generateFilterName() {
|
||||
if (this.filterRules.length == 1) {
|
||||
@@ -1355,6 +1358,23 @@ export class FilterEditorComponent
|
||||
}
|
||||
}
|
||||
|
||||
get advancedSearchEditorAvailable(): boolean {
|
||||
return this.textFilterTarget === TEXT_FILTER_TARGET_FULLTEXT_QUERY
|
||||
}
|
||||
|
||||
openAdvancedSearchEditor() {
|
||||
const modal = this.modalService.open(AdvancedSearchDialogComponent, {
|
||||
backdrop: 'static',
|
||||
size: 'lg',
|
||||
})
|
||||
modal.componentInstance.query = this._textFilter ?? ''
|
||||
modal.componentInstance.queryApplied
|
||||
.pipe(first())
|
||||
.subscribe((query: string) => {
|
||||
this.updateTextFilter(query)
|
||||
})
|
||||
}
|
||||
|
||||
textFilterKeydown(event: KeyboardEvent) {
|
||||
if (event.key == 'Enter') {
|
||||
if (event.defaultPrevented) {
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
// Fields and forms documented in docs/usage.md > "Document searches"
|
||||
|
||||
export enum AdvancedSearchField {
|
||||
Any = '',
|
||||
Title = 'title',
|
||||
Content = 'content',
|
||||
OriginalFilename = 'original_filename',
|
||||
NoteText = 'notes.note',
|
||||
NoteAuthor = 'notes.user',
|
||||
CustomFieldName = 'custom_fields.name',
|
||||
CustomFieldValue = 'custom_fields.value',
|
||||
Correspondent = 'correspondent',
|
||||
DocumentType = 'document_type',
|
||||
StoragePath = 'storage_path',
|
||||
Tag = 'tag',
|
||||
ASN = 'asn',
|
||||
PageCount = 'page_count',
|
||||
NumNotes = 'num_notes',
|
||||
Created = 'created',
|
||||
Added = 'added',
|
||||
Modified = 'modified',
|
||||
Checksum = 'checksum',
|
||||
}
|
||||
|
||||
export enum AdvancedSearchFieldKind {
|
||||
Text = 'text',
|
||||
Number = 'number',
|
||||
Date = 'date',
|
||||
Checksum = 'checksum',
|
||||
}
|
||||
|
||||
export const ADVANCED_SEARCH_FIELD_KINDS: Record<
|
||||
AdvancedSearchField,
|
||||
AdvancedSearchFieldKind
|
||||
> = {
|
||||
[AdvancedSearchField.Any]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.Title]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.Content]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.OriginalFilename]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.NoteText]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.NoteAuthor]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.CustomFieldName]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.CustomFieldValue]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.Correspondent]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.DocumentType]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.StoragePath]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.Tag]: AdvancedSearchFieldKind.Text,
|
||||
[AdvancedSearchField.ASN]: AdvancedSearchFieldKind.Number,
|
||||
[AdvancedSearchField.PageCount]: AdvancedSearchFieldKind.Number,
|
||||
[AdvancedSearchField.NumNotes]: AdvancedSearchFieldKind.Number,
|
||||
[AdvancedSearchField.Created]: AdvancedSearchFieldKind.Date,
|
||||
[AdvancedSearchField.Added]: AdvancedSearchFieldKind.Date,
|
||||
[AdvancedSearchField.Modified]: AdvancedSearchFieldKind.Date,
|
||||
[AdvancedSearchField.Checksum]: AdvancedSearchFieldKind.Checksum,
|
||||
}
|
||||
|
||||
export enum AdvancedSearchOperator {
|
||||
AllWords = 'all',
|
||||
AnyWord = 'any',
|
||||
Phrase = 'phrase',
|
||||
StartsWith = 'prefix',
|
||||
Equals = 'eq',
|
||||
AtLeast = 'gte',
|
||||
AtMost = 'lte',
|
||||
Between = 'between',
|
||||
DateKeyword = 'keyword',
|
||||
WithinLast = 'within',
|
||||
}
|
||||
|
||||
export const ADVANCED_SEARCH_OPERATORS_BY_KIND: Record<
|
||||
AdvancedSearchFieldKind,
|
||||
AdvancedSearchOperator[]
|
||||
> = {
|
||||
[AdvancedSearchFieldKind.Text]: [
|
||||
AdvancedSearchOperator.AllWords,
|
||||
AdvancedSearchOperator.AnyWord,
|
||||
AdvancedSearchOperator.Phrase,
|
||||
AdvancedSearchOperator.StartsWith,
|
||||
],
|
||||
[AdvancedSearchFieldKind.Number]: [
|
||||
AdvancedSearchOperator.Equals,
|
||||
AdvancedSearchOperator.AtLeast,
|
||||
AdvancedSearchOperator.AtMost,
|
||||
AdvancedSearchOperator.Between,
|
||||
],
|
||||
[AdvancedSearchFieldKind.Date]: [
|
||||
AdvancedSearchOperator.DateKeyword,
|
||||
AdvancedSearchOperator.WithinLast,
|
||||
AdvancedSearchOperator.AtLeast,
|
||||
AdvancedSearchOperator.AtMost,
|
||||
AdvancedSearchOperator.Between,
|
||||
],
|
||||
[AdvancedSearchFieldKind.Checksum]: [AdvancedSearchOperator.StartsWith],
|
||||
}
|
||||
|
||||
export const ADVANCED_SEARCH_DATE_KEYWORDS = [
|
||||
'today',
|
||||
'yesterday',
|
||||
'tomorrow',
|
||||
'previous week',
|
||||
'this month',
|
||||
'previous month',
|
||||
'previous quarter',
|
||||
'this year',
|
||||
'previous year',
|
||||
] as const
|
||||
|
||||
export type AdvancedSearchDateKeyword =
|
||||
(typeof ADVANCED_SEARCH_DATE_KEYWORDS)[number]
|
||||
|
||||
export enum AdvancedSearchDateUnit {
|
||||
Day = 'day',
|
||||
Week = 'week',
|
||||
Month = 'month',
|
||||
Year = 'year',
|
||||
}
|
||||
|
||||
export enum AdvancedSearchLogicalOperator {
|
||||
And = 'AND',
|
||||
Or = 'OR',
|
||||
Not = 'NOT',
|
||||
}
|
||||
|
||||
export enum AdvancedSearchQueryElementType {
|
||||
Atom = 'atom',
|
||||
Group = 'group',
|
||||
}
|
||||
|
||||
export interface AdvancedSearchQueryAtom {
|
||||
type: AdvancedSearchQueryElementType.Atom
|
||||
field: AdvancedSearchField
|
||||
operator: AdvancedSearchOperator
|
||||
value?: string
|
||||
valueTo?: string
|
||||
unit?: AdvancedSearchDateUnit // for WithinLast
|
||||
}
|
||||
|
||||
export interface AdvancedSearchQueryGroup {
|
||||
type: AdvancedSearchQueryElementType.Group
|
||||
operator: AdvancedSearchLogicalOperator
|
||||
children: AdvancedSearchQueryElement[]
|
||||
}
|
||||
|
||||
export type AdvancedSearchQueryElement =
|
||||
AdvancedSearchQueryAtom | AdvancedSearchQueryGroup
|
||||
|
||||
export const ADVANCED_SEARCH_MAX_DEPTH = 2
|
||||
export const ADVANCED_SEARCH_MAX_ATOMS = 10
|
||||
|
||||
export const ADVANCED_SEARCH_FIELD_LABELS: Record<AdvancedSearchField, string> =
|
||||
{
|
||||
[AdvancedSearchField.Any]: $localize`Any field`,
|
||||
[AdvancedSearchField.Title]: $localize`Title`,
|
||||
[AdvancedSearchField.Content]: $localize`Content`,
|
||||
[AdvancedSearchField.OriginalFilename]: $localize`File name`,
|
||||
[AdvancedSearchField.NoteText]: $localize`Note text`,
|
||||
[AdvancedSearchField.NoteAuthor]: $localize`Note author`,
|
||||
[AdvancedSearchField.CustomFieldName]: $localize`Custom field name`,
|
||||
[AdvancedSearchField.CustomFieldValue]: $localize`Custom field value`,
|
||||
[AdvancedSearchField.Correspondent]: $localize`Correspondent name`,
|
||||
[AdvancedSearchField.DocumentType]: $localize`Document type name`,
|
||||
[AdvancedSearchField.StoragePath]: $localize`Storage path name`,
|
||||
[AdvancedSearchField.Tag]: $localize`Tag name`,
|
||||
[AdvancedSearchField.ASN]: $localize`ASN`,
|
||||
[AdvancedSearchField.PageCount]: $localize`Pages`,
|
||||
[AdvancedSearchField.NumNotes]: $localize`Number of notes`,
|
||||
[AdvancedSearchField.Created]: $localize`Created`,
|
||||
[AdvancedSearchField.Added]: $localize`Added`,
|
||||
[AdvancedSearchField.Modified]: $localize`Modified`,
|
||||
[AdvancedSearchField.Checksum]: $localize`Checksum`,
|
||||
}
|
||||
|
||||
export const ADVANCED_SEARCH_FIELD_GROUPS: {
|
||||
label: string
|
||||
fields: AdvancedSearchField[]
|
||||
}[] = [
|
||||
{
|
||||
label: $localize`Text`,
|
||||
fields: [
|
||||
AdvancedSearchField.Any,
|
||||
AdvancedSearchField.Title,
|
||||
AdvancedSearchField.Content,
|
||||
AdvancedSearchField.OriginalFilename,
|
||||
AdvancedSearchField.NoteText,
|
||||
AdvancedSearchField.NoteAuthor,
|
||||
AdvancedSearchField.CustomFieldName,
|
||||
AdvancedSearchField.CustomFieldValue,
|
||||
],
|
||||
},
|
||||
{
|
||||
label: $localize`Names`,
|
||||
fields: [
|
||||
AdvancedSearchField.Correspondent,
|
||||
AdvancedSearchField.DocumentType,
|
||||
AdvancedSearchField.StoragePath,
|
||||
AdvancedSearchField.Tag,
|
||||
],
|
||||
},
|
||||
{
|
||||
label: $localize`Numbers`,
|
||||
fields: [
|
||||
AdvancedSearchField.ASN,
|
||||
AdvancedSearchField.PageCount,
|
||||
AdvancedSearchField.NumNotes,
|
||||
],
|
||||
},
|
||||
{
|
||||
label: $localize`Dates`,
|
||||
fields: [
|
||||
AdvancedSearchField.Created,
|
||||
AdvancedSearchField.Added,
|
||||
AdvancedSearchField.Modified,
|
||||
],
|
||||
},
|
||||
{ label: $localize`Other`, fields: [AdvancedSearchField.Checksum] },
|
||||
]
|
||||
|
||||
export const ADVANCED_SEARCH_OPERATOR_LABELS: Record<
|
||||
AdvancedSearchOperator,
|
||||
string
|
||||
> = {
|
||||
[AdvancedSearchOperator.AllWords]: $localize`contains all words`,
|
||||
[AdvancedSearchOperator.AnyWord]: $localize`contains any word`,
|
||||
[AdvancedSearchOperator.Phrase]: $localize`contains the phrase`,
|
||||
[AdvancedSearchOperator.StartsWith]: $localize`starts with`,
|
||||
[AdvancedSearchOperator.Equals]: $localize`is`,
|
||||
[AdvancedSearchOperator.AtLeast]: $localize`is at least`,
|
||||
[AdvancedSearchOperator.AtMost]: $localize`is at most`,
|
||||
[AdvancedSearchOperator.Between]: $localize`is between`,
|
||||
[AdvancedSearchOperator.DateKeyword]: $localize`is`,
|
||||
[AdvancedSearchOperator.WithinLast]: $localize`is within the last`,
|
||||
}
|
||||
|
||||
// Comparing dates reads differently than comparing counts
|
||||
export const ADVANCED_SEARCH_DATE_OPERATOR_LABELS: Partial<
|
||||
Record<AdvancedSearchOperator, string>
|
||||
> = {
|
||||
[AdvancedSearchOperator.AtLeast]: $localize`is on or after`,
|
||||
[AdvancedSearchOperator.AtMost]: $localize`is on or before`,
|
||||
}
|
||||
|
||||
export const ADVANCED_SEARCH_DATE_KEYWORD_LABELS: Record<string, string> = {
|
||||
today: $localize`today`,
|
||||
yesterday: $localize`yesterday`,
|
||||
tomorrow: $localize`tomorrow`,
|
||||
'previous week': $localize`previous week`,
|
||||
'this month': $localize`this month`,
|
||||
'previous month': $localize`previous month`,
|
||||
'previous quarter': $localize`previous quarter`,
|
||||
'this year': $localize`this year`,
|
||||
'previous year': $localize`previous year`,
|
||||
}
|
||||
|
||||
export const ADVANCED_SEARCH_DATE_UNIT_LABELS: Record<
|
||||
AdvancedSearchDateUnit,
|
||||
string
|
||||
> = {
|
||||
[AdvancedSearchDateUnit.Day]: $localize`days`,
|
||||
[AdvancedSearchDateUnit.Week]: $localize`weeks`,
|
||||
[AdvancedSearchDateUnit.Month]: $localize`months`,
|
||||
[AdvancedSearchDateUnit.Year]: $localize`years`,
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export interface SystemStatus {
|
||||
status: SystemStatusItemStatus
|
||||
error?: string
|
||||
migration_status: {
|
||||
latest_migration: string
|
||||
latest_migration: string | null
|
||||
unapplied_migrations: string[]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,515 @@
|
||||
import {
|
||||
AdvancedSearchDateUnit,
|
||||
AdvancedSearchField,
|
||||
AdvancedSearchLogicalOperator,
|
||||
AdvancedSearchOperator,
|
||||
AdvancedSearchQueryAtom,
|
||||
AdvancedSearchQueryElement,
|
||||
AdvancedSearchQueryElementType,
|
||||
AdvancedSearchQueryGroup,
|
||||
} from '../data/advanced-search-query'
|
||||
import {
|
||||
parseAdvancedSearchQuery,
|
||||
serializeAdvancedSearchQuery,
|
||||
} from './advanced-search-query'
|
||||
|
||||
const atom = (
|
||||
field: AdvancedSearchField,
|
||||
operator: AdvancedSearchOperator,
|
||||
value?: string,
|
||||
extra: Partial<AdvancedSearchQueryAtom> = {}
|
||||
): AdvancedSearchQueryAtom => ({
|
||||
type: AdvancedSearchQueryElementType.Atom,
|
||||
field,
|
||||
operator,
|
||||
value,
|
||||
...extra,
|
||||
})
|
||||
|
||||
const group = (
|
||||
operator: AdvancedSearchLogicalOperator,
|
||||
...children: AdvancedSearchQueryElement[]
|
||||
): AdvancedSearchQueryGroup => ({
|
||||
type: AdvancedSearchQueryElementType.Group,
|
||||
operator,
|
||||
children,
|
||||
})
|
||||
|
||||
const { And, Or, Not } = AdvancedSearchLogicalOperator
|
||||
|
||||
describe('serializeAdvancedSearchQuery', () => {
|
||||
describe('text fields', () => {
|
||||
it.each([
|
||||
[AdvancedSearchOperator.AllWords, 'invoice', 'title:invoice'],
|
||||
[
|
||||
AdvancedSearchOperator.AllWords,
|
||||
' invoice unpaid ',
|
||||
'title:invoice AND title:unpaid',
|
||||
],
|
||||
[
|
||||
AdvancedSearchOperator.AnyWord,
|
||||
'invoice unpaid',
|
||||
'title:invoice OR title:unpaid',
|
||||
],
|
||||
[
|
||||
AdvancedSearchOperator.Phrase,
|
||||
'quick brown fox',
|
||||
'title:"quick brown fox"',
|
||||
],
|
||||
[AdvancedSearchOperator.Phrase, 'say "hi"', 'title:"say hi"'],
|
||||
[AdvancedSearchOperator.StartsWith, 'invoi', 'title:invoi*'],
|
||||
[AdvancedSearchOperator.StartsWith, 'in*v?oi', 'title:invoi*'],
|
||||
])('%s %j writes %s', (operator, value, expected) => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(AdvancedSearchField.Title, operator, value)
|
||||
)
|
||||
).toBe(expected)
|
||||
})
|
||||
|
||||
it('writes bare words for the Any field', () => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(AdvancedSearchField.Any, AdvancedSearchOperator.AllWords, 'a b')
|
||||
)
|
||||
).toBe('a AND b')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['A-1312/99', 'custom_fields.value:A-1312/99'],
|
||||
["O'Brien", "custom_fields.value:O'Brien"],
|
||||
["'quoted'", `custom_fields.value:"'quoted'"`],
|
||||
['foo:bar', 'custom_fields.value:"foo:bar"'],
|
||||
['(x)', 'custom_fields.value:"(x)"'],
|
||||
['2024*', 'custom_fields.value:"2024*"'],
|
||||
['a,b', 'custom_fields.value:"a,b"'],
|
||||
['OR', 'custom_fields.value:"OR"'],
|
||||
['or', 'custom_fields.value:or'],
|
||||
])(
|
||||
'quotes %j only when the grammar would read it as syntax',
|
||||
(value, expected) => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(
|
||||
AdvancedSearchField.CustomFieldValue,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
value
|
||||
)
|
||||
)
|
||||
).toBe(expected)
|
||||
}
|
||||
)
|
||||
|
||||
it('uses the dotted names for custom fields', () => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
group(
|
||||
And,
|
||||
atom(
|
||||
AdvancedSearchField.CustomFieldName,
|
||||
AdvancedSearchOperator.Phrase,
|
||||
'status'
|
||||
),
|
||||
atom(
|
||||
AdvancedSearchField.CustomFieldValue,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
'paid'
|
||||
)
|
||||
)
|
||||
)
|
||||
).toBe('custom_fields.name:"status" AND custom_fields.value:paid')
|
||||
})
|
||||
|
||||
it('uses the dotted names for notes', () => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
group(
|
||||
And,
|
||||
atom(
|
||||
AdvancedSearchField.NoteText,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
'call'
|
||||
),
|
||||
atom(
|
||||
AdvancedSearchField.NoteAuthor,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
'alice'
|
||||
)
|
||||
)
|
||||
)
|
||||
).toBe('notes.note:call AND notes.user:alice')
|
||||
})
|
||||
|
||||
it.each([
|
||||
[AdvancedSearchOperator.AllWords, ''],
|
||||
[AdvancedSearchOperator.AllWords, ' '],
|
||||
[AdvancedSearchOperator.AllWords, '!! --'],
|
||||
[AdvancedSearchOperator.Phrase, '""'],
|
||||
[AdvancedSearchOperator.StartsWith, 'two words'],
|
||||
[AdvancedSearchOperator.StartsWith, '***'],
|
||||
[AdvancedSearchOperator.StartsWith, undefined],
|
||||
])('leaves out %s %j', (operator, value) => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(AdvancedSearchField.Title, operator, value)
|
||||
)
|
||||
).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('checksum', () => {
|
||||
it('lowercases the prefix', () => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(
|
||||
AdvancedSearchField.Checksum,
|
||||
AdvancedSearchOperator.StartsWith,
|
||||
'9F86D081'
|
||||
)
|
||||
)
|
||||
).toBe('checksum:9f86d081*')
|
||||
})
|
||||
})
|
||||
|
||||
describe('number fields', () => {
|
||||
it.each([
|
||||
[AdvancedSearchOperator.Equals, '42', undefined, 'asn:42'],
|
||||
[AdvancedSearchOperator.AtLeast, '50', undefined, 'asn:[50 to]'],
|
||||
[AdvancedSearchOperator.AtMost, '50', undefined, 'asn:[to 50]'],
|
||||
[AdvancedSearchOperator.Between, '50', '150', 'asn:[50 to 150]'],
|
||||
[AdvancedSearchOperator.Equals, '4.2', undefined, ''],
|
||||
[AdvancedSearchOperator.Equals, '-1', undefined, ''],
|
||||
[AdvancedSearchOperator.Equals, '2024-01-01', undefined, ''],
|
||||
[AdvancedSearchOperator.Between, '50', '', ''],
|
||||
])('%s %j %j writes %j', (operator, value, valueTo, expected) => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(AdvancedSearchField.ASN, operator, value, { valueTo })
|
||||
)
|
||||
).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe('date fields', () => {
|
||||
it.each([
|
||||
['today', 'added:today'],
|
||||
['previous month', 'added:"previous month"'],
|
||||
['last tuesday', ''],
|
||||
['', ''],
|
||||
])('keyword %j writes %j', (value, expected) => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(
|
||||
AdvancedSearchField.Added,
|
||||
AdvancedSearchOperator.DateKeyword,
|
||||
value
|
||||
)
|
||||
)
|
||||
).toBe(expected)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['1', AdvancedSearchDateUnit.Day, 'added:[-1 day to now]'],
|
||||
['3', AdvancedSearchDateUnit.Month, 'added:[-3 months to now]'],
|
||||
['2', AdvancedSearchDateUnit.Week, 'added:[-2 weeks to now]'],
|
||||
['0', AdvancedSearchDateUnit.Year, ''],
|
||||
['1.5', AdvancedSearchDateUnit.Year, ''],
|
||||
['3', undefined, ''],
|
||||
['3', 'fortnight' as AdvancedSearchDateUnit, ''],
|
||||
])('within the last %j %j writes %j', (value, unit, expected) => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(
|
||||
AdvancedSearchField.Added,
|
||||
AdvancedSearchOperator.WithinLast,
|
||||
value,
|
||||
{
|
||||
unit,
|
||||
}
|
||||
)
|
||||
)
|
||||
).toBe(expected)
|
||||
})
|
||||
|
||||
it.each([
|
||||
[
|
||||
AdvancedSearchOperator.AtLeast,
|
||||
'2024-01-01',
|
||||
undefined,
|
||||
'created:[2024-01-01 to]',
|
||||
],
|
||||
[
|
||||
AdvancedSearchOperator.AtMost,
|
||||
'2024-01-01',
|
||||
undefined,
|
||||
'created:[to 2024-01-01]',
|
||||
],
|
||||
[
|
||||
AdvancedSearchOperator.Between,
|
||||
'2024-01-01',
|
||||
'2024-03-31',
|
||||
'created:[2024-01-01 to 2024-03-31]',
|
||||
],
|
||||
[AdvancedSearchOperator.AtLeast, '2024', undefined, ''],
|
||||
[AdvancedSearchOperator.Between, '2024-01-01', 'now', ''],
|
||||
])('%s %j %j writes %j', (operator, value, valueTo, expected) => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
atom(AdvancedSearchField.Created, operator, value, { valueTo })
|
||||
)
|
||||
).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe('groups', () => {
|
||||
const invoice = atom(
|
||||
AdvancedSearchField.Content,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
'invoice'
|
||||
)
|
||||
const letter = atom(
|
||||
AdvancedSearchField.Title,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
'letter'
|
||||
)
|
||||
const paid = atom(
|
||||
AdvancedSearchField.Tag,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
'paid'
|
||||
)
|
||||
const twoWords = atom(
|
||||
AdvancedSearchField.Title,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
'a b'
|
||||
)
|
||||
const anyWords = atom(
|
||||
AdvancedSearchField.Title,
|
||||
AdvancedSearchOperator.AnyWord,
|
||||
'a b'
|
||||
)
|
||||
const empty = atom(
|
||||
AdvancedSearchField.Title,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
''
|
||||
)
|
||||
|
||||
it.each([
|
||||
['an empty group', group(And), ''],
|
||||
['a group of empty atoms', group(Or, empty, group(And, empty)), ''],
|
||||
[
|
||||
'a single child without parentheses',
|
||||
group(Or, invoice),
|
||||
'content:invoice',
|
||||
],
|
||||
['All', group(And, invoice, letter), 'content:invoice AND title:letter'],
|
||||
['Any', group(Or, invoice, letter), 'content:invoice OR title:letter'],
|
||||
[
|
||||
'skipped empty atoms',
|
||||
group(And, empty, invoice, empty),
|
||||
'content:invoice',
|
||||
],
|
||||
['Not with one child', group(Not, paid), 'NOT tag:paid'],
|
||||
[
|
||||
'Not as none of',
|
||||
group(Not, paid, letter),
|
||||
'NOT (tag:paid OR title:letter)',
|
||||
],
|
||||
[
|
||||
'Not with a compound child',
|
||||
group(Not, twoWords),
|
||||
'NOT (title:a AND title:b)',
|
||||
],
|
||||
[
|
||||
'Not inside All',
|
||||
group(And, invoice, group(Not, paid)),
|
||||
'content:invoice AND NOT tag:paid',
|
||||
],
|
||||
[
|
||||
'Not inside Any',
|
||||
group(Or, invoice, group(Not, paid)),
|
||||
'content:invoice OR NOT tag:paid',
|
||||
],
|
||||
[
|
||||
'Any inside All',
|
||||
group(And, invoice, group(Or, letter, paid)),
|
||||
'content:invoice AND (title:letter OR tag:paid)',
|
||||
],
|
||||
[
|
||||
'All inside Any',
|
||||
group(Or, invoice, group(And, letter, paid)),
|
||||
'content:invoice OR (title:letter AND tag:paid)',
|
||||
],
|
||||
[
|
||||
'All inside All flattened',
|
||||
group(And, invoice, group(And, letter, paid)),
|
||||
'content:invoice AND title:letter AND tag:paid',
|
||||
],
|
||||
[
|
||||
'an all-words atom inside Any',
|
||||
group(Or, invoice, twoWords),
|
||||
'content:invoice OR (title:a AND title:b)',
|
||||
],
|
||||
[
|
||||
'an any-word atom inside All',
|
||||
group(And, invoice, anyWords),
|
||||
'content:invoice AND (title:a OR title:b)',
|
||||
],
|
||||
[
|
||||
'an all-words atom inside Not with siblings',
|
||||
group(Not, paid, twoWords),
|
||||
'NOT (tag:paid OR (title:a AND title:b))',
|
||||
],
|
||||
])('writes %s', (_, tree, expected) => {
|
||||
expect(serializeAdvancedSearchQuery(tree)).toBe(expected)
|
||||
})
|
||||
|
||||
it('writes the mockup example', () => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
group(
|
||||
And,
|
||||
invoice,
|
||||
group(
|
||||
Or,
|
||||
atom(
|
||||
AdvancedSearchField.Correspondent,
|
||||
AdvancedSearchOperator.Phrase,
|
||||
'acme corp'
|
||||
),
|
||||
atom(
|
||||
AdvancedSearchField.Content,
|
||||
AdvancedSearchOperator.Phrase,
|
||||
'acme corporation'
|
||||
)
|
||||
),
|
||||
atom(
|
||||
AdvancedSearchField.Added,
|
||||
AdvancedSearchOperator.WithinLast,
|
||||
'3',
|
||||
{
|
||||
unit: AdvancedSearchDateUnit.Month,
|
||||
}
|
||||
),
|
||||
group(Not, paid)
|
||||
)
|
||||
)
|
||||
).toBe(
|
||||
'content:invoice AND (correspondent:"acme corp" OR content:"acme corporation") AND added:[-3 months to now] AND NOT tag:paid'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseAdvancedSearchQuery', () => {
|
||||
const canonical = [
|
||||
'title:invoice',
|
||||
'title:invoice AND title:unpaid',
|
||||
'content:invoice OR content:receipt',
|
||||
'a AND b',
|
||||
'title:"quick brown fox"',
|
||||
'title:invoi*',
|
||||
"custom_fields.value:O'Brien",
|
||||
'custom_fields.value:"foo:bar"',
|
||||
'custom_fields.name:"status" AND custom_fields.value:paid',
|
||||
'notes.note:call AND notes.user:alice',
|
||||
'checksum:9f86d081*',
|
||||
'asn:42',
|
||||
'asn:[50 to 150]',
|
||||
'asn:[50 to]',
|
||||
'asn:[to 50]',
|
||||
'page_count:[10 to]',
|
||||
'added:today',
|
||||
'added:"previous month"',
|
||||
'added:[-1 day to now]',
|
||||
'added:[-3 months to now]',
|
||||
'created:[2024-01-01 to 2024-03-31]',
|
||||
'created:[2024-01-01 to]',
|
||||
'created:[to 2024-01-01]',
|
||||
'NOT tag:paid',
|
||||
'NOT (tag:paid OR title:letter)',
|
||||
'NOT (title:a AND title:b)',
|
||||
'content:invoice OR NOT tag:paid',
|
||||
'content:invoice AND (title:letter OR tag:paid)',
|
||||
'content:invoice OR (title:letter AND tag:paid)',
|
||||
'content:invoice AND (correspondent:"acme corp" OR content:"acme corporation") AND added:[-3 months to now] AND NOT tag:paid',
|
||||
]
|
||||
|
||||
it.each(canonical)('reads back %s unchanged', (query) => {
|
||||
const tree = parseAdvancedSearchQuery(query)
|
||||
expect(tree).not.toBeNull()
|
||||
expect(serializeAdvancedSearchQuery(tree)).toBe(query)
|
||||
})
|
||||
|
||||
it('reads surrounding whitespace', () => {
|
||||
expect(
|
||||
serializeAdvancedSearchQuery(
|
||||
parseAdvancedSearchQuery(' title:invoice ')
|
||||
)
|
||||
).toBe('title:invoice')
|
||||
})
|
||||
|
||||
it('puts the words of one condition back together', () => {
|
||||
expect(parseAdvancedSearchQuery('title:invoice AND title:unpaid')).toEqual(
|
||||
group(
|
||||
And,
|
||||
atom(
|
||||
AdvancedSearchField.Title,
|
||||
AdvancedSearchOperator.AllWords,
|
||||
'invoice unpaid'
|
||||
)
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps words of different fields apart', () => {
|
||||
expect(parseAdvancedSearchQuery('title:a OR content:b')).toEqual(
|
||||
group(
|
||||
Or,
|
||||
atom(AdvancedSearchField.Title, AdvancedSearchOperator.AllWords, 'a'),
|
||||
atom(AdvancedSearchField.Content, AdvancedSearchOperator.AllWords, 'b')
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('reads a range as its condition', () => {
|
||||
expect(parseAdvancedSearchQuery('added:[-3 months to now]')).toEqual(
|
||||
group(
|
||||
And,
|
||||
atom(
|
||||
AdvancedSearchField.Added,
|
||||
AdvancedSearchOperator.WithinLast,
|
||||
'3',
|
||||
{
|
||||
unit: AdvancedSearchDateUnit.Month,
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it.each([
|
||||
['', 'nothing'],
|
||||
[' ', 'whitespace'],
|
||||
['type:invoice', 'a field alias'],
|
||||
['notes:call', 'a bare notes prefix'],
|
||||
['unknown:x', 'an unknown field'],
|
||||
['title:a AND content:b OR title:c', 'AND and OR mixed at one level'],
|
||||
['title:a b', 'an implicit AND'],
|
||||
['title:"unterminated', 'an unterminated phrase'],
|
||||
['asn:[50 to', 'an unterminated range'],
|
||||
['title:a*b', 'a wildcard in the middle'],
|
||||
['title:invoice^2', 'a boost'],
|
||||
['asn:[50 to abc]', 'a non-numeric bound'],
|
||||
['asn:invoice', 'a word on a number field'],
|
||||
['created:[2024 to 2025]', 'a year-only date range'],
|
||||
['added:"last tuesday"', 'a date keyword paperless does not have'],
|
||||
['title:[a to b]', 'a range on a text field'],
|
||||
['checksum:9f86d081', 'a checksum without a wildcard'],
|
||||
['(title:invoice)', 'parentheses the editor would not write'],
|
||||
['title:invoice AND', 'a trailing operator'],
|
||||
['title:"a"b', 'a value running into the next'],
|
||||
['ADDED:today', 'an uppercase field name'],
|
||||
])('leaves %s alone, having %s', (query) => {
|
||||
expect(parseAdvancedSearchQuery(query)).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,500 @@
|
||||
import {
|
||||
ADVANCED_SEARCH_DATE_KEYWORDS,
|
||||
ADVANCED_SEARCH_FIELD_KINDS,
|
||||
AdvancedSearchDateUnit,
|
||||
AdvancedSearchField,
|
||||
AdvancedSearchFieldKind,
|
||||
AdvancedSearchLogicalOperator,
|
||||
AdvancedSearchOperator,
|
||||
AdvancedSearchQueryAtom,
|
||||
AdvancedSearchQueryElement,
|
||||
AdvancedSearchQueryElementType,
|
||||
AdvancedSearchQueryGroup,
|
||||
} from '../data/advanced-search-query'
|
||||
|
||||
// Anything the query grammar would read as syntax rather than as a word
|
||||
const SYNTAX_CHARS = /[\s():"[\]*?,{}^~\\]/
|
||||
const SYNTAX_CHARS_GLOBAL = new RegExp(SYNTAX_CHARS, 'g')
|
||||
// A word wrapped in single quotes is also syntax, an apostrophe inside one is not
|
||||
const EDGE_SINGLE_QUOTE = /^'|'$/
|
||||
const RESERVED_WORDS = /^(AND|OR|NOT|TO)$/
|
||||
const HAS_WORD_CHAR = /[\p{L}\p{N}]/u
|
||||
const WHOLE_NUMBER = /^\d+$/
|
||||
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/
|
||||
|
||||
interface Serialized {
|
||||
text: string
|
||||
// The operator joining the top level of `text`, null when it is self-delimiting
|
||||
join:
|
||||
AdvancedSearchLogicalOperator.And | AdvancedSearchLogicalOperator.Or | null
|
||||
}
|
||||
|
||||
const prefix = (field: AdvancedSearchField) => (field ? `${field}:` : '')
|
||||
|
||||
const quote = (text: string) => `"${text.replace(/"/g, '')}"`
|
||||
|
||||
const words = (value: string) =>
|
||||
value
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.filter((word) => HAS_WORD_CHAR.test(word))
|
||||
|
||||
const word = (w: string) =>
|
||||
SYNTAX_CHARS.test(w) || EDGE_SINGLE_QUOTE.test(w) || RESERVED_WORDS.test(w)
|
||||
? quote(w)
|
||||
: w
|
||||
|
||||
const atomic = (text: string): Serialized => ({ text, join: null })
|
||||
|
||||
function serializeWords(
|
||||
atom: AdvancedSearchQueryAtom,
|
||||
join: AdvancedSearchLogicalOperator.And | AdvancedSearchLogicalOperator.Or
|
||||
): Serialized {
|
||||
// A field applies only to the word right after it, so repeat it per word
|
||||
const terms = words(atom.value ?? '').map(
|
||||
(w) => `${prefix(atom.field)}${word(w)}`
|
||||
)
|
||||
if (terms.length === 0) return null
|
||||
if (terms.length === 1) return atomic(terms[0])
|
||||
return { text: terms.join(` ${join} `), join }
|
||||
}
|
||||
|
||||
function serializeRange(
|
||||
atom: AdvancedSearchQueryAtom,
|
||||
isValid: (v: string) => boolean
|
||||
): Serialized {
|
||||
const lo = atom.value?.trim() ?? ''
|
||||
const hi = atom.valueTo?.trim() ?? ''
|
||||
const field = prefix(atom.field)
|
||||
switch (atom.operator) {
|
||||
case AdvancedSearchOperator.Equals:
|
||||
return isValid(lo) ? atomic(`${field}${lo}`) : null
|
||||
case AdvancedSearchOperator.AtLeast:
|
||||
return isValid(lo) ? atomic(`${field}[${lo} to]`) : null
|
||||
case AdvancedSearchOperator.AtMost:
|
||||
return isValid(lo) ? atomic(`${field}[to ${lo}]`) : null
|
||||
case AdvancedSearchOperator.Between:
|
||||
return isValid(lo) && isValid(hi)
|
||||
? atomic(`${field}[${lo} to ${hi}]`)
|
||||
: null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function serializeAtom(atom: AdvancedSearchQueryAtom): Serialized {
|
||||
const field = prefix(atom.field)
|
||||
const value = atom.value?.trim() ?? ''
|
||||
|
||||
switch (atom.operator) {
|
||||
case AdvancedSearchOperator.AllWords:
|
||||
return serializeWords(atom, AdvancedSearchLogicalOperator.And)
|
||||
case AdvancedSearchOperator.AnyWord:
|
||||
return serializeWords(atom, AdvancedSearchLogicalOperator.Or)
|
||||
case AdvancedSearchOperator.Phrase:
|
||||
return HAS_WORD_CHAR.test(value)
|
||||
? atomic(`${field}${quote(value)}`)
|
||||
: null
|
||||
case AdvancedSearchOperator.StartsWith: {
|
||||
if (/\s/.test(value)) return null
|
||||
let stem = value.replace(SYNTAX_CHARS_GLOBAL, '')
|
||||
if (!HAS_WORD_CHAR.test(stem)) return null
|
||||
// checksum is indexed as-is, in lowercase
|
||||
if (atom.field === AdvancedSearchField.Checksum) {
|
||||
stem = stem.toLowerCase()
|
||||
}
|
||||
return atomic(`${field}${stem}*`)
|
||||
}
|
||||
case AdvancedSearchOperator.DateKeyword:
|
||||
return (ADVANCED_SEARCH_DATE_KEYWORDS as readonly string[]).includes(
|
||||
value
|
||||
)
|
||||
? atomic(`${field}${word(value)}`)
|
||||
: null
|
||||
case AdvancedSearchOperator.WithinLast: {
|
||||
const amount = parseInt(value, 10)
|
||||
const units = Object.values(AdvancedSearchDateUnit) as string[]
|
||||
if (!WHOLE_NUMBER.test(value) || amount < 1) return null
|
||||
if (!units.includes(atom.unit)) return null
|
||||
const unit = amount === 1 ? atom.unit : `${atom.unit}s`
|
||||
return atomic(`${field}[-${amount} ${unit} to now]`)
|
||||
}
|
||||
case AdvancedSearchOperator.Equals:
|
||||
case AdvancedSearchOperator.AtLeast:
|
||||
case AdvancedSearchOperator.AtMost:
|
||||
case AdvancedSearchOperator.Between:
|
||||
return serializeRange(
|
||||
atom,
|
||||
ADVANCED_SEARCH_FIELD_KINDS[atom.field] === AdvancedSearchFieldKind.Date
|
||||
? (v) => ISO_DATE.test(v)
|
||||
: (v) => WHOLE_NUMBER.test(v)
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function wrap(
|
||||
child: Serialized,
|
||||
parentJoin: AdvancedSearchLogicalOperator
|
||||
): string {
|
||||
return child.join === null || child.join === parentJoin
|
||||
? child.text
|
||||
: `(${child.text})`
|
||||
}
|
||||
|
||||
function serializeGroup(group: AdvancedSearchQueryGroup): Serialized {
|
||||
const children = group.children.map(serializeElement).filter(Boolean)
|
||||
if (children.length === 0) return null
|
||||
|
||||
if (group.operator === AdvancedSearchLogicalOperator.Not) {
|
||||
// A Not group matches documents matching none of its children
|
||||
if (children.length === 1 && children[0].join === null) {
|
||||
return atomic(`NOT ${children[0].text}`)
|
||||
}
|
||||
const inner =
|
||||
children.length === 1
|
||||
? children[0].text
|
||||
: children
|
||||
.map((c) => wrap(c, AdvancedSearchLogicalOperator.Or))
|
||||
.join(' OR ')
|
||||
return atomic(`NOT (${inner})`)
|
||||
}
|
||||
|
||||
if (children.length === 1) return children[0]
|
||||
return {
|
||||
text: children
|
||||
.map((c) => wrap(c, group.operator))
|
||||
.join(` ${group.operator} `),
|
||||
join: group.operator,
|
||||
}
|
||||
}
|
||||
|
||||
function serializeElement(element: AdvancedSearchQueryElement): Serialized {
|
||||
return element.type === AdvancedSearchQueryElementType.Group
|
||||
? serializeGroup(element)
|
||||
: serializeAtom(element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an editor tree as a full-text query. Atoms that are not filled in
|
||||
* (or not valid) are left out, and empty groups with them.
|
||||
*/
|
||||
export function serializeAdvancedSearchQuery(
|
||||
element: AdvancedSearchQueryElement
|
||||
): string {
|
||||
return serializeElement(element)?.text ?? ''
|
||||
}
|
||||
|
||||
// --- Reading a query back into the editor --------------------------------
|
||||
//
|
||||
// Deliberately narrow: this reads the forms serializeAdvancedSearchQuery
|
||||
// writes, and nothing else. A query it cannot read is not a failure, it just
|
||||
// stays text, so there is never a lossy or surprising conversion. The final
|
||||
// round-trip check below is what holds that promise: a tree is only returned
|
||||
// when writing it out again reproduces the query exactly.
|
||||
|
||||
const RELATIVE_BOUND = /^-(\d+) (day|week|month|year)s?$/
|
||||
const FIELD_PREFIX = /^([a-z_]+(?:\.[a-z_]+)?):/
|
||||
const KEYWORD_TOKEN = /^(AND|OR|NOT)(?=[\s(]|$)/
|
||||
// Either bound may be missing: [50 to 150], [50 to], [to 50]
|
||||
const RANGE_BOUNDS = /^(?:(.+?) )?to(?: (.+))?$/
|
||||
const TRAILING_WILDCARD = /^([^*?]+)\*$/
|
||||
|
||||
class UnreadableQuery extends Error {}
|
||||
|
||||
interface Token {
|
||||
type: 'term' | 'AND' | 'OR' | 'NOT' | '(' | ')'
|
||||
field?: string
|
||||
value?: string
|
||||
quoted?: boolean
|
||||
range?: boolean
|
||||
}
|
||||
|
||||
// A parsed element, plus what it takes to merge the per-word terms the
|
||||
// serializer writes for "contains all words" back into a single condition
|
||||
interface Parsed {
|
||||
element: AdvancedSearchQueryElement
|
||||
word?: { field: AdvancedSearchField; text: string }
|
||||
}
|
||||
|
||||
function tokenize(query: string): Token[] {
|
||||
const tokens: Token[] = []
|
||||
let i = 0
|
||||
while (i < query.length) {
|
||||
const rest = query.slice(i)
|
||||
if (/^\s/.test(rest)) {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
if (rest[0] === '(' || rest[0] === ')') {
|
||||
tokens.push({ type: rest[0] as '(' | ')' })
|
||||
i++
|
||||
continue
|
||||
}
|
||||
const keyword = KEYWORD_TOKEN.exec(rest)
|
||||
if (keyword) {
|
||||
tokens.push({ type: keyword[1] as 'AND' | 'OR' | 'NOT' })
|
||||
i += keyword[1].length
|
||||
continue
|
||||
}
|
||||
const fieldMatch = FIELD_PREFIX.exec(rest)
|
||||
const field = fieldMatch ? fieldMatch[1] : ''
|
||||
i += fieldMatch ? fieldMatch[0].length : 0
|
||||
|
||||
const value = query.slice(i)
|
||||
if (value.startsWith('"')) {
|
||||
const end = query.indexOf('"', i + 1)
|
||||
if (end < 0) throw new UnreadableQuery()
|
||||
tokens.push({
|
||||
type: 'term',
|
||||
field,
|
||||
value: query.slice(i + 1, end),
|
||||
quoted: true,
|
||||
})
|
||||
i = end + 1
|
||||
} else if (value.startsWith('[')) {
|
||||
const end = query.indexOf(']', i + 1)
|
||||
if (end < 0) throw new UnreadableQuery()
|
||||
tokens.push({
|
||||
type: 'term',
|
||||
field,
|
||||
value: query.slice(i + 1, end),
|
||||
range: true,
|
||||
})
|
||||
i = end + 1
|
||||
} else {
|
||||
const bare = /^[^\s()]+/.exec(value)
|
||||
if (!bare) throw new UnreadableQuery()
|
||||
tokens.push({ type: 'term', field, value: bare[0] })
|
||||
i += bare[0].length
|
||||
}
|
||||
// Nothing may run on directly after a value, e.g. title:"a"b
|
||||
if (i < query.length && !/[\s)]/.test(query[i])) throw new UnreadableQuery()
|
||||
}
|
||||
return tokens
|
||||
}
|
||||
|
||||
function resolveField(name: string): AdvancedSearchField {
|
||||
const fields = Object.values(AdvancedSearchField) as string[]
|
||||
// Aliases (type:, path:, notes:) are left to the text box on purpose:
|
||||
// reading one would mean rewriting the user's query as it was read
|
||||
if (!fields.includes(name)) throw new UnreadableQuery()
|
||||
return name as AdvancedSearchField
|
||||
}
|
||||
|
||||
function atomFrom(
|
||||
field: AdvancedSearchField,
|
||||
operator: AdvancedSearchOperator,
|
||||
value: string,
|
||||
extra: Partial<AdvancedSearchQueryAtom> = {}
|
||||
): AdvancedSearchQueryAtom {
|
||||
return {
|
||||
type: AdvancedSearchQueryElementType.Atom,
|
||||
field,
|
||||
operator,
|
||||
value,
|
||||
...extra,
|
||||
}
|
||||
}
|
||||
|
||||
function parseRange(
|
||||
field: AdvancedSearchField,
|
||||
kind: AdvancedSearchFieldKind,
|
||||
body: string
|
||||
): AdvancedSearchQueryAtom {
|
||||
const bounds = RANGE_BOUNDS.exec(body)
|
||||
if (!bounds) throw new UnreadableQuery()
|
||||
const lo = bounds[1] ?? ''
|
||||
const hi = bounds[2] ?? ''
|
||||
|
||||
if (kind === AdvancedSearchFieldKind.Date) {
|
||||
const relative = RELATIVE_BOUND.exec(lo)
|
||||
if (relative && hi === 'now') {
|
||||
return atomFrom(field, AdvancedSearchOperator.WithinLast, relative[1], {
|
||||
unit: relative[2] as AdvancedSearchDateUnit,
|
||||
})
|
||||
}
|
||||
} else if (kind !== AdvancedSearchFieldKind.Number) {
|
||||
throw new UnreadableQuery()
|
||||
}
|
||||
|
||||
const isValid =
|
||||
kind === AdvancedSearchFieldKind.Date
|
||||
? (v: string) => ISO_DATE.test(v)
|
||||
: (v: string) => WHOLE_NUMBER.test(v)
|
||||
|
||||
if (lo && hi) {
|
||||
if (!isValid(lo) || !isValid(hi)) throw new UnreadableQuery()
|
||||
return atomFrom(field, AdvancedSearchOperator.Between, lo, { valueTo: hi })
|
||||
}
|
||||
if (lo && isValid(lo))
|
||||
return atomFrom(field, AdvancedSearchOperator.AtLeast, lo)
|
||||
if (hi && isValid(hi))
|
||||
return atomFrom(field, AdvancedSearchOperator.AtMost, hi)
|
||||
throw new UnreadableQuery()
|
||||
}
|
||||
|
||||
function parseTerm(token: Token): Parsed {
|
||||
const field = resolveField(token.field)
|
||||
const kind = ADVANCED_SEARCH_FIELD_KINDS[field]
|
||||
const value = token.value
|
||||
const isKeyword = (
|
||||
ADVANCED_SEARCH_DATE_KEYWORDS as readonly string[]
|
||||
).includes(value)
|
||||
|
||||
if (token.range) {
|
||||
return { element: parseRange(field, kind, value) }
|
||||
}
|
||||
|
||||
if (kind === AdvancedSearchFieldKind.Date) {
|
||||
if (!isKeyword) throw new UnreadableQuery()
|
||||
return {
|
||||
element: atomFrom(field, AdvancedSearchOperator.DateKeyword, value),
|
||||
}
|
||||
}
|
||||
|
||||
if (token.quoted) {
|
||||
if (kind !== AdvancedSearchFieldKind.Text) throw new UnreadableQuery()
|
||||
return { element: atomFrom(field, AdvancedSearchOperator.Phrase, value) }
|
||||
}
|
||||
|
||||
const wildcard = TRAILING_WILDCARD.exec(value)
|
||||
if (wildcard) {
|
||||
if (kind === AdvancedSearchFieldKind.Number) throw new UnreadableQuery()
|
||||
return {
|
||||
element: atomFrom(field, AdvancedSearchOperator.StartsWith, wildcard[1]),
|
||||
}
|
||||
}
|
||||
|
||||
if (kind === AdvancedSearchFieldKind.Number) {
|
||||
if (!WHOLE_NUMBER.test(value)) throw new UnreadableQuery()
|
||||
return { element: atomFrom(field, AdvancedSearchOperator.Equals, value) }
|
||||
}
|
||||
// A checksum is only ever searched by its first characters
|
||||
if (kind === AdvancedSearchFieldKind.Checksum) throw new UnreadableQuery()
|
||||
|
||||
return {
|
||||
element: atomFrom(field, AdvancedSearchOperator.AllWords, value),
|
||||
word: { field, text: value },
|
||||
}
|
||||
}
|
||||
|
||||
// The serializer repeats the field for every word, because a field applies
|
||||
// only to the word after it. Put those back together into one condition.
|
||||
function mergeWords(
|
||||
parts: Parsed[],
|
||||
operator: AdvancedSearchLogicalOperator.And | AdvancedSearchLogicalOperator.Or
|
||||
): AdvancedSearchQueryElement[] {
|
||||
const merged: AdvancedSearchQueryElement[] = []
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const run = [parts[i]]
|
||||
while (
|
||||
parts[i].word &&
|
||||
parts[i + 1]?.word &&
|
||||
parts[i + 1].word.field === parts[i].word.field
|
||||
) {
|
||||
run.push(parts[++i])
|
||||
}
|
||||
if (run.length === 1) {
|
||||
merged.push(run[0].element)
|
||||
continue
|
||||
}
|
||||
merged.push(
|
||||
atomFrom(
|
||||
run[0].word.field,
|
||||
operator === AdvancedSearchLogicalOperator.And
|
||||
? AdvancedSearchOperator.AllWords
|
||||
: AdvancedSearchOperator.AnyWord,
|
||||
run.map((part) => part.word.text).join(' ')
|
||||
)
|
||||
)
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
interface Cursor {
|
||||
tokens: Token[]
|
||||
at: number
|
||||
}
|
||||
|
||||
function parseExpression(cursor: Cursor): Parsed {
|
||||
const parts: Parsed[] = [parseOperand(cursor)]
|
||||
let operator:
|
||||
AdvancedSearchLogicalOperator.And | AdvancedSearchLogicalOperator.Or
|
||||
while (
|
||||
cursor.tokens[cursor.at]?.type === 'AND' ||
|
||||
cursor.tokens[cursor.at]?.type === 'OR'
|
||||
) {
|
||||
const next = cursor.tokens[cursor.at++].type as
|
||||
AdvancedSearchLogicalOperator.And | AdvancedSearchLogicalOperator.Or
|
||||
// One level mixing AND and OR is never something the editor wrote
|
||||
if (operator && next !== operator) throw new UnreadableQuery()
|
||||
operator = next
|
||||
parts.push(parseOperand(cursor))
|
||||
}
|
||||
if (parts.length === 1) return parts[0]
|
||||
|
||||
const children = mergeWords(parts, operator)
|
||||
if (children.length === 1) return { element: children[0] }
|
||||
return {
|
||||
element: {
|
||||
type: AdvancedSearchQueryElementType.Group,
|
||||
operator,
|
||||
children,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function parseOperand(cursor: Cursor): Parsed {
|
||||
const token = cursor.tokens[cursor.at++]
|
||||
if (!token) throw new UnreadableQuery()
|
||||
|
||||
if (token.type === 'NOT') {
|
||||
const child = parseOperand(cursor)
|
||||
return {
|
||||
element: {
|
||||
type: AdvancedSearchQueryElementType.Group,
|
||||
operator: AdvancedSearchLogicalOperator.Not,
|
||||
children: [child.element],
|
||||
},
|
||||
}
|
||||
}
|
||||
if (token.type === '(') {
|
||||
const inner = parseExpression(cursor)
|
||||
if (cursor.tokens[cursor.at++]?.type !== ')') throw new UnreadableQuery()
|
||||
return { element: inner.element }
|
||||
}
|
||||
if (token.type !== 'term') throw new UnreadableQuery()
|
||||
return parseTerm(token)
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a query the editor could have written back into an editor tree, or
|
||||
* returns null when the editor cannot show it, in which case the query stays
|
||||
* text. Never returns a tree that would be written back differently.
|
||||
*/
|
||||
export function parseAdvancedSearchQuery(
|
||||
query: string
|
||||
): AdvancedSearchQueryGroup | null {
|
||||
const trimmed = query?.trim() ?? ''
|
||||
if (!trimmed) return null
|
||||
|
||||
let parsed: Parsed
|
||||
try {
|
||||
const cursor: Cursor = { tokens: tokenize(trimmed), at: 0 }
|
||||
parsed = parseExpression(cursor)
|
||||
if (cursor.at !== cursor.tokens.length) throw new UnreadableQuery()
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
|
||||
const root =
|
||||
parsed.element.type === AdvancedSearchQueryElementType.Group
|
||||
? parsed.element
|
||||
: {
|
||||
type: AdvancedSearchQueryElementType.Group as const,
|
||||
operator: AdvancedSearchLogicalOperator.And,
|
||||
children: [parsed.element],
|
||||
}
|
||||
|
||||
return serializeAdvancedSearchQuery(root) === trimmed ? root : null
|
||||
}
|
||||
@@ -8,7 +8,7 @@ export const environment = {
|
||||
apiVersion: '10', // match src/paperless/settings.py
|
||||
appTitle: DEFAULT_APP_TITLE,
|
||||
tag: 'prod',
|
||||
version: '3.4.0',
|
||||
version: '3.4.1',
|
||||
webSocketHost: window.location.host,
|
||||
webSocketProtocol: window.location.protocol == 'https:' ? 'wss:' : 'ws:',
|
||||
webSocketBaseUrl: base_url.pathname + 'ws/',
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Wysig dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Wysig dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">تعديل المستند</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">تعديل المستند</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Рэдагаваць дакумент</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Рэдагаваць дакумент</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Сортирай по: <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Редактиране на документа</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Визуализация на документа</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Редактиране на документа</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Ordena per <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Edita document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Previsualitza document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Edita document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Seřadit podle <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Upravit dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Náhled dokumentu</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Upravit dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Nach <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/> sortieren</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Dokument bearbeiten</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Dokumentenvorschau</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Dokument bearbeiten</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -4795,7 +4795,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html</context>
|
||||
<context context-type="linenumber">38</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Date mode</target>
|
||||
<target state="translated">Datumsmodus</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7572800523712857519" datatype="html">
|
||||
<source>Fixed date</source>
|
||||
@@ -4807,7 +4807,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html</context>
|
||||
<context context-type="linenumber">40</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Fixed date</target>
|
||||
<target state="translated">Festes Datum</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4108478337308251505" datatype="html">
|
||||
<source>Fixed</source>
|
||||
@@ -4815,7 +4815,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html</context>
|
||||
<context context-type="linenumber">41,42</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Fixed</target>
|
||||
<target state="translated">Fixiert</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="8283919074858117329" datatype="html">
|
||||
<source>Relative date</source>
|
||||
@@ -4827,7 +4827,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html</context>
|
||||
<context context-type="linenumber">44</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Relative date</target>
|
||||
<target state="translated">Relatives Datum</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2731996625798485199" datatype="html">
|
||||
<source>Relative</source>
|
||||
@@ -4835,7 +4835,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html</context>
|
||||
<context context-type="linenumber">45,46</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Relative</target>
|
||||
<target state="translated">Relativ</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6533918067030990396" datatype="html">
|
||||
<source>Amount</source>
|
||||
@@ -4843,7 +4843,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html</context>
|
||||
<context context-type="linenumber">51</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Amount</target>
|
||||
<target state="translated">Anzahl</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="8932917860978648376" datatype="html">
|
||||
<source>Unit</source>
|
||||
@@ -4851,7 +4851,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html</context>
|
||||
<context context-type="linenumber">56,57</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Unit</target>
|
||||
<target state="translated">Einheit</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9138811584797805840" datatype="html">
|
||||
<source>Open date picker</source>
|
||||
@@ -4991,7 +4991,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.html</context>
|
||||
<context context-type="linenumber">119,120</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Operator</target>
|
||||
<target state="translated">Operator</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2328549728463836983" datatype="html">
|
||||
<source>Remove query</source>
|
||||
@@ -5051,7 +5051,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts</context>
|
||||
<context context-type="linenumber">330</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">days ago</target>
|
||||
<target state="translated">vor Tagen</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2871318661796659216" datatype="html">
|
||||
<source>weeks ago</source>
|
||||
@@ -5059,7 +5059,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">weeks ago</target>
|
||||
<target state="translated">vor Wochen</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6041340836190906216" datatype="html">
|
||||
<source>months ago</source>
|
||||
@@ -5067,7 +5067,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts</context>
|
||||
<context context-type="linenumber">332</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">months ago</target>
|
||||
<target state="translated">vor Monaten</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="963494111451627204" datatype="html">
|
||||
<source>years ago</source>
|
||||
@@ -5075,7 +5075,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts</context>
|
||||
<context context-type="linenumber">333</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">years ago</target>
|
||||
<target state="translated">vor Jahren</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5555905617885007774" datatype="html">
|
||||
<source>days from now</source>
|
||||
@@ -5083,7 +5083,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts</context>
|
||||
<context context-type="linenumber">334</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">days from now</target>
|
||||
<target state="translated">Tage von heute an</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4298377021616940216" datatype="html">
|
||||
<source>weeks from now</source>
|
||||
@@ -5091,7 +5091,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts</context>
|
||||
<context context-type="linenumber">335</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">weeks from now</target>
|
||||
<target state="translated">Wochen von heute an</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2772874767134148305" datatype="html">
|
||||
<source>months from now</source>
|
||||
@@ -5099,7 +5099,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts</context>
|
||||
<context context-type="linenumber">336</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">months from now</target>
|
||||
<target state="translated">Monate von heute an</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6363533917780225967" datatype="html">
|
||||
<source>years from now</source>
|
||||
@@ -5107,7 +5107,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts</context>
|
||||
<context context-type="linenumber">337</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">years from now</target>
|
||||
<target state="translated">Jahr von heute an</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="6630533861307510614" datatype="html">
|
||||
<source>Clear created relative date</source>
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="final">Nach <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/> sortieren</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html" approved="yes">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="final">Dokument bearbeiten</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html" approved="yes">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="final">Dokumentenvorschau</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html" approved="yes">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="final">Dokument bearbeiten</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html" approved="yes">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Επεξεργασία εγγράφου</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Επεξεργασία εγγράφου</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Ordenar por <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Editar documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Previsualizar documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Editar documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">سند ویرایش</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">سند پیش نمایش</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">سند ویرایش</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Muokkaa asiakirjaa</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Esikatsele asiakirja</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Muokkaa asiakirjaa</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -3719,7 +3719,7 @@
|
||||
<context context-type="sourcefile">src/app/components/admin/users-groups/users-groups.component.ts</context>
|
||||
<context context-type="linenumber">163</context>
|
||||
</context-group>
|
||||
<target state="translated">Erreur lors de la supression de l’utilisateur « <x id="PH" equiv-text="user.username"/> ».</target>
|
||||
<target state="translated">Erreur lors de la suppression de l’utilisateur « <x id="PH" equiv-text="user.username"/> ».</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5766640174051730159" datatype="html" approved="yes">
|
||||
<source>Saved group "<x id="PH" equiv-text="newGroup.name"/>".</source>
|
||||
@@ -3767,7 +3767,7 @@
|
||||
<context context-type="sourcefile">src/app/components/admin/users-groups/users-groups.component.ts</context>
|
||||
<context context-type="linenumber">220</context>
|
||||
</context-group>
|
||||
<target state="translated">Erreur lors de la supression du groupe « <x id="PH" equiv-text="group.name"/> ».</target>
|
||||
<target state="translated">Erreur lors de la suppression du groupe « <x id="PH" equiv-text="group.name"/> ».</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7931334600001636863" datatype="html" approved="yes">
|
||||
<source>by Paperless-ngx</source>
|
||||
@@ -6935,7 +6935,7 @@
|
||||
<context context-type="sourcefile">src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html</context>
|
||||
<context context-type="linenumber">410</context>
|
||||
</context-group>
|
||||
<target state="translated">Destinatires du courriel</target>
|
||||
<target state="translated">Destinataires du courriel</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7916910101279824329" datatype="html">
|
||||
<source>Attach document</source>
|
||||
@@ -10930,7 +10930,7 @@
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-card-small/document-card-small.component.html</context>
|
||||
<context context-type="linenumber">8,9</context>
|
||||
</context-group>
|
||||
<target state="translated"><x id="INTERPOLATION" equiv-text="{{ document().title | documentTitle }}"/> mignature</target>
|
||||
<target state="translated"><x id="INTERPOLATION" equiv-text="{{ document().title | documentTitle }}"/> miniature</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2784168796433474565" datatype="html" approved="yes">
|
||||
<source>Filter by tag</source>
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Trier par <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html" approved="yes">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="final">Modifier le document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Prévisualiser le document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html" approved="yes">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="final">Modifier le document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">מיון לפי <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">עריכת מסמך</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">תצוגה מקדימה של המסמך</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">עריכת מסמך</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Sortiraj po <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Uredi dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Pregledaj dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Uredi dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Rendezés <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/> szerint</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Dokumentum szerkesztése</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Dokumentum előnézete</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Dokumentum szerkesztése</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Urutkan berdasarkan <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Edit dokumen</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Pratinjau dokumen</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Edit dokumen</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Ordina per <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Modifica documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Anteprima documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Modifica documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated"><x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/> でソート</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">ドキュメントを編集</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">ドキュメントのプレビュー</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">ドキュメントを編集</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">문서 수정</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">문서 미리보기</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">문서 수정</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Dokument editéieren</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Dokument editéieren</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Rediģēt dokumentu</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Rediģēt dokumentu</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
+1503
-1504
File diff suppressed because it is too large.
Load diff
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Edit document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Sorteer op <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Document bewerken</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Voorbeeld van document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Document bewerken</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Sorter etter <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Rediger dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Forhåndsvis dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Rediger dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Sortuj według <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Edytuj dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Podgląd dokumentu</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Edytuj dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11398,22 +11398,22 @@ Erro ao enviar documentos por e-mail</target>
|
||||
</context-group>
|
||||
<target state="translated">Ordenar por <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Editar documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Prévisualizar documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Editar documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Editar documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Editar documento</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Sortează după <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Editează document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Previzualizare document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Editează document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Сортировать по <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Изменить документ</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Предпросмотр документа</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Изменить документ</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11398,22 +11398,22 @@ zhodujúce sa</target>
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Upraviť dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Upraviť dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Razvrsti po <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Uredi dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Predogled dokumenta</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Uredi dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Rendit by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Redakto dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Preview dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Redakto dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11398,22 +11398,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Složi prema <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Uredi dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Pregledaj dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Uredi dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">Sortera efter <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Redigera dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Förhandsvisa dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Redigera dokument</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">แก้ไขเอกสาร</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="needs-translation">Preview document</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">แก้ไขเอกสาร</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11398,22 +11398,22 @@ tüm <x id="CLOSE_EMPHASISED_TEXT" ctype="x-em" equiv-text="</em>"/> krite
|
||||
</context-group>
|
||||
<target state="translated"><x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/> göre sırala</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Belgeyi düzenle</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Belgeyi ön izle</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Belgeyi düzenle</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="needs-translation">Sort by <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Редагувати документ</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">Попередній перегляд документа</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">Редагувати документ</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11459,22 +11459,22 @@
|
||||
Sắp xếp theo
|
||||
</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html" approved="yes">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="final">Chỉnh sửa tài liệu</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html" approved="yes">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="final">Xem trước tài liệu</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html" approved="yes">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="final">Chỉnh sửa tài liệu</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html" approved="yes">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11396,22 +11396,22 @@
|
||||
</context-group>
|
||||
<target state="translated">按 <x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/> 排序</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">编辑文档</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">预览文档</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">编辑文档</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -11397,22 +11397,22 @@
|
||||
</context-group>
|
||||
<target state="translated">以<x id="INTERPOLATION" equiv-text="{{getDisplayCustomFieldTitle(field_id)}}"/>排序</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">編輯文件</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3420321797707163677" datatype="html">
|
||||
<source>Preview document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">329</context>
|
||||
<context context-type="linenumber">328</context>
|
||||
</context-group>
|
||||
<target state="translated">預覽文件</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2179847500064178686" datatype="html">
|
||||
<source>Edit document</source>
|
||||
<context-group purpose="location">
|
||||
<context context-type="sourcefile">src/app/components/document-list/document-list.component.html</context>
|
||||
<context context-type="linenumber">331</context>
|
||||
</context-group>
|
||||
<target state="translated">編輯文件</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4512084577073831437" datatype="html">
|
||||
<source>Reset filters / selection</source>
|
||||
<context-group purpose="location">
|
||||
|
||||
@@ -155,6 +155,7 @@ import {
|
||||
send,
|
||||
shop,
|
||||
slashCircle,
|
||||
sliders,
|
||||
sliders2Vertical,
|
||||
sortAlphaDown,
|
||||
sortAlphaUpAlt,
|
||||
@@ -411,6 +412,7 @@ const icons = {
|
||||
send,
|
||||
slashCircle,
|
||||
shop,
|
||||
sliders,
|
||||
sliders2Vertical,
|
||||
sortAlphaDown,
|
||||
sortAlphaUpAlt,
|
||||
|
||||
@@ -10,9 +10,6 @@ from typing import TYPE_CHECKING
|
||||
import regex as regex_mod
|
||||
from django.conf import settings
|
||||
from pdf2image import convert_from_path
|
||||
from pikepdf import Page
|
||||
from pikepdf import PasswordError
|
||||
from pikepdf import Pdf
|
||||
|
||||
from documents.converters import convert_from_tiff_to_pdf
|
||||
from documents.data_models import ConsumableDocument
|
||||
@@ -34,6 +31,7 @@ from documents.utils import maybe_override_pixel_limit
|
||||
from paperless.config import BarcodeConfig
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pikepdf import Page
|
||||
from PIL import Image
|
||||
|
||||
logger = logging.getLogger("paperless.barcodes")
|
||||
@@ -282,6 +280,8 @@ class BarcodePlugin(ConsumeTaskPlugin):
|
||||
# No op if not a TIFF
|
||||
self.convert_from_tiff_to_pdf()
|
||||
|
||||
from pikepdf import PasswordError
|
||||
|
||||
try:
|
||||
self.barcodes = scan_pdf(
|
||||
self.pdf_file,
|
||||
@@ -433,6 +433,8 @@ class BarcodePlugin(ConsumeTaskPlugin):
|
||||
|
||||
document_paths = []
|
||||
fname: str = self.input_doc.original_file.stem
|
||||
from pikepdf import Pdf
|
||||
|
||||
with Pdf.open(self.pdf_file) as input_pdf:
|
||||
# Start with an empty document
|
||||
current_document: list[Page] = []
|
||||
@@ -516,6 +518,8 @@ def scan_pdf(pdf_path: Path, settings: BarcodeConfig, work_dir: Path) -> list[Ba
|
||||
"""
|
||||
barcodes: list[Barcode] = []
|
||||
|
||||
from pikepdf import Pdf
|
||||
|
||||
with Pdf.open(pdf_path) as pdf:
|
||||
num_of_pages = len(pdf.pages)
|
||||
logger.debug(f"PDF has {num_of_pages} pages")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from pathlib import Path
|
||||
|
||||
import img2pdf
|
||||
from PIL import Image
|
||||
|
||||
from documents.utils import copy_basic_file_stats
|
||||
@@ -17,6 +16,8 @@ def convert_from_tiff_to_pdf(tiff_path: Path, target_directory: Path) -> Path:
|
||||
|
||||
Returns the path of the PDF created.
|
||||
"""
|
||||
import img2pdf
|
||||
|
||||
# override pixel setting if needed
|
||||
maybe_override_pixel_limit()
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
from django.conf import settings
|
||||
from pikepdf import Pdf
|
||||
|
||||
from documents.consumer import ConsumerError
|
||||
from documents.converters import convert_from_tiff_to_pdf
|
||||
@@ -85,6 +84,8 @@ class CollatePlugin(NoCleanupPluginMixin, NoSetupPluginMixin, ConsumeTaskPlugin)
|
||||
valid_staging_exists = True
|
||||
|
||||
if valid_staging_exists:
|
||||
from pikepdf import Pdf
|
||||
|
||||
try:
|
||||
# Collate pages from second PDF in reverse order
|
||||
with Pdf.open(staging) as pdf1, Pdf.open(pdf_file) as pdf2:
|
||||
|
||||
@@ -11,7 +11,6 @@ from decimal import InvalidOperation
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Any
|
||||
|
||||
import dateparser
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db.models import Case
|
||||
@@ -350,6 +349,8 @@ class DateQueryField(serializers.DateField):
|
||||
if not isinstance(value, str):
|
||||
raise
|
||||
|
||||
import dateparser
|
||||
|
||||
try:
|
||||
parsed = dateparser.parse(
|
||||
value,
|
||||
|
||||
@@ -14,8 +14,6 @@ from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import NamedTuple
|
||||
|
||||
import pikepdf
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Iterable
|
||||
@@ -43,6 +41,8 @@ def rotate_pdf(src: Path, dst: Path, degrees: int) -> None:
|
||||
Rotate every page relatively on the opened document, not a rebuild, so Info,
|
||||
XMP and outlines are kept. ``src`` is not modified.
|
||||
"""
|
||||
import pikepdf
|
||||
|
||||
with pikepdf.open(src) as pdf:
|
||||
for page in pdf.pages:
|
||||
page.rotate(degrees, relative=True)
|
||||
@@ -58,6 +58,8 @@ def remove_pages(src: Path, dst: Path, pages: Iterable[int]) -> None:
|
||||
Duplicates are ignored. Pages are removed highest first so earlier removals
|
||||
never shift the index of later ones.
|
||||
"""
|
||||
import pikepdf
|
||||
|
||||
unique = sorted(set(pages))
|
||||
_require_positive(unique)
|
||||
with pikepdf.open(src) as pdf:
|
||||
@@ -81,6 +83,8 @@ def build_pdfs(
|
||||
(Info, XMP, outlines) is not carried over. Returns the written paths in output
|
||||
order.
|
||||
"""
|
||||
import pikepdf
|
||||
|
||||
for specs, _ in outputs:
|
||||
_require_positive(spec.page for spec in specs)
|
||||
|
||||
@@ -140,6 +144,8 @@ def needs_decrypt(src: Path) -> bool:
|
||||
True if ``src`` is encrypted. A PDF that needs a password to open at all
|
||||
counts as encrypted.
|
||||
"""
|
||||
import pikepdf
|
||||
|
||||
try:
|
||||
with pikepdf.open(src) as pdf:
|
||||
return bool(pdf.is_encrypted)
|
||||
@@ -154,6 +160,8 @@ def decrypt_pdf(src: Path, make_dst: Callable[[], Path], password: str) -> Path:
|
||||
``make_dst`` is only called once the password has been accepted, so a wrong
|
||||
password never leaves a destination behind.
|
||||
"""
|
||||
import pikepdf
|
||||
|
||||
with pikepdf.open(src, password=password) as pdf:
|
||||
pdf.remove_unreferenced_resources()
|
||||
dst = make_dst()
|
||||
@@ -170,6 +178,8 @@ class PdfMerger:
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
import pikepdf
|
||||
|
||||
self._pdf = pikepdf.new()
|
||||
self._version: str = self._pdf.pdf_version
|
||||
|
||||
@@ -185,6 +195,8 @@ class PdfMerger:
|
||||
self._pdf.close()
|
||||
|
||||
def add(self, path: Path) -> None:
|
||||
import pikepdf
|
||||
|
||||
with pikepdf.open(str(path)) as pdf:
|
||||
self._version = max(self._version, pdf.pdf_version)
|
||||
self._pdf.pages.extend(pdf.pages)
|
||||
|
||||
@@ -7,8 +7,6 @@ from dataclasses import dataclass
|
||||
from types import TracebackType
|
||||
from typing import Self
|
||||
|
||||
import dateparser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -80,6 +78,8 @@ class DateParserPluginBase(ABC):
|
||||
|
||||
Uses configuration from `self.config`.
|
||||
"""
|
||||
import dateparser
|
||||
|
||||
try:
|
||||
return dateparser.parse(
|
||||
date_string,
|
||||
|
||||
@@ -476,13 +476,13 @@ def update_filename_and_move_files(
|
||||
return
|
||||
|
||||
with FileLock(settings.MEDIA_LOCK):
|
||||
try:
|
||||
# If this was waiting for the lock, the filename or archive_filename
|
||||
# of this document may have been updated. This happens if multiple updates
|
||||
# get queued from the UI for the same document
|
||||
# So freshen up the data before doing anything
|
||||
instance.refresh_from_db()
|
||||
# If this was waiting for the lock, the filename or archive_filename
|
||||
# of this document may have been updated. This happens if multiple updates
|
||||
# get queued from the UI for the same document
|
||||
# So freshen up the data before doing anything
|
||||
instance.refresh_from_db()
|
||||
|
||||
try:
|
||||
old_filename = instance.filename
|
||||
old_source_path = instance.source_path
|
||||
move_original = False
|
||||
|
||||
@@ -76,9 +76,6 @@ from paperless.logging import consume_task_id
|
||||
from paperless.parsers import ParserContext
|
||||
from paperless.parsers.registry import get_parser_registry
|
||||
from paperless_ai.exceptions import LLMTimeoutError
|
||||
from paperless_ai.indexing import llm_index_add_or_update_document
|
||||
from paperless_ai.indexing import llm_index_remove_document
|
||||
from paperless_ai.indexing import update_llm_index
|
||||
|
||||
if settings.AUDIT_LOG_ENABLED:
|
||||
from auditlog.models import LogEntry
|
||||
@@ -339,6 +336,8 @@ def bulk_update_documents(document_ids) -> None:
|
||||
|
||||
ai_config = AIConfig()
|
||||
if ai_config.llm_index_enabled:
|
||||
from paperless_ai.indexing import update_llm_index
|
||||
|
||||
update_llm_index(
|
||||
rebuild=False,
|
||||
document_ids=document_ids,
|
||||
@@ -499,6 +498,8 @@ def update_document_content_maybe_archive_file(
|
||||
|
||||
ai_config = AIConfig()
|
||||
if ai_config.llm_index_enabled:
|
||||
from paperless_ai.indexing import llm_index_add_or_update_document
|
||||
|
||||
llm_index_add_or_update_document(document)
|
||||
|
||||
clear_document_caches(document.pk)
|
||||
@@ -800,11 +801,15 @@ def apply_ai_suggestions(self, action_id: int, document_id: int) -> None:
|
||||
|
||||
@shared_task
|
||||
def update_document_in_llm_index(document) -> None:
|
||||
from paperless_ai.indexing import llm_index_add_or_update_document
|
||||
|
||||
llm_index_add_or_update_document(document)
|
||||
|
||||
|
||||
@shared_task
|
||||
def remove_document_from_llm_index(document) -> None:
|
||||
from paperless_ai.indexing import llm_index_remove_document
|
||||
|
||||
llm_index_remove_document(document)
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,10 @@ def localize_date(value: date | datetime | str, format: str, locale: str) -> str
|
||||
|
||||
def format_datetime(value: str | datetime, format: str) -> str:
|
||||
if isinstance(value, str):
|
||||
value = parse_date(value)
|
||||
parsed = parse_datetime(value) or parse_date(value)
|
||||
if parsed is None:
|
||||
raise ValueError(f"Invalid date or datetime string: {value!r}")
|
||||
return parsed.strftime(format=format)
|
||||
return value.strftime(format=format)
|
||||
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class TestParseString:
|
||||
):
|
||||
# We still need to mock dateparser.parse to force the exception
|
||||
mocker.patch(
|
||||
"documents.plugins.date_parsing.base.dateparser.parse",
|
||||
"dateparser.parse",
|
||||
side_effect=ValueError(
|
||||
"Parsing error: 01/01/2024",
|
||||
),
|
||||
@@ -260,7 +260,7 @@ class TestRegexDateParser:
|
||||
parser = RegexDateParserPlugin(base_config)
|
||||
|
||||
# Patch the dateparser.parse
|
||||
target = "documents.plugins.date_parsing.base.dateparser.parse"
|
||||
target = "dateparser.parse"
|
||||
|
||||
def fake_parse(
|
||||
date_string: str,
|
||||
@@ -335,7 +335,7 @@ class TestRegexDateParser:
|
||||
)
|
||||
parser = RegexDateParserPlugin(cfg)
|
||||
|
||||
target = "documents.plugins.date_parsing.base.dateparser.parse"
|
||||
target = "dateparser.parse"
|
||||
|
||||
def fake_parse(
|
||||
date_string: str,
|
||||
@@ -400,7 +400,7 @@ class TestRegexDateParser:
|
||||
parser = RegexDateParserPlugin(cfg)
|
||||
|
||||
# Patch the module's dateparser.parse so we can inspect calls
|
||||
target = "documents.plugins.date_parsing.base.dateparser.parse"
|
||||
target = "dateparser.parse"
|
||||
|
||||
def fake_parse(
|
||||
date_string: str,
|
||||
|
||||
@@ -1070,7 +1070,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
|
||||
|
||||
with (
|
||||
patch("documents.tasks.llmindex_index.apply_async") as mock_update,
|
||||
patch("paperless.views.llm_index_exists") as mock_exists,
|
||||
patch("paperless_ai.indexing.llm_index_exists") as mock_exists,
|
||||
):
|
||||
mock_exists.return_value = False
|
||||
self.client.patch(
|
||||
@@ -1095,7 +1095,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
|
||||
|
||||
with (
|
||||
patch("documents.tasks.llmindex_index.apply_async") as mock_update,
|
||||
patch("paperless.views.llm_index_exists", return_value=False),
|
||||
patch("paperless_ai.indexing.llm_index_exists", return_value=False),
|
||||
):
|
||||
self.client.patch(
|
||||
f"{self.ENDPOINT}1/",
|
||||
@@ -1115,7 +1115,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
|
||||
|
||||
with (
|
||||
patch("documents.tasks.llmindex_index.apply_async") as mock_update,
|
||||
patch("paperless.views.llm_index_exists") as mock_exists,
|
||||
patch("paperless_ai.indexing.llm_index_exists") as mock_exists,
|
||||
):
|
||||
mock_exists.return_value = True
|
||||
self.client.patch(
|
||||
@@ -1136,7 +1136,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
|
||||
|
||||
with (
|
||||
patch("documents.tasks.llmindex_index.apply_async") as mock_update,
|
||||
patch("paperless.views.llm_index_exists") as mock_exists,
|
||||
patch("paperless_ai.indexing.llm_index_exists") as mock_exists,
|
||||
):
|
||||
mock_exists.return_value = True
|
||||
self.client.patch(
|
||||
@@ -1174,7 +1174,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
|
||||
|
||||
with (
|
||||
patch("documents.tasks.llmindex_index.apply_async") as mock_update,
|
||||
patch("paperless.views.llm_index_exists") as mock_exists,
|
||||
patch("paperless_ai.indexing.llm_index_exists") as mock_exists,
|
||||
):
|
||||
mock_exists.return_value = True
|
||||
self.client.patch(
|
||||
|
||||
@@ -61,7 +61,7 @@ class TestChatStreamingViewInputValidation(APITestCase):
|
||||
return_value=self._mock_ai_enabled(),
|
||||
),
|
||||
mock.patch(
|
||||
"documents.views.stream_chat_with_documents",
|
||||
"paperless_ai.chat.stream_chat_with_documents",
|
||||
return_value=iter(chunks),
|
||||
),
|
||||
):
|
||||
@@ -104,7 +104,7 @@ class TestChatStreamingViewUnrestrictedFlag:
|
||||
"""
|
||||
mocker.patch("documents.views.AIConfig").return_value.ai_enabled = True
|
||||
return mocker.patch(
|
||||
"documents.views.stream_chat_with_documents",
|
||||
"paperless_ai.chat.stream_chat_with_documents",
|
||||
return_value=iter(()),
|
||||
)
|
||||
|
||||
|
||||
@@ -1110,7 +1110,7 @@ class TestVersionActionPermissions(DirectoriesMixin, APITestCase):
|
||||
self.assertEqual(response.status_code, 403)
|
||||
with (
|
||||
mock.patch("documents.views.AIConfig") as ai_config,
|
||||
mock.patch("documents.views.stream_chat_with_documents") as chat,
|
||||
mock.patch("paperless_ai.chat.stream_chat_with_documents") as chat,
|
||||
):
|
||||
ai_config.return_value.ai_enabled = True
|
||||
response = self.client.post(
|
||||
|
||||
@@ -2686,7 +2686,7 @@ class TestDocumentApi(DirectoriesMixin, ConsumeTaskMixin, APITestCase):
|
||||
response = self.client.get("/api/documents/34676/suggestions/")
|
||||
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
@mock.patch("documents.views.get_ai_document_classification")
|
||||
@mock.patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(AI_ENABLED=True)
|
||||
def test_suggestions_still_uses_classifier_when_ai_enabled(
|
||||
self,
|
||||
|
||||
@@ -308,3 +308,32 @@ class TestBulkDownloadSchema:
|
||||
def test_bulk_download_response_403(self, api_schema: SchemaGenerator) -> None:
|
||||
op = api_schema["paths"]["/api/documents/bulk_download/"]["post"]
|
||||
assert "403" in op["responses"]
|
||||
|
||||
|
||||
class TestDocumentListObjectFilterSchema:
|
||||
"""documents_list: comma-separated ObjectFilter params must be typed as integer arrays."""
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"param_name",
|
||||
[
|
||||
"tags__id__all",
|
||||
"tags__id__none",
|
||||
"tags__id__in",
|
||||
"correspondent__id__none",
|
||||
"document_type__id__none",
|
||||
"storage_path__id__none",
|
||||
"owner__id__none",
|
||||
"custom_fields__id__all",
|
||||
"custom_fields__id__none",
|
||||
"custom_fields__id__in",
|
||||
],
|
||||
)
|
||||
def test_object_filter_param_is_integer_array(
|
||||
self,
|
||||
api_schema: SchemaGenerator,
|
||||
param_name: str,
|
||||
) -> None:
|
||||
params = api_schema["paths"]["/api/documents/"]["get"]["parameters"]
|
||||
param = next(p for p in params if p["name"] == param_name)
|
||||
assert param["schema"] == {"type": "array", "items": {"type": "integer"}}
|
||||
assert param["explode"] is False
|
||||
@@ -539,3 +539,50 @@ class TestSystemStatus(APITestCase):
|
||||
self.assertEqual(response.data["tasks"]["summary"]["success_count"], 1)
|
||||
self.assertEqual(response.data["tasks"]["summary"]["failure_count"], 1)
|
||||
self.assertEqual(response.data["tasks"]["summary"]["pending_count"], 1)
|
||||
|
||||
def test_system_status_reports_database_error(self) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- Reading the migration state fails
|
||||
WHEN:
|
||||
- The system status is requested
|
||||
THEN:
|
||||
- The response reports the database error rather than a server error
|
||||
"""
|
||||
self.client.force_login(self.user)
|
||||
with mock.patch(
|
||||
"documents.views.MigrationLoader",
|
||||
side_effect=Exception("database is down"),
|
||||
):
|
||||
response = self.client.get(self.ENDPOINT)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
database = response.data["database"]
|
||||
self.assertEqual(database["status"], "ERROR")
|
||||
self.assertIsNotNone(database["error"])
|
||||
self.assertEqual(
|
||||
database["migration_status"],
|
||||
{"latest_migration": None, "unapplied_migrations": []},
|
||||
)
|
||||
|
||||
def test_system_status_migration_query_error(self) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- The migration graph loads but reading the applied migrations fails
|
||||
WHEN:
|
||||
- The system status is requested
|
||||
THEN:
|
||||
- No migrations are reported as unapplied, since the state is unknown
|
||||
"""
|
||||
self.client.force_login(self.user)
|
||||
with mock.patch("documents.views.MigrationRecorder") as recorder:
|
||||
recorder.Migration.objects.all.side_effect = Exception("query failed")
|
||||
response = self.client.get(self.ENDPOINT)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
database = response.data["database"]
|
||||
self.assertEqual(database["status"], "ERROR")
|
||||
self.assertEqual(
|
||||
database["migration_status"],
|
||||
{"latest_migration": None, "unapplied_migrations": []},
|
||||
)
|
||||
@@ -31,6 +31,7 @@ from documents.serialisers import DocumentSerializer
|
||||
from documents.tasks import empty_trash
|
||||
from paperless_testing.assertions import FileSystemAssertsMixin
|
||||
from paperless_testing.dirs import DirectoriesMixin
|
||||
from paperless_testing.dirs import PaperlessDirs
|
||||
from paperless_testing.factories import DocumentFactory
|
||||
from paperless_testing.factories import UserFactory
|
||||
|
||||
@@ -2134,3 +2135,28 @@ class TestPathDateLocalization:
|
||||
with override_settings(FILENAME_FORMAT=filename_format):
|
||||
filename = generate_filename(document)
|
||||
assert filename == Path(expected_filename)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_refresh_failure_surfaces_database_error(
|
||||
paperless_dirs: PaperlessDirs,
|
||||
) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- A document with a stored filename
|
||||
WHEN:
|
||||
- Saving it triggers a filename update and refreshing it from the database fails
|
||||
THEN:
|
||||
- The database error is raised, not an unbound variable error from the rollback
|
||||
"""
|
||||
document = DocumentFactory(filename="some.pdf")
|
||||
|
||||
with (
|
||||
mock.patch.object(
|
||||
Document,
|
||||
"refresh_from_db",
|
||||
side_effect=DatabaseError("database is locked"),
|
||||
),
|
||||
pytest.raises(DatabaseError, match="database is locked"),
|
||||
):
|
||||
document.save()
|
||||
@@ -4,6 +4,7 @@ from typing import Literal
|
||||
|
||||
import pytest
|
||||
|
||||
from documents.templating.filters import format_datetime
|
||||
from documents.templating.filters import localize_date
|
||||
|
||||
|
||||
@@ -294,3 +295,23 @@ class TestDateLocalization:
|
||||
Tests `localize_date` with `date` string across different locales and formats.
|
||||
"""
|
||||
assert localize_date(value, format_style, locale_str) == expected_output
|
||||
|
||||
|
||||
class TestFormatDatetime:
|
||||
@pytest.mark.parametrize(
|
||||
("value", "expected"),
|
||||
[
|
||||
pytest.param("2026-09-21", "2026-09-21 00:00", id="date"),
|
||||
pytest.param(
|
||||
"2026-09-21T13:45:00+00:00",
|
||||
"2026-09-21 13:45",
|
||||
id="datetime",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_parses_iso_strings(self, value: str, expected: str) -> None:
|
||||
assert format_datetime(value, "%Y-%m-%d %H:%M") == expected
|
||||
|
||||
def test_rejects_unparseable_string(self) -> None:
|
||||
with pytest.raises(ValueError, match="not a date"):
|
||||
format_datetime("not a date", "%Y")
|
||||
@@ -572,7 +572,7 @@ class TestAiChatAllDocumentsPermissionBoundary:
|
||||
ENDPOINT = "/api/documents/chat/"
|
||||
|
||||
@override_settings(AI_ENABLED=True)
|
||||
@patch("documents.views.stream_chat_with_documents")
|
||||
@patch("paperless_ai.chat.stream_chat_with_documents")
|
||||
def test_chat_all_documents_excludes_unshared_document(self, mock_stream_chat):
|
||||
mock_stream_chat.return_value = iter([b"data"])
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ class TestUpdateContent(DirectoriesMixin, TestCase):
|
||||
)
|
||||
|
||||
@override_settings(AI_ENABLED=True, LLM_EMBEDDING_BACKEND="huggingface")
|
||||
@mock.patch("documents.tasks.llm_index_add_or_update_document")
|
||||
@mock.patch("paperless_ai.indexing.llm_index_add_or_update_document")
|
||||
@mock.patch("documents.search.get_backend")
|
||||
def test_update_content_version_updates_llm_index(
|
||||
self,
|
||||
@@ -450,7 +450,7 @@ class TestAIIndex(DirectoriesMixin, TestCase):
|
||||
checksum="wow",
|
||||
)
|
||||
with mock.patch(
|
||||
"documents.tasks.llm_index_add_or_update_document",
|
||||
"paperless_ai.indexing.llm_index_add_or_update_document",
|
||||
) as llm_index_add_or_update_document:
|
||||
tasks.update_document_in_llm_index(doc)
|
||||
llm_index_add_or_update_document.assert_called_once_with(doc)
|
||||
@@ -470,7 +470,7 @@ class TestAIIndex(DirectoriesMixin, TestCase):
|
||||
checksum="wow",
|
||||
)
|
||||
with mock.patch(
|
||||
"documents.tasks.llm_index_remove_document",
|
||||
"paperless_ai.indexing.llm_index_remove_document",
|
||||
) as llm_index_remove_document:
|
||||
tasks.remove_document_from_llm_index(doc)
|
||||
llm_index_remove_document.assert_called_once_with(doc)
|
||||
@@ -495,7 +495,7 @@ class TestAIIndex(DirectoriesMixin, TestCase):
|
||||
"documents.tasks.update_document_in_llm_index",
|
||||
) as update_document_in_llm_index,
|
||||
mock.patch(
|
||||
"documents.tasks.update_llm_index",
|
||||
"paperless_ai.indexing.update_llm_index",
|
||||
) as update_llm_index,
|
||||
):
|
||||
doc_ids = [doc.pk for doc in docs]
|
||||
|
||||
@@ -474,7 +474,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(response.json()["tags"], [])
|
||||
self.assertEqual(response.json()["suggested_tags"], [])
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="mock_backend",
|
||||
@@ -524,7 +524,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
None,
|
||||
)
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="mock_backend",
|
||||
@@ -562,7 +562,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
"KI Title",
|
||||
)
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="mock_backend",
|
||||
@@ -601,7 +601,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
"Titre IA",
|
||||
)
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="mock_backend",
|
||||
@@ -637,7 +637,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
),
|
||||
)
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="mock_backend",
|
||||
@@ -709,7 +709,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
),
|
||||
)
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="openai-like",
|
||||
@@ -738,7 +738,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
get_llm_suggestion_cache(self.document.pk, backend="openai-like"),
|
||||
)
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="openai-like",
|
||||
@@ -765,7 +765,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
get_llm_suggestion_cache(self.document.pk, backend="openai-like"),
|
||||
)
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="openai-like",
|
||||
@@ -797,7 +797,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
get_llm_suggestion_cache(self.document.pk, backend="openai-like"),
|
||||
)
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="mock_backend",
|
||||
@@ -835,7 +835,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(response.json()["tags"], [self.tag1.pk])
|
||||
self.assertEqual(response.json()["suggested_tags"], ["Follow-up"])
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="mock_backend",
|
||||
@@ -874,7 +874,7 @@ class TestAISuggestions(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(response.json()["tags"], [self.tag1.pk])
|
||||
self.assertEqual(response.json()["suggested_tags"], [])
|
||||
|
||||
@patch("documents.views.get_ai_document_classification")
|
||||
@patch("paperless_ai.ai_classifier.get_ai_document_classification")
|
||||
@override_settings(
|
||||
AI_ENABLED=True,
|
||||
LLM_BACKEND="mock_backend",
|
||||
@@ -996,7 +996,7 @@ class TestAIChatStreamingView(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertIn(b"AI is required for this feature", response.content)
|
||||
|
||||
@patch("documents.views.stream_chat_with_documents")
|
||||
@patch("paperless_ai.chat.stream_chat_with_documents")
|
||||
@patch("documents.views.permitted_document_ids")
|
||||
@override_settings(AI_ENABLED=True)
|
||||
def test_post_no_document_id(self, mock_permitted_ids, mock_stream_chat) -> None:
|
||||
@@ -1016,7 +1016,7 @@ class TestAIChatStreamingView(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(list(call_kwargs["documents"]), [self.document])
|
||||
self.assertIsNone(call_kwargs["output_language"])
|
||||
|
||||
@patch("documents.views.stream_chat_with_documents")
|
||||
@patch("paperless_ai.chat.stream_chat_with_documents")
|
||||
@patch("documents.views.permitted_document_ids")
|
||||
@override_settings(AI_ENABLED=True)
|
||||
def test_post_uses_user_display_language(
|
||||
@@ -1042,7 +1042,7 @@ class TestAIChatStreamingView(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(list(call_kwargs["documents"]), [self.document])
|
||||
self.assertEqual(call_kwargs["output_language"], "de-de")
|
||||
|
||||
@patch("documents.views.stream_chat_with_documents")
|
||||
@patch("paperless_ai.chat.stream_chat_with_documents")
|
||||
@override_settings(AI_ENABLED=True)
|
||||
def test_post_with_document_id(self, mock_stream_chat) -> None:
|
||||
self.grant_view_document_permission()
|
||||
@@ -1079,7 +1079,7 @@ class TestAIChatStreamingView(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(response.status_code, 403)
|
||||
self.assertIn(b"Insufficient permissions", response.content)
|
||||
|
||||
@patch("documents.views.stream_chat_with_documents")
|
||||
@patch("paperless_ai.chat.stream_chat_with_documents")
|
||||
@override_settings(AI_ENABLED=True)
|
||||
def test_post_no_document_id_requires_view_document_permission(
|
||||
self,
|
||||
@@ -1093,7 +1093,7 @@ class TestAIChatStreamingView(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(response.status_code, 403)
|
||||
mock_stream_chat.assert_not_called()
|
||||
|
||||
@patch("documents.views.stream_chat_with_documents")
|
||||
@patch("paperless_ai.chat.stream_chat_with_documents")
|
||||
@override_settings(AI_ENABLED=True)
|
||||
def test_post_with_document_id_requires_view_document_permission(
|
||||
self,
|
||||
|
||||
+36
-28
@@ -250,20 +250,8 @@ from paperless.parsers.remote import RemoteEngineConfig
|
||||
from paperless.serialisers import GroupSerializer
|
||||
from paperless.serialisers import UserSerializer
|
||||
from paperless.views import StandardPagination
|
||||
from paperless_ai.ai_classifier import get_ai_document_classification
|
||||
from paperless_ai.ai_classifier import get_llm_output_language
|
||||
from paperless_ai.chat import stream_chat_with_documents
|
||||
from paperless_ai.exceptions import LLMProviderError
|
||||
from paperless_ai.exceptions import LLMTimeoutError
|
||||
from paperless_ai.matching import extract_unmatched_names
|
||||
from paperless_ai.matching import match_correspondents_by_name
|
||||
from paperless_ai.matching import match_document_types_by_name
|
||||
from paperless_ai.matching import match_storage_paths_by_name
|
||||
from paperless_ai.matching import match_tags_by_name
|
||||
from paperless_ai.matching import resolve_correspondent_ids
|
||||
from paperless_ai.matching import resolve_document_type_ids
|
||||
from paperless_ai.matching import resolve_storage_path_ids
|
||||
from paperless_ai.matching import resolve_tag_ids
|
||||
from paperless_mail.models import MailAccount
|
||||
from paperless_mail.models import MailRule
|
||||
from paperless_mail.oauth import PaperlessMailOAuth2Manager
|
||||
@@ -699,19 +687,6 @@ class EmailDocumentDetailSchema(EmailSerializer):
|
||||
|
||||
|
||||
@extend_schema_view(
|
||||
list=extend_schema(
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name=name,
|
||||
type=OpenApiTypes.INT,
|
||||
many=True,
|
||||
style="form",
|
||||
explode=False,
|
||||
)
|
||||
for name, field in DocumentFilterSet.base_filters.items()
|
||||
if isinstance(field, ObjectFilter)
|
||||
],
|
||||
),
|
||||
retrieve=extend_schema(
|
||||
description="Retrieve a single document",
|
||||
responses={
|
||||
@@ -1613,6 +1588,18 @@ class DocumentViewSet(
|
||||
if not ai_config.ai_enabled:
|
||||
return HttpResponseBadRequest("AI is required for this feature")
|
||||
|
||||
from paperless_ai.ai_classifier import get_ai_document_classification
|
||||
from paperless_ai.ai_classifier import get_llm_output_language
|
||||
from paperless_ai.matching import extract_unmatched_names
|
||||
from paperless_ai.matching import match_correspondents_by_name
|
||||
from paperless_ai.matching import match_document_types_by_name
|
||||
from paperless_ai.matching import match_storage_paths_by_name
|
||||
from paperless_ai.matching import match_tags_by_name
|
||||
from paperless_ai.matching import resolve_correspondent_ids
|
||||
from paperless_ai.matching import resolve_document_type_ids
|
||||
from paperless_ai.matching import resolve_storage_path_ids
|
||||
from paperless_ai.matching import resolve_tag_ids
|
||||
|
||||
output_language = get_llm_output_language(
|
||||
ai_config=ai_config,
|
||||
user=request.user,
|
||||
@@ -2446,6 +2433,9 @@ class ChatStreamingView(GenericAPIView[Any]):
|
||||
)
|
||||
unrestricted = user_is_unrestricted(request.user)
|
||||
|
||||
from paperless_ai.ai_classifier import get_llm_output_language
|
||||
from paperless_ai.chat import stream_chat_with_documents
|
||||
|
||||
output_language = get_llm_output_language(
|
||||
ai_config=ai_config,
|
||||
user=request.user,
|
||||
@@ -2467,6 +2457,17 @@ class ChatStreamingView(GenericAPIView[Any]):
|
||||
list=extend_schema(
|
||||
description="Document views including search",
|
||||
parameters=[
|
||||
*(
|
||||
OpenApiParameter(
|
||||
name=name,
|
||||
type=OpenApiTypes.INT,
|
||||
many=True,
|
||||
style="form",
|
||||
explode=False,
|
||||
)
|
||||
for name, field in DocumentFilterSet.base_filters.items()
|
||||
if isinstance(field, ObjectFilter)
|
||||
),
|
||||
OpenApiParameter(
|
||||
name="text",
|
||||
type=OpenApiTypes.STR,
|
||||
@@ -5267,7 +5268,9 @@ class CustomFieldViewSet(PermissionsAwareDocumentCountMixin, ModelViewSet[Custom
|
||||
"migration_status": inline_serializer(
|
||||
name="MigrationStatus",
|
||||
fields={
|
||||
"latest_migration": serializers.CharField(),
|
||||
"latest_migration": serializers.CharField(
|
||||
allow_null=True,
|
||||
),
|
||||
"unapplied_migrations": serializers.ListSerializer(
|
||||
child=serializers.CharField(),
|
||||
),
|
||||
@@ -5342,6 +5345,8 @@ class SystemStatusView(PassUserMixin):
|
||||
db_conn = connections["default"]
|
||||
db_url = str(db_conn.settings_dict["NAME"])
|
||||
db_error = None
|
||||
all_migrations: list[str] = []
|
||||
applied_migrations: list[str] = []
|
||||
|
||||
try:
|
||||
db_conn.ensure_connection()
|
||||
@@ -5352,7 +5357,8 @@ class SystemStatusView(PassUserMixin):
|
||||
f"{m.app}.{m.name}"
|
||||
for m in MigrationRecorder.Migration.objects.all().order_by("id")
|
||||
]
|
||||
except Exception as e: # pragma: no cover
|
||||
except Exception as e:
|
||||
all_migrations = []
|
||||
applied_migrations = []
|
||||
db_status = "ERROR"
|
||||
logger.exception(
|
||||
@@ -5548,7 +5554,9 @@ class SystemStatusView(PassUserMixin):
|
||||
"status": db_status,
|
||||
"error": db_error,
|
||||
"migration_status": {
|
||||
"latest_migration": applied_migrations[-1],
|
||||
"latest_migration": (
|
||||
applied_migrations[-1] if applied_migrations else None
|
||||
),
|
||||
"unapplied_migrations": [
|
||||
m for m in all_migrations if m not in applied_migrations
|
||||
],
|
||||
|
||||
Loaded 100 of 165 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user