mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-09-04 08:55:04 +00:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee19e8dcff | ||
|
|
b9cf877029 | ||
|
|
82cc1016ad | ||
|
|
dcedb531c6 | ||
|
|
8bedb07cea | ||
|
|
5e34d566a2 | ||
|
|
601ecce3f1 | ||
|
|
d67beba9f6 | ||
|
|
3bc8ee8425 | ||
|
|
fdef4a99a7 | ||
|
|
d16d05a391 | ||
|
|
10789e63cb | ||
|
|
2197781b39 | ||
|
|
981492bb33 | ||
|
|
0ef5ef5826 | ||
|
|
a6b1763149 | ||
|
|
90531525e2 | ||
|
|
8f00bfa931 | ||
|
|
a0479f1d9b | ||
|
|
9b8bd21044 | ||
|
|
a60172bc6f | ||
|
|
6c5bc1c0ff | ||
|
|
f4a7c478a9 | ||
|
|
bc07c19d9b | ||
|
|
bfcee24572 | ||
|
|
4fec4b0948 | ||
|
|
3e4ffc4132 | ||
|
|
6d61bcee7e |
@@ -38,6 +38,7 @@ body:
|
|||||||
label: Installation method
|
label: Installation method
|
||||||
options:
|
options:
|
||||||
- Docker - official image
|
- Docker - official image
|
||||||
|
- Docker - linuxserver.io image
|
||||||
- Bare metal
|
- Bare metal
|
||||||
- Other (please describe above)
|
- Other (please describe above)
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
@@ -87,8 +87,10 @@ body:
|
|||||||
label: Installation method
|
label: Installation method
|
||||||
options:
|
options:
|
||||||
- Docker - official image
|
- Docker - official image
|
||||||
|
- Docker - linuxserver.io image
|
||||||
- Bare metal
|
- Bare metal
|
||||||
- Other (please describe above)
|
- Other (please describe above)
|
||||||
|
description: Note there are significant differences from the official image and linuxserver.io, please check if your issue is specific to the third-party image.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ services:
|
|||||||
network_mode: host
|
network_mode: host
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
greenmail:
|
greenmail:
|
||||||
image: docker.io/greenmail/standalone:2.1.13
|
image: docker.io/greenmail/standalone:2.1.11
|
||||||
hostname: greenmail
|
hostname: greenmail
|
||||||
container_name: greenmail
|
container_name: greenmail
|
||||||
environment:
|
environment:
|
||||||
@@ -35,7 +35,7 @@ services:
|
|||||||
- "3143:3143" # IMAP
|
- "3143:3143" # IMAP
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
nginx:
|
nginx:
|
||||||
image: docker.io/nginx:1.31.5-alpine
|
image: docker.io/nginx:1.31.3-alpine
|
||||||
hostname: nginx
|
hostname: nginx
|
||||||
container_name: nginx
|
container_name: nginx
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ def replace_with_symlinks(
|
|||||||
total_duplicates = 0
|
total_duplicates = 0
|
||||||
space_saved = 0
|
space_saved = 0
|
||||||
|
|
||||||
for file_hash, file_list in duplicate_groups.items():
|
for file_list in duplicate_groups.values():
|
||||||
# Keep the first file as the original, replace others with symlinks
|
# Keep the first file as the original, replace others with symlinks
|
||||||
original_file = file_list[0]
|
original_file = file_list[0]
|
||||||
duplicates = file_list[1:]
|
duplicates = file_list[1:]
|
||||||
|
|||||||
+101
-48
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "paperless-ngx"
|
name = "paperless-ngx"
|
||||||
version = "3.1.3"
|
version = "3.1.2"
|
||||||
description = "A community-supported supercharged document management system: scan, index and archive all your physical documents"
|
description = "A community-supported supercharged document management system: scan, index and archive all your physical documents"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
@@ -186,68 +186,121 @@ line-ending = "lf"
|
|||||||
# https://docs.astral.sh/ruff/rules/
|
# https://docs.astral.sh/ruff/rules/
|
||||||
select = [ "E4", "E7", "E9", "F" ]
|
select = [ "E4", "E7", "E9", "F" ]
|
||||||
extend-select = [
|
extend-select = [
|
||||||
"COM", # https://docs.astral.sh/ruff/rules/#flake8-commas-com
|
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
|
||||||
"DJ", # https://docs.astral.sh/ruff/rules/#flake8-django-dj
|
"B002", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
|
||||||
"EXE", # https://docs.astral.sh/ruff/rules/#flake8-executable-exe
|
"B003",
|
||||||
"FBT", # https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
|
"B004",
|
||||||
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
|
"B005",
|
||||||
"G201", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
|
"B006",
|
||||||
"I", # https://docs.astral.sh/ruff/rules/#isort-i
|
"B008",
|
||||||
"ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn
|
"B009",
|
||||||
"INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp
|
"B010",
|
||||||
"ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
|
"B012",
|
||||||
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
|
"B013",
|
||||||
"PLC", # https://docs.astral.sh/ruff/rules/#pylint-pl
|
"B014",
|
||||||
"PLE", # https://docs.astral.sh/ruff/rules/#pylint-pl
|
"B015",
|
||||||
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
|
"B016",
|
||||||
"Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q
|
"B017",
|
||||||
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
|
"B018",
|
||||||
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
|
"B019",
|
||||||
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
|
"B020",
|
||||||
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
|
"B021",
|
||||||
"TC", # https://docs.astral.sh/ruff/rules/#flake8-type-checking-tc
|
"B022",
|
||||||
"TID", # https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid
|
"B023",
|
||||||
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
|
"B025",
|
||||||
"W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
|
"B026",
|
||||||
|
"B029",
|
||||||
|
"B030",
|
||||||
|
"B031",
|
||||||
|
"B032",
|
||||||
|
"B033",
|
||||||
|
"B035",
|
||||||
|
"B039",
|
||||||
|
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
|
||||||
|
"COM", # https://docs.astral.sh/ruff/rules/#flake8-commas-com
|
||||||
|
"D419", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
|
||||||
|
"DJ", # https://docs.astral.sh/ruff/rules/#flake8-django-dj
|
||||||
|
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
|
||||||
|
"EXE", # https://docs.astral.sh/ruff/rules/#flake8-executable-exe
|
||||||
|
"FA", # https://docs.astral.sh/ruff/rules/#flake8-future-annotations-fa
|
||||||
|
"FBT", # https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
|
||||||
|
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
|
||||||
|
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
|
||||||
|
"G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
|
||||||
|
"I", # https://docs.astral.sh/ruff/rules/#isort-i
|
||||||
|
"ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn
|
||||||
|
"INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp
|
||||||
|
"INT", # https://docs.astral.sh/ruff/rules/#flake8-gettext-int
|
||||||
|
"ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
|
||||||
|
"LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log
|
||||||
|
"N999", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
|
||||||
|
"PERF101", # https://docs.astral.sh/ruff/rules/#perflint-perf
|
||||||
|
"PERF102",
|
||||||
|
"PERF402",
|
||||||
|
"PGH005", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
|
||||||
|
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
|
||||||
|
"PLC", # https://docs.astral.sh/ruff/rules/#pylint-pl
|
||||||
|
"PLE", # https://docs.astral.sh/ruff/rules/#error-ple
|
||||||
|
"PLR0124", # https://docs.astral.sh/ruff/rules/#refactor-plr
|
||||||
|
"PLR0133",
|
||||||
|
"PLR0206",
|
||||||
|
"PLR0402",
|
||||||
|
"PLR1704",
|
||||||
|
"PLR1708",
|
||||||
|
"PLR1711",
|
||||||
|
"PLR1716",
|
||||||
|
"PLR1722",
|
||||||
|
"PLR1730",
|
||||||
|
"PLR1733",
|
||||||
|
"PLR1736",
|
||||||
|
"PLR2044",
|
||||||
|
"PLW", # https://docs.astral.sh/ruff/rules/#warning-plw
|
||||||
|
"PT010", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
|
||||||
|
"PT014",
|
||||||
|
"PT020",
|
||||||
|
"PT025",
|
||||||
|
"PT026",
|
||||||
|
"PT031",
|
||||||
|
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
|
||||||
|
"Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q
|
||||||
|
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
|
||||||
|
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
|
||||||
|
"S102", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
|
||||||
|
"S110",
|
||||||
|
"S112",
|
||||||
|
"S113",
|
||||||
|
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
|
||||||
|
"T100", # https://docs.astral.sh/ruff/rules/#flake8-debugger-t10
|
||||||
|
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
|
||||||
|
"TC", # https://docs.astral.sh/ruff/rules/#flake8-type-checking-tc
|
||||||
|
"TID", # https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid
|
||||||
|
"TRY002", # https://docs.astral.sh/ruff/rules/#tryceratops-try
|
||||||
|
"TRY004",
|
||||||
|
"TRY201",
|
||||||
|
"TRY203",
|
||||||
|
"TRY401",
|
||||||
|
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
|
||||||
|
"W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
|
||||||
|
"YTT", # https://docs.astral.sh/ruff/rules/#flake8-2020-ytt
|
||||||
]
|
]
|
||||||
ignore = [
|
ignore = [
|
||||||
"DJ001",
|
"DJ001",
|
||||||
"PLC0415",
|
"PLC0415",
|
||||||
"RUF012",
|
"RUF012",
|
||||||
"SIM105",
|
"SIM105",
|
||||||
|
"G004", # Logging statement uses f-string - good to do, but a large diff
|
||||||
]
|
]
|
||||||
# Migrations
|
# Migrations
|
||||||
per-file-ignores."*/migrations/*.py" = [
|
per-file-ignores."*/migrations/*.py" = []
|
||||||
"E501",
|
|
||||||
"SIM",
|
|
||||||
"T201",
|
|
||||||
]
|
|
||||||
# Testing
|
# Testing
|
||||||
per-file-ignores."*/tests/*.py" = [
|
per-file-ignores."*/tests/*.py" = [
|
||||||
"E501",
|
"DTZ",
|
||||||
"SIM117",
|
"SIM117",
|
||||||
]
|
]
|
||||||
per-file-ignores.".github/scripts/*.py" = [
|
|
||||||
"E501",
|
|
||||||
"INP001",
|
|
||||||
"SIM117",
|
|
||||||
]
|
|
||||||
# Docker specific
|
|
||||||
per-file-ignores."docker/rootfs/usr/local/bin/wait-for-redis.py" = [
|
|
||||||
"INP001",
|
|
||||||
"T201",
|
|
||||||
]
|
|
||||||
per-file-ignores."docker/wait-for-redis.py" = [
|
|
||||||
"INP001",
|
|
||||||
"T201",
|
|
||||||
]
|
|
||||||
per-file-ignores."src/documents/models.py" = [
|
|
||||||
"SIM115",
|
|
||||||
]
|
|
||||||
isort.force-single-line = true
|
isort.force-single-line = true
|
||||||
|
|
||||||
[tool.codespell]
|
[tool.codespell]
|
||||||
ignore-words-list = "criterias,afterall,valeu,ureue,equest,ure,assertIn,Oktober,commitish,NIN,nin"
|
ignore-words-list = "criterias,afterall,valeu,ureue,equest,ure,assertIn,Oktober,commitish"
|
||||||
skip = """\
|
skip = """\
|
||||||
src-ui/src/locale/*,src-ui/pnpm-lock.yaml,src-ui/e2e/*,src/paperless_mail/tests/samples/*,src/paperless/tests/samples\
|
src-ui/src/locale/*,src-ui/pnpm-lock.yaml,src-ui/e2e/*,src/paperless_mail/tests/samples/*,src/paperless/tests/samples\
|
||||||
/mail/*,src/documents/tests/samples/*,*.po,*.json\
|
/mail/*,src/documents/tests/samples/*,*.po,*.json\
|
||||||
|
|||||||
+205
-201
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "paperless-ngx-ui",
|
"name": "paperless-ngx-ui",
|
||||||
"version": "3.1.3",
|
"version": "3.1.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
@@ -15,14 +15,14 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/cdk": "^22.1.4",
|
"@angular/cdk": "^22.1.1",
|
||||||
"@angular/common": "~22.1.3",
|
"@angular/common": "~22.1.1",
|
||||||
"@angular/compiler": "~22.1.3",
|
"@angular/compiler": "~22.1.1",
|
||||||
"@angular/core": "~22.1.3",
|
"@angular/core": "~22.1.1",
|
||||||
"@angular/forms": "~22.1.3",
|
"@angular/forms": "~22.1.1",
|
||||||
"@angular/localize": "~22.1.3",
|
"@angular/localize": "~22.1.1",
|
||||||
"@angular/platform-browser": "~22.1.3",
|
"@angular/platform-browser": "~22.1.1",
|
||||||
"@angular/router": "~22.1.3",
|
"@angular/router": "~22.1.1",
|
||||||
"@ng-bootstrap/ng-bootstrap": "^21.0.0",
|
"@ng-bootstrap/ng-bootstrap": "^21.0.0",
|
||||||
"@ng-select/ng-select": "~23.6.0",
|
"@ng-select/ng-select": "~23.6.0",
|
||||||
"@ngneat/dirty-check-forms": "^3.0.3",
|
"@ngneat/dirty-check-forms": "^3.0.3",
|
||||||
@@ -45,16 +45,16 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-builders/jest": "^22.0.1",
|
"@angular-builders/jest": "^22.0.1",
|
||||||
"@angular-devkit/core": "^22.1.6",
|
"@angular-devkit/core": "^22.1.3",
|
||||||
"@angular-devkit/schematics": "^22.1.6",
|
"@angular-devkit/schematics": "^22.1.3",
|
||||||
"@angular-eslint/builder": "22.1.0",
|
"@angular-eslint/builder": "22.1.0",
|
||||||
"@angular-eslint/eslint-plugin": "22.1.0",
|
"@angular-eslint/eslint-plugin": "22.1.0",
|
||||||
"@angular-eslint/eslint-plugin-template": "22.1.0",
|
"@angular-eslint/eslint-plugin-template": "22.1.0",
|
||||||
"@angular-eslint/schematics": "22.1.0",
|
"@angular-eslint/schematics": "22.1.0",
|
||||||
"@angular-eslint/template-parser": "22.1.0",
|
"@angular-eslint/template-parser": "22.1.0",
|
||||||
"@angular/build": "22.1.6",
|
"@angular/build": "22.1.3",
|
||||||
"@angular/cli": "22.1.6",
|
"@angular/cli": "22.1.3",
|
||||||
"@angular/compiler-cli": "~22.1.3",
|
"@angular/compiler-cli": "~22.1.1",
|
||||||
"@playwright/test": "^1.62.1",
|
"@playwright/test": "^1.62.1",
|
||||||
"@types/jest": "^30.0.0",
|
"@types/jest": "^30.0.0",
|
||||||
"@types/node": "^26.2.0",
|
"@types/node": "^26.2.0",
|
||||||
|
|||||||
Generated
+629
-437
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@
|
|||||||
i18n-title
|
i18n-title
|
||||||
info="Tasks shows detailed information about document consumption and system tasks."
|
info="Tasks shows detailed information about document consumption and system tasks."
|
||||||
i18n-info
|
i18n-info
|
||||||
[loading]="loading() && pagedTasks().length === 0"
|
|
||||||
>
|
>
|
||||||
<div class="btn-toolbar col col-md-auto align-items-center gap-2">
|
<div class="btn-toolbar col col-md-auto align-items-center gap-2">
|
||||||
<button class="btn btn-sm btn-outline-secondary me-2" (click)="clearSelection()" [hidden]="selectedTasks.size === 0">
|
<button class="btn btn-sm btn-outline-secondary me-2" (click)="clearSelection()" [hidden]="selectedTasks.size === 0">
|
||||||
@@ -22,6 +21,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</pngx-page-header>
|
</pngx-page-header>
|
||||||
|
|
||||||
|
@if (loading() && pagedTasks().length === 0) {
|
||||||
|
<div class="spinner-border spinner-border-sm fw-normal ms-2 me-auto" role="status"></div>
|
||||||
|
<div class="visually-hidden" i18n>Loading...</div>
|
||||||
|
}
|
||||||
|
|
||||||
<div class="task-controls mb-3 gap-3 btn-toolbar align-items-center" role="toolbar">
|
<div class="task-controls mb-3 gap-3 btn-toolbar align-items-center" role="toolbar">
|
||||||
<div class="task-view-scope btn-group btn-group-sm" role="group">
|
<div class="task-view-scope btn-group btn-group-sm" role="group">
|
||||||
<input
|
<input
|
||||||
@@ -281,6 +285,6 @@
|
|||||||
<ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks: tasksForSection(section), section: section}"></ng-container>
|
<ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks: tasksForSection(section), section: section}"></ng-container>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
} @else if (!loading() || pagedTasks().length > 0) {
|
} @else {
|
||||||
<div class="alert alert-secondary fst-italic" i18n>No tasks match the current filters.</div>
|
<div class="alert alert-secondary fst-italic" i18n>No tasks match the current filters.</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ export class TrashComponent
|
|||||||
private modalService = inject(NgbModal)
|
private modalService = inject(NgbModal)
|
||||||
private settingsService = inject(SettingsService)
|
private settingsService = inject(SettingsService)
|
||||||
private router = inject(Router)
|
private router = inject(Router)
|
||||||
private readonly emptyTrashDelaySetting =
|
|
||||||
this.settingsService.getSignal<number>(SETTINGS_KEYS.EMPTY_TRASH_DELAY)
|
|
||||||
|
|
||||||
readonly documentsInTrash = signal<Document[]>([])
|
readonly documentsInTrash = signal<Document[]>([])
|
||||||
readonly selectedDocuments = signal<Set<number>>(new Set())
|
readonly selectedDocuments = signal<Set<number>>(new Set())
|
||||||
@@ -202,7 +200,8 @@ export class TrashComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
getDaysRemaining(document: Document): number {
|
getDaysRemaining(document: Document): number {
|
||||||
const delay = this.emptyTrashDelaySetting()
|
this.settingsService.trackChanges()
|
||||||
|
const delay = this.settingsService.get(SETTINGS_KEYS.EMPTY_TRASH_DELAY)
|
||||||
const diff = new Date().getTime() - new Date(document.deleted_at).getTime()
|
const diff = new Date().getTime() - new Date(document.deleted_at).getTime()
|
||||||
const days = Math.ceil(diff / (1000 * 3600 * 24))
|
const days = Math.ceil(diff / (1000 * 3600 * 24))
|
||||||
return delay - days
|
return delay - days
|
||||||
|
|||||||
@@ -34,7 +34,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
--pngx-sidebar-width: var(--pngx-sidebar-expanded-width);
|
&.expanded {
|
||||||
|
--pngx-sidebar-width: var(--pngx-sidebar-expanded-width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (max-width: 767.98px) {
|
@media (max-width: 767.98px) {
|
||||||
@@ -111,13 +113,6 @@ main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only animate when the user toggles slim mode
|
|
||||||
.sidebar:not(.animating),
|
|
||||||
.sidebar:not(.animating) ~ main,
|
|
||||||
.sidebar:not(.animating) .sidebar-slim-toggler {
|
|
||||||
transition: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar.slim {
|
.sidebar.slim {
|
||||||
max-width: 55px;
|
max-width: 55px;
|
||||||
|
|
||||||
@@ -128,6 +123,8 @@ main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sidebar.slim:not(.animating) {
|
.sidebar.slim:not(.animating) {
|
||||||
|
transition: none;
|
||||||
|
|
||||||
li.nav-item span,
|
li.nav-item span,
|
||||||
.sidebar-heading span {
|
.sidebar-heading span {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -147,6 +144,10 @@ main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar.slim:not(.animating) ~ main.col-slim {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar.animating {
|
.sidebar.animating {
|
||||||
li.nav-item span,
|
li.nav-item span,
|
||||||
.sidebar-heading span {
|
.sidebar-heading span {
|
||||||
@@ -195,26 +196,6 @@ main {
|
|||||||
--bs-popover-body-padding-y: .5rem;
|
--bs-popover-body-padding-y: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) {
|
|
||||||
.sidebar-sticky > ul,
|
|
||||||
.sidebar-sticky > .nav-group {
|
|
||||||
animation: sidebar-nav-in .3s cubic-bezier(.22, .61, .36, 1) backwards;
|
|
||||||
}
|
|
||||||
|
|
||||||
@for $i from 2 through 5 {
|
|
||||||
.sidebar-sticky > :nth-child(#{$i}) {
|
|
||||||
animation-delay: #{($i - 1) * 0.04}s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes sidebar-nav-in {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(6px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar-sticky {
|
.sidebar-sticky {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
@@ -193,23 +193,6 @@ describe('AppFrameComponent', () => {
|
|||||||
expect(savedViewSpy).toHaveBeenCalled()
|
expect(savedViewSpy).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should update reinitialized signal-backed settings without manual change detection', async () => {
|
|
||||||
settingsService.initializeSettings().subscribe()
|
|
||||||
httpTestingController
|
|
||||||
.expectOne(`${environment.apiBaseUrl}ui_settings/`)
|
|
||||||
.flush({
|
|
||||||
settings: { app_title: 'Reactive title' },
|
|
||||||
user: {},
|
|
||||||
permissions: [],
|
|
||||||
})
|
|
||||||
|
|
||||||
await fixture.whenStable()
|
|
||||||
|
|
||||||
expect(
|
|
||||||
fixture.nativeElement.querySelector('.brand-title').textContent
|
|
||||||
).toBe('Reactive title')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should check for update if enabled', () => {
|
it('should check for update if enabled', () => {
|
||||||
const updateCheckSpy = jest.spyOn(remoteVersionService, 'checkForUpdates')
|
const updateCheckSpy = jest.spyOn(remoteVersionService, 'checkForUpdates')
|
||||||
updateCheckSpy.mockImplementation(() => {
|
updateCheckSpy.mockImplementation(() => {
|
||||||
|
|||||||
@@ -98,29 +98,6 @@ export class AppFrameComponent
|
|||||||
readonly isMenuCollapsed = signal(true)
|
readonly isMenuCollapsed = signal(true)
|
||||||
readonly slimSidebarAnimating = signal(false)
|
readonly slimSidebarAnimating = signal(false)
|
||||||
readonly mobileSearchHidden = signal(false)
|
readonly mobileSearchHidden = signal(false)
|
||||||
private readonly versionSetting = this.settingsService.getSignal<string>(
|
|
||||||
SETTINGS_KEYS.VERSION
|
|
||||||
)
|
|
||||||
private readonly appTitleSetting = this.settingsService.getSignal<string>(
|
|
||||||
SETTINGS_KEYS.APP_TITLE
|
|
||||||
)
|
|
||||||
private readonly appLogoSetting = this.settingsService.getSignal<string>(
|
|
||||||
SETTINGS_KEYS.APP_LOGO
|
|
||||||
)
|
|
||||||
private readonly slimSidebarSetting = this.settingsService.getSignal<boolean>(
|
|
||||||
SETTINGS_KEYS.SLIM_SIDEBAR
|
|
||||||
)
|
|
||||||
private readonly attributesSectionsCollapsedSetting =
|
|
||||||
this.settingsService.getSignal<CollapsibleSection[]>(
|
|
||||||
SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED
|
|
||||||
)
|
|
||||||
private readonly aiEnabledSetting = this.settingsService.getSignal<boolean>(
|
|
||||||
SETTINGS_KEYS.AI_ENABLED
|
|
||||||
)
|
|
||||||
private readonly sidebarViewsShowCountSetting =
|
|
||||||
this.settingsService.getSignal<boolean>(
|
|
||||||
SETTINGS_KEYS.SIDEBAR_VIEWS_SHOW_COUNT
|
|
||||||
)
|
|
||||||
private lastScrollY: number = 0
|
private lastScrollY: number = 0
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -214,23 +191,33 @@ export class AppFrameComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get versionString(): string {
|
get versionString(): string {
|
||||||
return `${environment.appTitle} v${this.versionSetting()}${environment.tag === 'prod' ? '' : ` #${environment.tag}`}`
|
this.settingsService.trackChanges()
|
||||||
|
return `${environment.appTitle} v${this.settingsService.get(SETTINGS_KEYS.VERSION)}${environment.tag === 'prod' ? '' : ` #${environment.tag}`}`
|
||||||
}
|
}
|
||||||
|
|
||||||
get appTitle(): string {
|
get appTitle(): string {
|
||||||
return this.appTitleSetting() || environment.appTitle
|
this.settingsService.trackChanges()
|
||||||
|
return (
|
||||||
|
this.settingsService.get(SETTINGS_KEYS.APP_TITLE) || environment.appTitle
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
get customAppTitle(): string {
|
get customAppTitle(): string {
|
||||||
return this.appTitleSetting()
|
this.settingsService.trackChanges()
|
||||||
|
return this.settingsService.get(SETTINGS_KEYS.APP_TITLE)
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasCustomBranding(): boolean {
|
get hasCustomBranding(): boolean {
|
||||||
return !!(this.appTitleSetting()?.length || this.appLogoSetting()?.length)
|
this.settingsService.trackChanges()
|
||||||
|
return !!(
|
||||||
|
this.settingsService.get(SETTINGS_KEYS.APP_TITLE)?.length ||
|
||||||
|
this.settingsService.get(SETTINGS_KEYS.APP_LOGO)?.length
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
get customAppLogo(): string {
|
get customAppLogo(): string {
|
||||||
const logo = this.appLogoSetting()
|
this.settingsService.trackChanges()
|
||||||
|
const logo = this.settingsService.get(SETTINGS_KEYS.APP_LOGO)
|
||||||
return logo?.length
|
return logo?.length
|
||||||
? environment.apiBaseUrl.replace(/\/api\/$/, logo)
|
? environment.apiBaseUrl.replace(/\/api\/$/, logo)
|
||||||
: null
|
: null
|
||||||
@@ -275,7 +262,8 @@ export class AppFrameComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get slimSidebarEnabled(): boolean {
|
get slimSidebarEnabled(): boolean {
|
||||||
return this.slimSidebarSetting()
|
this.settingsService.trackChanges()
|
||||||
|
return this.settingsService.get(SETTINGS_KEYS.SLIM_SIDEBAR)
|
||||||
}
|
}
|
||||||
|
|
||||||
set slimSidebarEnabled(enabled: boolean) {
|
set slimSidebarEnabled(enabled: boolean) {
|
||||||
@@ -298,9 +286,10 @@ export class AppFrameComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get attributesSectionsCollapsed(): boolean {
|
get attributesSectionsCollapsed(): boolean {
|
||||||
return this.attributesSectionsCollapsedSetting()?.includes(
|
this.settingsService.trackChanges()
|
||||||
CollapsibleSection.ATTRIBUTES
|
return this.settingsService
|
||||||
)
|
.get(SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED)
|
||||||
|
?.includes(CollapsibleSection.ATTRIBUTES)
|
||||||
}
|
}
|
||||||
|
|
||||||
set attributesSectionsCollapsed(collapsed: boolean) {
|
set attributesSectionsCollapsed(collapsed: boolean) {
|
||||||
@@ -323,7 +312,8 @@ export class AppFrameComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get aiEnabled(): boolean {
|
get aiEnabled(): boolean {
|
||||||
return this.aiEnabledSetting()
|
this.settingsService.trackChanges()
|
||||||
|
return this.settingsService.get(SETTINGS_KEYS.AI_ENABLED)
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:resize')
|
@HostListener('window:resize')
|
||||||
@@ -490,8 +480,9 @@ export class AppFrameComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get showSidebarCounts(): boolean {
|
get showSidebarCounts(): boolean {
|
||||||
|
this.settingsService.trackChanges()
|
||||||
return (
|
return (
|
||||||
this.sidebarViewsShowCountSetting() &&
|
this.settingsService.get(SETTINGS_KEYS.SIDEBAR_VIEWS_SHOW_COUNT) &&
|
||||||
!this.settingsService.organizingSidebarSavedViews()
|
!this.settingsService.organizingSidebarSavedViews()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,10 +81,6 @@ export class GlobalSearchComponent implements OnInit {
|
|||||||
private hotkeyService = inject(HotKeyService)
|
private hotkeyService = inject(HotKeyService)
|
||||||
private settingsService = inject(SettingsService)
|
private settingsService = inject(SettingsService)
|
||||||
private locationStrategy = inject(LocationStrategy)
|
private locationStrategy = inject(LocationStrategy)
|
||||||
private readonly searchFullTypeSetting =
|
|
||||||
this.settingsService.getSignal<GlobalSearchType>(
|
|
||||||
SETTINGS_KEYS.SEARCH_FULL_TYPE
|
|
||||||
)
|
|
||||||
|
|
||||||
public DataType = DataType
|
public DataType = DataType
|
||||||
readonly query = signal<string>(null)
|
readonly query = signal<string>(null)
|
||||||
@@ -101,7 +97,11 @@ export class GlobalSearchComponent implements OnInit {
|
|||||||
@ViewChildren('secondaryButton') secondaryButtons: QueryList<ElementRef>
|
@ViewChildren('secondaryButton') secondaryButtons: QueryList<ElementRef>
|
||||||
|
|
||||||
get useAdvancedForFullSearch(): boolean {
|
get useAdvancedForFullSearch(): boolean {
|
||||||
return this.searchFullTypeSetting() === GlobalSearchType.ADVANCED
|
this.settingsService.trackChanges()
|
||||||
|
return (
|
||||||
|
this.settingsService.get(SETTINGS_KEYS.SEARCH_FULL_TYPE) ===
|
||||||
|
GlobalSearchType.ADVANCED
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
+13
-19
@@ -196,16 +196,6 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
})
|
})
|
||||||
|
|
||||||
function setActionSettings({
|
|
||||||
email = true,
|
|
||||||
remoteOcr = true,
|
|
||||||
ai = true,
|
|
||||||
} = {}) {
|
|
||||||
settingsService.set(SETTINGS_KEYS.EMAIL_ENABLED, email)
|
|
||||||
settingsService.set(SETTINGS_KEYS.REMOTE_OCR_CONFIGURED, remoteOcr)
|
|
||||||
settingsService.set(SETTINGS_KEYS.AI_ENABLED, ai)
|
|
||||||
}
|
|
||||||
|
|
||||||
it('should support create and edit modes, support adding triggers and actions on new workflow', () => {
|
it('should support create and edit modes, support adding triggers and actions on new workflow', () => {
|
||||||
component.dialogMode.set(EditDialogMode.CREATE)
|
component.dialogMode.set(EditDialogMode.CREATE)
|
||||||
const createTitleSpy = jest.spyOn(component, 'getCreateTitle')
|
const createTitleSpy = jest.spyOn(component, 'getCreateTitle')
|
||||||
@@ -228,7 +218,7 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should return source options, type options, type name, schedule date field options', () => {
|
it('should return source options, type options, type name, schedule date field options', () => {
|
||||||
setActionSettings()
|
jest.spyOn(settingsService, 'get').mockReturnValue(true)
|
||||||
component.ngOnInit()
|
component.ngOnInit()
|
||||||
expect(component.sourceOptions).toEqual(DOCUMENT_SOURCE_OPTIONS)
|
expect(component.sourceOptions).toEqual(DOCUMENT_SOURCE_OPTIONS)
|
||||||
expect(component.triggerTypeOptions).toEqual(WORKFLOW_TYPE_OPTIONS)
|
expect(component.triggerTypeOptions).toEqual(WORKFLOW_TYPE_OPTIONS)
|
||||||
@@ -252,7 +242,7 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Email, remote OCR and AI all disabled
|
// Email, remote OCR and AI all disabled
|
||||||
setActionSettings({ email: false, remoteOcr: false, ai: false })
|
jest.spyOn(settingsService, 'get').mockReturnValue(false)
|
||||||
component.ngOnInit()
|
component.ngOnInit()
|
||||||
expect(component.actionTypeOptions).toEqual(
|
expect(component.actionTypeOptions).toEqual(
|
||||||
WORKFLOW_ACTION_OPTIONS.filter(
|
WORKFLOW_ACTION_OPTIONS.filter(
|
||||||
@@ -265,7 +255,7 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should offer remote OCR only for consumption workflows', () => {
|
it('should offer remote OCR only for consumption workflows', () => {
|
||||||
setActionSettings()
|
jest.spyOn(settingsService, 'get').mockReturnValue(true)
|
||||||
|
|
||||||
// A consumption trigger makes the action reachable
|
// A consumption trigger makes the action reachable
|
||||||
component.object = {
|
component.object = {
|
||||||
@@ -295,7 +285,7 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should offer remote OCR on a trigger added to a new workflow', () => {
|
it('should offer remote OCR on a trigger added to a new workflow', () => {
|
||||||
setActionSettings()
|
jest.spyOn(settingsService, 'get').mockReturnValue(true)
|
||||||
component.ngOnInit()
|
component.ngOnInit()
|
||||||
|
|
||||||
// Nothing for the action to apply to yet
|
// Nothing for the action to apply to yet
|
||||||
@@ -321,7 +311,7 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should keep remote OCR listed when an action already uses it', () => {
|
it('should keep remote OCR listed when an action already uses it', () => {
|
||||||
setActionSettings()
|
jest.spyOn(settingsService, 'get').mockReturnValue(true)
|
||||||
|
|
||||||
// Otherwise changing the trigger would silently blank the selection
|
// Otherwise changing the trigger would silently blank the selection
|
||||||
component.object = {
|
component.object = {
|
||||||
@@ -339,7 +329,9 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not offer remote OCR when no engine is configured', () => {
|
it('should not offer remote OCR when no engine is configured', () => {
|
||||||
setActionSettings({ remoteOcr: false })
|
jest
|
||||||
|
.spyOn(settingsService, 'get')
|
||||||
|
.mockImplementation((key) => key !== SETTINGS_KEYS.REMOTE_OCR_CONFIGURED)
|
||||||
|
|
||||||
component.object = {
|
component.object = {
|
||||||
name: 'Workflow 1',
|
name: 'Workflow 1',
|
||||||
@@ -356,7 +348,7 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should offer apply AI suggestions unless every trigger is consumption', () => {
|
it('should offer apply AI suggestions unless every trigger is consumption', () => {
|
||||||
setActionSettings()
|
jest.spyOn(settingsService, 'get').mockReturnValue(true)
|
||||||
|
|
||||||
// Consumption runs before the document has been parsed, so there would be
|
// Consumption runs before the document has been parsed, so there would be
|
||||||
// no content to make suggestions from
|
// no content to make suggestions from
|
||||||
@@ -390,7 +382,7 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should keep apply AI suggestions listed when an action already uses it', () => {
|
it('should keep apply AI suggestions listed when an action already uses it', () => {
|
||||||
setActionSettings()
|
jest.spyOn(settingsService, 'get').mockReturnValue(true)
|
||||||
|
|
||||||
// Otherwise changing the trigger would silently blank the selection
|
// Otherwise changing the trigger would silently blank the selection
|
||||||
component.object = {
|
component.object = {
|
||||||
@@ -408,7 +400,9 @@ describe('WorkflowEditDialogComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not offer apply AI suggestions when AI is disabled', () => {
|
it('should not offer apply AI suggestions when AI is disabled', () => {
|
||||||
setActionSettings({ ai: false })
|
jest
|
||||||
|
.spyOn(settingsService, 'get')
|
||||||
|
.mockImplementation((key) => key !== SETTINGS_KEYS.AI_ENABLED)
|
||||||
|
|
||||||
component.object = {
|
component.object = {
|
||||||
name: 'Workflow 1',
|
name: 'Workflow 1',
|
||||||
|
|||||||
+4
-10
@@ -537,13 +537,6 @@ export class WorkflowEditDialogComponent
|
|||||||
readonly dateCustomFields = computed(() =>
|
readonly dateCustomFields = computed(() =>
|
||||||
this.customFields()?.filter((f) => f.data_type === CustomFieldDataType.Date)
|
this.customFields()?.filter((f) => f.data_type === CustomFieldDataType.Date)
|
||||||
)
|
)
|
||||||
private readonly emailEnabledSetting =
|
|
||||||
this.settingsService.getSignal<boolean>(SETTINGS_KEYS.EMAIL_ENABLED)
|
|
||||||
private readonly remoteOcrConfiguredSetting =
|
|
||||||
this.settingsService.getSignal<boolean>(SETTINGS_KEYS.REMOTE_OCR_CONFIGURED)
|
|
||||||
private readonly aiEnabledSetting = this.settingsService.getSignal<boolean>(
|
|
||||||
SETTINGS_KEYS.AI_ENABLED
|
|
||||||
)
|
|
||||||
|
|
||||||
expandedItem: number = null
|
expandedItem: number = null
|
||||||
|
|
||||||
@@ -596,7 +589,7 @@ export class WorkflowEditDialogComponent
|
|||||||
private getAllowedActionTypes() {
|
private getAllowedActionTypes() {
|
||||||
let allowed = WORKFLOW_ACTION_OPTIONS
|
let allowed = WORKFLOW_ACTION_OPTIONS
|
||||||
|
|
||||||
if (!this.emailEnabledSetting()) {
|
if (!this.settingsService.get(SETTINGS_KEYS.EMAIL_ENABLED)) {
|
||||||
allowed = allowed.filter((a) => a.id !== WorkflowActionType.Email)
|
allowed = allowed.filter((a) => a.id !== WorkflowActionType.Email)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,7 +597,7 @@ export class WorkflowEditDialogComponent
|
|||||||
// offered for workflows that run at consumption.
|
// offered for workflows that run at consumption.
|
||||||
const formWorkflow: Workflow = this.objectForm?.value
|
const formWorkflow: Workflow = this.objectForm?.value
|
||||||
const remoteOcrUsable =
|
const remoteOcrUsable =
|
||||||
this.remoteOcrConfiguredSetting() &&
|
this.settingsService.get(SETTINGS_KEYS.REMOTE_OCR_CONFIGURED) &&
|
||||||
(formWorkflow?.triggers?.some(
|
(formWorkflow?.triggers?.some(
|
||||||
(trigger) => trigger.type === WorkflowTriggerType.Consumption
|
(trigger) => trigger.type === WorkflowTriggerType.Consumption
|
||||||
) ||
|
) ||
|
||||||
@@ -619,7 +612,7 @@ export class WorkflowEditDialogComponent
|
|||||||
// once every trigger is consumption, so it stays offered on a workflow
|
// once every trigger is consumption, so it stays offered on a workflow
|
||||||
// that has no triggers yet.
|
// that has no triggers yet.
|
||||||
const aiSuggestionsUsable =
|
const aiSuggestionsUsable =
|
||||||
this.aiEnabledSetting() &&
|
this.settingsService.get(SETTINGS_KEYS.AI_ENABLED) &&
|
||||||
(!formWorkflow?.triggers?.length ||
|
(!formWorkflow?.triggers?.length ||
|
||||||
formWorkflow.triggers.some(
|
formWorkflow.triggers.some(
|
||||||
(trigger) => trigger.type !== WorkflowTriggerType.Consumption
|
(trigger) => trigger.type !== WorkflowTriggerType.Consumption
|
||||||
@@ -1369,6 +1362,7 @@ export class WorkflowEditDialogComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get actionTypeOptions() {
|
get actionTypeOptions() {
|
||||||
|
this.settingsService.trackChanges()
|
||||||
// Computed on read rather than cached
|
// Computed on read rather than cached
|
||||||
return this.getAllowedActionTypes()
|
return this.getAllowedActionTypes()
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-10
@@ -839,9 +839,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
selectionModel.items = [memoRoot]
|
selectionModel.items = [memoRoot]
|
||||||
selectionModel.documentCounts = [{ id: memoRoot.id, document_count: 9 }]
|
selectionModel.documentCounts = [{ id: memoRoot.id, document_count: 9 }]
|
||||||
|
|
||||||
const getRootDocCount = (selectionModel as any).createRootDocCounter(
|
const getRootDocCount = (selectionModel as any).createRootDocCounter()
|
||||||
selectionModel.items
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(getRootDocCount(memoRoot.id)).toEqual(9)
|
expect(getRootDocCount(memoRoot.id)).toEqual(9)
|
||||||
selectionModel.documentCounts = []
|
selectionModel.documentCounts = []
|
||||||
@@ -857,9 +855,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
selectionModel.items = [rootWithoutSelection]
|
selectionModel.items = [rootWithoutSelection]
|
||||||
selectionModel.documentCounts = []
|
selectionModel.documentCounts = []
|
||||||
|
|
||||||
const getRootDocCount = (selectionModel as any).createRootDocCounter(
|
const getRootDocCount = (selectionModel as any).createRootDocCounter()
|
||||||
selectionModel.items
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(getRootDocCount(rootWithoutSelection.id)).toEqual(4)
|
expect(getRootDocCount(rootWithoutSelection.id)).toEqual(4)
|
||||||
})
|
})
|
||||||
@@ -869,9 +865,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
selectionModel.items = [rootWithoutCounts]
|
selectionModel.items = [rootWithoutCounts]
|
||||||
selectionModel.documentCounts = []
|
selectionModel.documentCounts = []
|
||||||
|
|
||||||
const getRootDocCount = (selectionModel as any).createRootDocCounter(
|
const getRootDocCount = (selectionModel as any).createRootDocCounter()
|
||||||
selectionModel.items
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(getRootDocCount(rootWithoutCounts.id)).toEqual(0)
|
expect(getRootDocCount(rootWithoutCounts.id)).toEqual(0)
|
||||||
})
|
})
|
||||||
@@ -972,7 +966,7 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
|
|||||||
component.selectionModel['temporarySelectionStates'].set(id, state)
|
component.selectionModel['temporarySelectionStates'].set(id, state)
|
||||||
const changedSpy = jest.spyOn(component.selectionModel.changed, 'next')
|
const changedSpy = jest.spyOn(component.selectionModel.changed, 'next')
|
||||||
component.selectionModel.exclude(id)
|
component.selectionModel.exclude(id)
|
||||||
expect(component.selectionModel.temporaryLogicalOperator()).toBe(
|
expect(component.selectionModel.temporaryLogicalOperator).toBe(
|
||||||
LogicalOperator.And
|
LogicalOperator.And
|
||||||
)
|
)
|
||||||
expect(component.selectionModel['temporarySelectionStates'].get(id)).toBe(
|
expect(component.selectionModel['temporarySelectionStates'].get(id)).toBe(
|
||||||
|
|||||||
+104
-125
@@ -64,56 +64,43 @@ export class FilterableDropdownSelectionModel {
|
|||||||
|
|
||||||
manyToOne = false
|
manyToOne = false
|
||||||
singleSelect = false
|
singleSelect = false
|
||||||
|
private _logicalOperator: LogicalOperator = LogicalOperator.And
|
||||||
|
temporaryLogicalOperator: LogicalOperator = this._logicalOperator
|
||||||
|
private _intersection: Intersection = Intersection.Include
|
||||||
|
temporaryIntersection: Intersection = this._intersection
|
||||||
|
|
||||||
private readonly _logicalOperator = signal(LogicalOperator.And)
|
private _documentCounts: SelectionDataItem[] = []
|
||||||
readonly temporaryLogicalOperator = signal(LogicalOperator.And)
|
|
||||||
private readonly _intersection = signal(Intersection.Include)
|
|
||||||
readonly temporaryIntersection = signal(Intersection.Include)
|
|
||||||
private readonly _documentCounts = signal<SelectionDataItem[]>([])
|
|
||||||
private readonly _items = signal<MatchingModel[]>([])
|
|
||||||
private readonly _selectionStates = signal(
|
|
||||||
new Map<number, ToggleableItemState>()
|
|
||||||
)
|
|
||||||
private readonly _temporarySelectionStates = signal(
|
|
||||||
new Map<number, ToggleableItemState>()
|
|
||||||
)
|
|
||||||
|
|
||||||
public documentCountSortingEnabled = false
|
public documentCountSortingEnabled = false
|
||||||
|
|
||||||
private get selectionStates(): ReadonlyMap<number, ToggleableItemState> {
|
|
||||||
return this._selectionStates()
|
|
||||||
}
|
|
||||||
|
|
||||||
private get temporarySelectionStates(): ReadonlyMap<
|
|
||||||
number,
|
|
||||||
ToggleableItemState
|
|
||||||
> {
|
|
||||||
return this._temporarySelectionStates()
|
|
||||||
}
|
|
||||||
|
|
||||||
public set documentCounts(counts: SelectionDataItem[]) {
|
public set documentCounts(counts: SelectionDataItem[]) {
|
||||||
this._documentCounts.set(counts)
|
this._documentCounts = counts
|
||||||
if (this.documentCountSortingEnabled) {
|
if (this.documentCountSortingEnabled) {
|
||||||
this._items.set(this.sortItems(this.items))
|
this.sortItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _items: MatchingModel[] = []
|
||||||
get items(): MatchingModel[] {
|
get items(): MatchingModel[] {
|
||||||
return this._items()
|
return this._items
|
||||||
}
|
}
|
||||||
|
|
||||||
set items(items: MatchingModel[]) {
|
set items(items: MatchingModel[]) {
|
||||||
if (items) {
|
if (items) {
|
||||||
this._items.set(this.withNullItem(this.sortItems(Array.from(items))))
|
this._items = Array.from(items)
|
||||||
|
this.sortItems()
|
||||||
|
this.setNullItem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private withNullItem(items: MatchingModel[]): MatchingModel[] {
|
private setNullItem() {
|
||||||
if (this.manyToOne && this.logicalOperator === LogicalOperator.Or) {
|
if (this.manyToOne && this.logicalOperator === LogicalOperator.Or) {
|
||||||
return items[0]?.id === null ? items.slice(1) : items
|
if (this._items[0]?.id === null) {
|
||||||
|
this._items.shift()
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const nullItem = {
|
const item = {
|
||||||
name: $localize`:Filter drop down element to filter for documents with no correspondent/type/tag assigned:Not assigned`,
|
name: $localize`:Filter drop down element to filter for documents with no correspondent/type/tag assigned:Not assigned`,
|
||||||
id:
|
id:
|
||||||
this.manyToOne || this.intersection === Intersection.Include
|
this.manyToOne || this.intersection === Intersection.Include
|
||||||
@@ -121,17 +108,22 @@ export class FilterableDropdownSelectionModel {
|
|||||||
: NEGATIVE_NULL_FILTER_VALUE,
|
: NEGATIVE_NULL_FILTER_VALUE,
|
||||||
}
|
}
|
||||||
|
|
||||||
return items[0]?.id === null || items[0]?.id === NEGATIVE_NULL_FILTER_VALUE
|
if (
|
||||||
? [nullItem, ...items.slice(1)]
|
this._items[0]?.id === null ||
|
||||||
: [nullItem, ...items]
|
this._items[0]?.id === NEGATIVE_NULL_FILTER_VALUE
|
||||||
|
) {
|
||||||
|
this._items[0] = item
|
||||||
|
} else if (this._items) {
|
||||||
|
this._items.unshift(item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(manyToOne: boolean = false) {
|
constructor(manyToOne: boolean = false) {
|
||||||
this.manyToOne = manyToOne
|
this.manyToOne = manyToOne
|
||||||
}
|
}
|
||||||
|
|
||||||
private sortItems(items: MatchingModel[]): MatchingModel[] {
|
private sortItems() {
|
||||||
const sorted = [...items].sort((a, b) => {
|
this._items.sort((a, b) => {
|
||||||
if (
|
if (
|
||||||
(a.id == null && b.id != null) ||
|
(a.id == null && b.id != null) ||
|
||||||
(a.id == NEGATIVE_NULL_FILTER_VALUE &&
|
(a.id == NEGATIVE_NULL_FILTER_VALUE &&
|
||||||
@@ -162,13 +154,13 @@ export class FilterableDropdownSelectionModel {
|
|||||||
) {
|
) {
|
||||||
return -1
|
return -1
|
||||||
} else if (
|
} else if (
|
||||||
this._documentCounts().length &&
|
this._documentCounts.length &&
|
||||||
this.getDocumentCount(b.id) === 0 &&
|
this.getDocumentCount(b.id) === 0 &&
|
||||||
this.getDocumentCount(a.id) > this.getDocumentCount(b.id)
|
this.getDocumentCount(a.id) > this.getDocumentCount(b.id)
|
||||||
) {
|
) {
|
||||||
return -1
|
return -1
|
||||||
} else if (
|
} else if (
|
||||||
this._documentCounts().length &&
|
this._documentCounts.length &&
|
||||||
this.getDocumentCount(a.id) === 0 &&
|
this.getDocumentCount(a.id) === 0 &&
|
||||||
this.getDocumentCount(a.id) < this.getDocumentCount(b.id)
|
this.getDocumentCount(a.id) < this.getDocumentCount(b.id)
|
||||||
) {
|
) {
|
||||||
@@ -178,11 +170,15 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return this._documentCounts().length
|
if (this._documentCounts.length) {
|
||||||
? this.promoteBranchesWithDocumentCounts(sorted)
|
this.promoteBranchesWithDocumentCounts()
|
||||||
: sorted
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private selectionStates = new Map<number, ToggleableItemState>()
|
||||||
|
|
||||||
|
private temporarySelectionStates = new Map<number, ToggleableItemState>()
|
||||||
|
|
||||||
getSelectedItems() {
|
getSelectedItems() {
|
||||||
return this.items.filter(
|
return this.items.filter(
|
||||||
(i) =>
|
(i) =>
|
||||||
@@ -198,33 +194,30 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set(id: number, state: ToggleableItemState, fireEvent = true) {
|
set(id: number, state: ToggleableItemState, fireEvent = true) {
|
||||||
const states = new Map(this.temporarySelectionStates)
|
|
||||||
if (state == ToggleableItemState.NotSelected) {
|
if (state == ToggleableItemState.NotSelected) {
|
||||||
states.delete(id)
|
this.temporarySelectionStates.delete(id)
|
||||||
} else {
|
} else {
|
||||||
states.set(id, state)
|
this.temporarySelectionStates.set(id, state)
|
||||||
}
|
}
|
||||||
this._temporarySelectionStates.set(states)
|
|
||||||
if (fireEvent) {
|
if (fireEvent) {
|
||||||
this.changed.next(this)
|
this.changed.next(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle(id: number, fireEvent = true) {
|
toggle(id: number, fireEvent = true) {
|
||||||
const states = new Map(this.temporarySelectionStates)
|
let state = this.temporarySelectionStates.get(id)
|
||||||
let state = states.get(id)
|
|
||||||
if (
|
if (
|
||||||
state == undefined ||
|
state == undefined ||
|
||||||
(state != ToggleableItemState.Selected &&
|
(state != ToggleableItemState.Selected &&
|
||||||
state != ToggleableItemState.Excluded)
|
state != ToggleableItemState.Excluded)
|
||||||
) {
|
) {
|
||||||
if (this.manyToOne || this.singleSelect) {
|
if (this.manyToOne || this.singleSelect) {
|
||||||
states.set(id, ToggleableItemState.Selected)
|
this.temporarySelectionStates.set(id, ToggleableItemState.Selected)
|
||||||
|
|
||||||
if (this.singleSelect) {
|
if (this.singleSelect) {
|
||||||
for (let key of states.keys()) {
|
for (let key of this.temporarySelectionStates.keys()) {
|
||||||
if (key != id) {
|
if (key != id) {
|
||||||
states.delete(key)
|
this.temporarySelectionStates.delete(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,26 +233,25 @@ export class FilterableDropdownSelectionModel {
|
|||||||
) {
|
) {
|
||||||
newState = ToggleableItemState.NotSelected
|
newState = ToggleableItemState.NotSelected
|
||||||
}
|
}
|
||||||
states.set(id, newState)
|
this.temporarySelectionStates.set(id, newState)
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
state == ToggleableItemState.Selected ||
|
state == ToggleableItemState.Selected ||
|
||||||
state == ToggleableItemState.Excluded
|
state == ToggleableItemState.Excluded
|
||||||
) {
|
) {
|
||||||
states.delete(id)
|
this.temporarySelectionStates.delete(id)
|
||||||
this.clearDescendantSelections(states, id)
|
this.clearDescendantSelections(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
for (let key of states.keys()) {
|
for (let key of this.temporarySelectionStates.keys()) {
|
||||||
if (key) {
|
if (key) {
|
||||||
states.delete(key)
|
this.temporarySelectionStates.delete(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
states.delete(null)
|
this.temporarySelectionStates.delete(null)
|
||||||
}
|
}
|
||||||
this._temporarySelectionStates.set(states)
|
|
||||||
|
|
||||||
if (fireEvent) {
|
if (fireEvent) {
|
||||||
this.changed.next(this)
|
this.changed.next(this)
|
||||||
@@ -267,21 +259,20 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exclude(id: number, fireEvent: boolean = true) {
|
exclude(id: number, fireEvent: boolean = true) {
|
||||||
const states = new Map(this.temporarySelectionStates)
|
let state = this.temporarySelectionStates.get(id)
|
||||||
let state = states.get(id)
|
|
||||||
if (id && (state == null || state != ToggleableItemState.Excluded)) {
|
if (id && (state == null || state != ToggleableItemState.Excluded)) {
|
||||||
const operator = this.manyToOne ? LogicalOperator.And : LogicalOperator.Or
|
this.temporaryLogicalOperator = this._logicalOperator = this.manyToOne
|
||||||
this.temporaryLogicalOperator.set(operator)
|
? LogicalOperator.And
|
||||||
this._logicalOperator.set(operator)
|
: LogicalOperator.Or
|
||||||
|
|
||||||
if (this.manyToOne || this.singleSelect) {
|
if (this.manyToOne || this.singleSelect) {
|
||||||
states.set(id, ToggleableItemState.Excluded)
|
this.temporarySelectionStates.set(id, ToggleableItemState.Excluded)
|
||||||
this.clearDescendantSelections(states, id)
|
this.clearDescendantSelections(id)
|
||||||
|
|
||||||
if (this.singleSelect) {
|
if (this.singleSelect) {
|
||||||
for (let key of states.keys()) {
|
for (let key of this.temporarySelectionStates.keys()) {
|
||||||
if (key != id) {
|
if (key != id) {
|
||||||
states.delete(key)
|
this.temporarySelectionStates.delete(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,18 +287,17 @@ export class FilterableDropdownSelectionModel {
|
|||||||
) {
|
) {
|
||||||
newState = ToggleableItemState.NotSelected
|
newState = ToggleableItemState.NotSelected
|
||||||
}
|
}
|
||||||
states.set(id, newState)
|
this.temporarySelectionStates.set(id, newState)
|
||||||
if (newState == ToggleableItemState.Excluded) {
|
if (newState == ToggleableItemState.Excluded) {
|
||||||
this.clearDescendantSelections(states, id)
|
this.clearDescendantSelections(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!id || state == ToggleableItemState.Excluded) {
|
} else if (!id || state == ToggleableItemState.Excluded) {
|
||||||
states.delete(id)
|
this.temporarySelectionStates.delete(id)
|
||||||
if (id) {
|
if (id) {
|
||||||
this.clearDescendantSelections(states, id)
|
this.clearDescendantSelections(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._temporarySelectionStates.set(states)
|
|
||||||
|
|
||||||
if (fireEvent) {
|
if (fireEvent) {
|
||||||
this.changed.next(this)
|
this.changed.next(this)
|
||||||
@@ -318,12 +308,9 @@ export class FilterableDropdownSelectionModel {
|
|||||||
return this.selectionStates.get(id) || ToggleableItemState.NotSelected
|
return this.selectionStates.get(id) || ToggleableItemState.NotSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearDescendantSelections(
|
private clearDescendantSelections(id: number) {
|
||||||
states: Map<number, ToggleableItemState>,
|
|
||||||
id: number
|
|
||||||
) {
|
|
||||||
for (const descendantID of this.getDescendantIDs(id)) {
|
for (const descendantID of this.getDescendantIDs(id)) {
|
||||||
states.delete(descendantID)
|
this.temporarySelectionStates.delete(descendantID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +320,7 @@ export class FilterableDropdownSelectionModel {
|
|||||||
|
|
||||||
while (queue.length) {
|
while (queue.length) {
|
||||||
const parentID = queue.shift()
|
const parentID = queue.shift()
|
||||||
for (const item of this.items) {
|
for (const item of this._items) {
|
||||||
if (
|
if (
|
||||||
typeof item?.id === 'number' &&
|
typeof item?.id === 'number' &&
|
||||||
typeof (item as any)['parent'] === 'number' &&
|
typeof (item as any)['parent'] === 'number' &&
|
||||||
@@ -349,12 +336,12 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get logicalOperator(): LogicalOperator {
|
get logicalOperator(): LogicalOperator {
|
||||||
return this.temporaryLogicalOperator()
|
return this.temporaryLogicalOperator
|
||||||
}
|
}
|
||||||
|
|
||||||
set logicalOperator(operator: LogicalOperator) {
|
set logicalOperator(operator: LogicalOperator) {
|
||||||
this.temporaryLogicalOperator.set(operator)
|
this.temporaryLogicalOperator = operator
|
||||||
this._items.set(this.withNullItem(this.items))
|
this.setNullItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleOperator() {
|
toggleOperator() {
|
||||||
@@ -362,12 +349,12 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get intersection(): Intersection {
|
get intersection(): Intersection {
|
||||||
return this.temporaryIntersection()
|
return this.temporaryIntersection
|
||||||
}
|
}
|
||||||
|
|
||||||
set intersection(intersection: Intersection) {
|
set intersection(intersection: Intersection) {
|
||||||
this.temporaryIntersection.set(intersection)
|
this.temporaryIntersection = intersection
|
||||||
this._items.set(this.withNullItem(this.items))
|
this.setNullItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleIntersection() {
|
toggleIntersection() {
|
||||||
@@ -377,20 +364,18 @@ export class FilterableDropdownSelectionModel {
|
|||||||
? ToggleableItemState.Selected
|
? ToggleableItemState.Selected
|
||||||
: ToggleableItemState.Excluded
|
: ToggleableItemState.Excluded
|
||||||
|
|
||||||
const states = new Map(this.temporarySelectionStates)
|
this.temporarySelectionStates.forEach((state, key) => {
|
||||||
states.forEach((state, key) => {
|
|
||||||
if (key === null && this.intersection === Intersection.Exclude) {
|
if (key === null && this.intersection === Intersection.Exclude) {
|
||||||
states.set(NEGATIVE_NULL_FILTER_VALUE, newState)
|
this.temporarySelectionStates.set(NEGATIVE_NULL_FILTER_VALUE, newState)
|
||||||
} else if (
|
} else if (
|
||||||
key === NEGATIVE_NULL_FILTER_VALUE &&
|
key === NEGATIVE_NULL_FILTER_VALUE &&
|
||||||
this.intersection === Intersection.Include
|
this.intersection === Intersection.Include
|
||||||
) {
|
) {
|
||||||
states.set(null, newState)
|
this.temporarySelectionStates.set(null, newState)
|
||||||
} else {
|
} else {
|
||||||
states.set(key, newState)
|
this.temporarySelectionStates.set(key, newState)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this._temporarySelectionStates.set(states)
|
|
||||||
|
|
||||||
this.changed.next(this)
|
this.changed.next(this)
|
||||||
}
|
}
|
||||||
@@ -410,12 +395,10 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clear(fireEvent = true) {
|
clear(fireEvent = true) {
|
||||||
this._temporarySelectionStates.set(new Map())
|
this.temporarySelectionStates.clear()
|
||||||
this.temporaryLogicalOperator.set(LogicalOperator.And)
|
this.temporaryLogicalOperator = this._logicalOperator = LogicalOperator.And
|
||||||
this._logicalOperator.set(LogicalOperator.And)
|
this.temporaryIntersection = this._intersection = Intersection.Include
|
||||||
this.temporaryIntersection.set(Intersection.Include)
|
this.setNullItem()
|
||||||
this._intersection.set(Intersection.Include)
|
|
||||||
this._items.set(this.withNullItem(this.items))
|
|
||||||
if (fireEvent) {
|
if (fireEvent) {
|
||||||
this.changed.next(this)
|
this.changed.next(this)
|
||||||
}
|
}
|
||||||
@@ -436,9 +419,9 @@ export class FilterableDropdownSelectionModel {
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
} else if (this.temporaryLogicalOperator() !== this._logicalOperator()) {
|
} else if (this.temporaryLogicalOperator !== this._logicalOperator) {
|
||||||
return true
|
return true
|
||||||
} else if (this.temporaryIntersection() !== this._intersection()) {
|
} else if (this.temporaryIntersection !== this._intersection) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@@ -455,29 +438,23 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getDocumentCount(id: number) {
|
getDocumentCount(id: number) {
|
||||||
return this._documentCounts().find((c) => c.id === id)?.document_count
|
return this._documentCounts.find((c) => c.id === id)?.document_count
|
||||||
}
|
}
|
||||||
|
|
||||||
private promoteBranchesWithDocumentCounts(
|
private promoteBranchesWithDocumentCounts() {
|
||||||
items: MatchingModel[]
|
const parentById = this.buildParentById()
|
||||||
): MatchingModel[] {
|
|
||||||
const parentById = this.buildParentById(items)
|
|
||||||
const findRootId = this.createRootFinder(parentById)
|
const findRootId = this.createRootFinder(parentById)
|
||||||
const getRootDocCount = this.createRootDocCounter(items)
|
const getRootDocCount = this.createRootDocCounter()
|
||||||
const summaries = this.buildBranchSummaries(
|
const summaries = this.buildBranchSummaries(findRootId, getRootDocCount)
|
||||||
items,
|
|
||||||
findRootId,
|
|
||||||
getRootDocCount
|
|
||||||
)
|
|
||||||
const orderedBranches = this.orderBranchesByPriority(summaries)
|
const orderedBranches = this.orderBranchesByPriority(summaries)
|
||||||
|
|
||||||
return orderedBranches.flatMap((summary) => summary.items)
|
this._items = orderedBranches.flatMap((summary) => summary.items)
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildParentById(items: MatchingModel[]): Map<number, number | null> {
|
private buildParentById(): Map<number, number | null> {
|
||||||
const parentById = new Map<number, number | null>()
|
const parentById = new Map<number, number | null>()
|
||||||
|
|
||||||
for (const item of items) {
|
for (const item of this._items) {
|
||||||
if (typeof item?.id === 'number') {
|
if (typeof item?.id === 'number') {
|
||||||
const parentValue = (item as any)['parent']
|
const parentValue = (item as any)['parent']
|
||||||
parentById.set(
|
parentById.set(
|
||||||
@@ -515,9 +492,7 @@ export class FilterableDropdownSelectionModel {
|
|||||||
return findRootId
|
return findRootId
|
||||||
}
|
}
|
||||||
|
|
||||||
private createRootDocCounter(
|
private createRootDocCounter(): (rootId: number) => number {
|
||||||
items: MatchingModel[]
|
|
||||||
): (rootId: number) => number {
|
|
||||||
const docCountMemo = new Map<number, number>()
|
const docCountMemo = new Map<number, number>()
|
||||||
|
|
||||||
return (rootId: number): number => {
|
return (rootId: number): number => {
|
||||||
@@ -532,7 +507,7 @@ export class FilterableDropdownSelectionModel {
|
|||||||
return explicit
|
return explicit
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootItem = items.find((i) => i.id === rootId)
|
const rootItem = this._items.find((i) => i.id === rootId)
|
||||||
const fallback =
|
const fallback =
|
||||||
typeof (rootItem as any)?.['document_count'] === 'number'
|
typeof (rootItem as any)?.['document_count'] === 'number'
|
||||||
? (rootItem as any)['document_count']
|
? (rootItem as any)['document_count']
|
||||||
@@ -544,13 +519,12 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private buildBranchSummaries(
|
private buildBranchSummaries(
|
||||||
items: MatchingModel[],
|
|
||||||
findRootId: (id: number) => number,
|
findRootId: (id: number) => number,
|
||||||
getRootDocCount: (rootId: number) => number
|
getRootDocCount: (rootId: number) => number
|
||||||
): Map<string, BranchSummary> {
|
): Map<string, BranchSummary> {
|
||||||
const summaries = new Map<string, BranchSummary>()
|
const summaries = new Map<string, BranchSummary>()
|
||||||
|
|
||||||
for (const [index, item] of items.entries()) {
|
for (const [index, item] of this._items.entries()) {
|
||||||
const { key, special, rootId } = this.describeBranchItem(
|
const { key, special, rootId } = this.describeBranchItem(
|
||||||
item,
|
item,
|
||||||
index,
|
index,
|
||||||
@@ -642,23 +616,28 @@ export class FilterableDropdownSelectionModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init(map: Map<number, ToggleableItemState>) {
|
init(map: Map<number, ToggleableItemState>) {
|
||||||
this._temporarySelectionStates.set(new Map(map))
|
this.temporarySelectionStates = map
|
||||||
this.apply()
|
this.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
apply() {
|
apply() {
|
||||||
this._selectionStates.set(new Map(this.temporarySelectionStates))
|
this.selectionStates.clear()
|
||||||
this._logicalOperator.set(this.temporaryLogicalOperator())
|
this.temporarySelectionStates.forEach((value, key) => {
|
||||||
this._intersection.set(this.temporaryIntersection())
|
this.selectionStates.set(key, value)
|
||||||
this._items.set(this.sortItems(this.items))
|
})
|
||||||
|
this._logicalOperator = this.temporaryLogicalOperator
|
||||||
|
this._intersection = this.temporaryIntersection
|
||||||
|
this.sortItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
reset(complete: boolean = false) {
|
reset(complete: boolean = false) {
|
||||||
|
this.temporarySelectionStates.clear()
|
||||||
if (complete) {
|
if (complete) {
|
||||||
this._selectionStates.set(new Map())
|
this.selectionStates.clear()
|
||||||
this._temporarySelectionStates.set(new Map())
|
|
||||||
} else {
|
} else {
|
||||||
this._temporarySelectionStates.set(new Map(this.selectionStates))
|
this.selectionStates.forEach((value, key) => {
|
||||||
|
this.temporarySelectionStates.set(key, value)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-6
@@ -7,8 +7,6 @@
|
|||||||
padding-left: calc(calc(var(--depth) - 2) * 1rem);
|
padding-left: calc(calc(var(--depth) - 2) * 1rem);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-width: 0;
|
|
||||||
overflow-wrap: anywhere;
|
|
||||||
|
|
||||||
.indicator {
|
.indicator {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@@ -20,7 +18,3 @@
|
|||||||
margin-left: .5rem;
|
margin-left: .5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge {
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|||||||
+9
-10
@@ -7,7 +7,7 @@
|
|||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.NONE)" [disabled]="disabled">
|
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.NONE)" [disabled]="disabled">
|
||||||
<div class="selected-icon me-1">
|
<div class="selected-icon me-1">
|
||||||
@if (selectionModel.ownerFilter() === OwnerFilterType.NONE) {
|
@if (selectionModel.ownerFilter === OwnerFilterType.NONE) {
|
||||||
<i-bs width="1em" height="1em" name="check"></i-bs>
|
<i-bs width="1em" height="1em" name="check"></i-bs>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.SELF)" [disabled]="disabled">
|
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.SELF)" [disabled]="disabled">
|
||||||
<div class="selected-icon me-1">
|
<div class="selected-icon me-1">
|
||||||
@if (selectionModel.ownerFilter() === OwnerFilterType.SELF) {
|
@if (selectionModel.ownerFilter === OwnerFilterType.SELF) {
|
||||||
<i-bs width="1em" height="1em" name="check"></i-bs>
|
<i-bs width="1em" height="1em" name="check"></i-bs>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.NOT_SELF)" [disabled]="disabled">
|
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.NOT_SELF)" [disabled]="disabled">
|
||||||
<div class="selected-icon me-1">
|
<div class="selected-icon me-1">
|
||||||
@if (selectionModel.ownerFilter() === OwnerFilterType.NOT_SELF) {
|
@if (selectionModel.ownerFilter === OwnerFilterType.NOT_SELF) {
|
||||||
<i-bs width="1em" height="1em" name="check"></i-bs>
|
<i-bs width="1em" height="1em" name="check"></i-bs>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.SHARED_BY_ME)" [disabled]="disabled">
|
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.SHARED_BY_ME)" [disabled]="disabled">
|
||||||
<div class="selected-icon me-1">
|
<div class="selected-icon me-1">
|
||||||
@if (selectionModel.ownerFilter() === OwnerFilterType.SHARED_BY_ME) {
|
@if (selectionModel.ownerFilter === OwnerFilterType.SHARED_BY_ME) {
|
||||||
<i-bs width="1em" height="1em" name="check"></i-bs>
|
<i-bs width="1em" height="1em" name="check"></i-bs>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.UNOWNED)" [disabled]="disabled">
|
<button class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" (click)="setFilter(OwnerFilterType.UNOWNED)" [disabled]="disabled">
|
||||||
<div class="selected-icon me-1">
|
<div class="selected-icon me-1">
|
||||||
@if (selectionModel.ownerFilter() === OwnerFilterType.UNOWNED) {
|
@if (selectionModel.ownerFilter === OwnerFilterType.UNOWNED) {
|
||||||
<i-bs width="1em" height="1em" name="check"></i-bs>
|
<i-bs width="1em" height="1em" name="check"></i-bs>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<button *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.User }" class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" [disabled]="disabled">
|
<button *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.User }" class="list-group-item list-group-item-action d-flex align-items-center p-2 border-top-0 border-start-0 border-end-0 border-bottom" role="menuitem" [disabled]="disabled">
|
||||||
<div class="selected-icon me-1">
|
<div class="selected-icon me-1">
|
||||||
@if (selectionModel.ownerFilter() === OwnerFilterType.OTHERS) {
|
@if (selectionModel.ownerFilter === OwnerFilterType.OTHERS) {
|
||||||
<i-bs width="1em" height="1em" name="check"></i-bs>
|
<i-bs width="1em" height="1em" name="check"></i-bs>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -65,8 +65,7 @@
|
|||||||
<ng-select
|
<ng-select
|
||||||
name="user"
|
name="user"
|
||||||
class="user-select small"
|
class="user-select small"
|
||||||
[ngModel]="selectionModel.includeUsers()"
|
[(ngModel)]="selectionModel.includeUsers"
|
||||||
(ngModelChange)="selectionModel.includeUsers.set($event)"
|
|
||||||
[disabled]="disabled"
|
[disabled]="disabled"
|
||||||
[clearable]="false"
|
[clearable]="false"
|
||||||
[items]="users()"
|
[items]="users()"
|
||||||
@@ -79,10 +78,10 @@
|
|||||||
</ng-select>
|
</ng-select>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
@if (selectionModel.ownerFilter() === OwnerFilterType.NONE || selectionModel.ownerFilter() === OwnerFilterType.NOT_SELF) {
|
@if (selectionModel.ownerFilter === OwnerFilterType.NONE || selectionModel.ownerFilter === OwnerFilterType.NOT_SELF) {
|
||||||
<div class="list-group-item list-group-item-action d-flex align-items-center p-2 ps-3 border-bottom-0 border-start-0 border-end-0">
|
<div class="list-group-item list-group-item-action d-flex align-items-center p-2 ps-3 border-bottom-0 border-start-0 border-end-0">
|
||||||
<div class="form-check form-switch w-100">
|
<div class="form-check form-switch w-100">
|
||||||
<input type="checkbox" class="form-check-input" id="hideUnowned" [ngModel]="selectionModel.hideUnowned()" (ngModelChange)="selectionModel.hideUnowned.set($event)" (change)="onChange()" [disabled]="disabled">
|
<input type="checkbox" class="form-check-input" id="hideUnowned" [(ngModel)]="this.selectionModel.hideUnowned" (change)="onChange()" [disabled]="disabled">
|
||||||
<label class="form-check-label w-100" for="hideUnowned"><small i18n>Hide unowned</small></label>
|
<label class="form-check-label w-100" for="hideUnowned"><small i18n>Hide unowned</small></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+30
-39
@@ -90,56 +90,56 @@ describe('PermissionsFilterDropdownComponent', () => {
|
|||||||
component.setFilter(OwnerFilterType.OTHERS)
|
component.setFilter(OwnerFilterType.OTHERS)
|
||||||
expect(component.isActive).toBeTruthy()
|
expect(component.isActive).toBeTruthy()
|
||||||
component.setFilter(OwnerFilterType.NONE)
|
component.setFilter(OwnerFilterType.NONE)
|
||||||
component.selectionModel.hideUnowned.set(true)
|
component.selectionModel.hideUnowned = true
|
||||||
expect(component.isActive).toBeTruthy()
|
expect(component.isActive).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should describe concrete user filters honestly', () => {
|
it('should describe concrete user filters honestly', () => {
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.SELF)
|
component.selectionModel.ownerFilter = OwnerFilterType.SELF
|
||||||
component.selectionModel.userID.set(1)
|
component.selectionModel.userID = 1
|
||||||
expect(component.ownerFilterLabel).toEqual('Owned by user1')
|
expect(component.ownerFilterLabel).toEqual('Owned by user1')
|
||||||
|
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.NOT_SELF)
|
component.selectionModel.ownerFilter = OwnerFilterType.NOT_SELF
|
||||||
component.selectionModel.excludeUsers.set([1])
|
component.selectionModel.excludeUsers = [1]
|
||||||
expect(component.ownerExclusionFilterLabel).toEqual('Not owned by user1')
|
expect(component.ownerExclusionFilterLabel).toEqual('Not owned by user1')
|
||||||
|
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.SHARED_BY_ME)
|
component.selectionModel.ownerFilter = OwnerFilterType.SHARED_BY_ME
|
||||||
component.selectionModel.userID.set(1)
|
component.selectionModel.userID = 1
|
||||||
expect(component.sharedByFilterLabel).toEqual('Shared by user1')
|
expect(component.sharedByFilterLabel).toEqual('Shared by user1')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should describe concrete filters when usernames are unavailable', () => {
|
it('should describe concrete filters when usernames are unavailable', () => {
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.SELF)
|
component.selectionModel.ownerFilter = OwnerFilterType.SELF
|
||||||
component.selectionModel.userID.set(99)
|
component.selectionModel.userID = 99
|
||||||
expect(component.ownerFilterLabel).toEqual('Owned by another user')
|
expect(component.ownerFilterLabel).toEqual('Owned by another user')
|
||||||
|
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.NOT_SELF)
|
component.selectionModel.ownerFilter = OwnerFilterType.NOT_SELF
|
||||||
component.selectionModel.excludeUsers.set([99])
|
component.selectionModel.excludeUsers = [99]
|
||||||
expect(component.ownerExclusionFilterLabel).toEqual(
|
expect(component.ownerExclusionFilterLabel).toEqual(
|
||||||
'Not owned by another user'
|
'Not owned by another user'
|
||||||
)
|
)
|
||||||
|
|
||||||
component.selectionModel.excludeUsers.set([98, 99])
|
component.selectionModel.excludeUsers = [98, 99]
|
||||||
expect(component.ownerExclusionFilterLabel).toEqual(
|
expect(component.ownerExclusionFilterLabel).toEqual(
|
||||||
'Not owned by selected users'
|
'Not owned by selected users'
|
||||||
)
|
)
|
||||||
|
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.SHARED_BY_ME)
|
component.selectionModel.ownerFilter = OwnerFilterType.SHARED_BY_ME
|
||||||
component.selectionModel.userID.set(99)
|
component.selectionModel.userID = 99
|
||||||
expect(component.sharedByFilterLabel).toEqual('Shared by another user')
|
expect(component.sharedByFilterLabel).toEqual('Shared by another user')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should retain relative labels for filters bound to the current user', () => {
|
it('should retain relative labels for filters bound to the current user', () => {
|
||||||
component.selectionModel.userID.set(currentUserID)
|
component.selectionModel.userID = currentUserID
|
||||||
expect(component.ownerFilterLabel).toEqual('My documents')
|
expect(component.ownerFilterLabel).toEqual('My documents')
|
||||||
expect(component.sharedByFilterLabel).toEqual('Shared by me')
|
expect(component.sharedByFilterLabel).toEqual('Shared by me')
|
||||||
|
|
||||||
component.selectionModel.excludeUsers.set([currentUserID])
|
component.selectionModel.excludeUsers = [currentUserID]
|
||||||
expect(component.ownerExclusionFilterLabel).toEqual('Shared with me')
|
expect(component.ownerExclusionFilterLabel).toEqual('Shared with me')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should retain relative labels for inactive filter choices', () => {
|
it('should retain relative labels for inactive filter choices', () => {
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.NONE)
|
component.selectionModel.ownerFilter = OwnerFilterType.NONE
|
||||||
|
|
||||||
expect(component.ownerFilterLabel).toEqual('My documents')
|
expect(component.ownerFilterLabel).toEqual('My documents')
|
||||||
expect(component.ownerExclusionFilterLabel).toEqual('Shared with me')
|
expect(component.ownerExclusionFilterLabel).toEqual('Shared with me')
|
||||||
@@ -148,41 +148,32 @@ describe('PermissionsFilterDropdownComponent', () => {
|
|||||||
|
|
||||||
it('should support reset', () => {
|
it('should support reset', () => {
|
||||||
component.setFilter(OwnerFilterType.OTHERS)
|
component.setFilter(OwnerFilterType.OTHERS)
|
||||||
expect(component.selectionModel.ownerFilter()).not.toEqual(
|
expect(component.selectionModel.ownerFilter).not.toEqual(
|
||||||
OwnerFilterType.NONE
|
OwnerFilterType.NONE
|
||||||
)
|
)
|
||||||
component.reset()
|
component.reset()
|
||||||
expect(component.selectionModel.ownerFilter()).toEqual(OwnerFilterType.NONE)
|
expect(component.selectionModel.ownerFilter).toEqual(OwnerFilterType.NONE)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should toggle owner filter type when users selected', () => {
|
it('should toggle owner filter type when users selected', () => {
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.NONE)
|
component.selectionModel.ownerFilter = OwnerFilterType.NONE
|
||||||
|
|
||||||
// this would normally be done by select component
|
// this would normally be done by select component
|
||||||
component.selectionModel.includeUsers.set([12])
|
component.selectionModel.includeUsers = [12]
|
||||||
component.onUserSelect()
|
component.onUserSelect()
|
||||||
expect(component.selectionModel.ownerFilter()).toEqual(
|
expect(component.selectionModel.ownerFilter).toEqual(OwnerFilterType.OTHERS)
|
||||||
OwnerFilterType.OTHERS
|
|
||||||
)
|
|
||||||
|
|
||||||
// this would normally be done by select component
|
// this would normally be done by select component
|
||||||
component.selectionModel.includeUsers.set(null)
|
component.selectionModel.includeUsers = null
|
||||||
component.onUserSelect()
|
component.onUserSelect()
|
||||||
|
|
||||||
expect(component.selectionModel.ownerFilter()).toEqual(OwnerFilterType.NONE)
|
expect(component.selectionModel.ownerFilter).toEqual(OwnerFilterType.NONE)
|
||||||
})
|
})
|
||||||
it('should emit a selection model depending on the type of owner filter set', () => {
|
it('should emit a selection model depending on the type of owner filter set', () => {
|
||||||
const emitted = () => ({
|
component.selectionModel.ownerFilter = OwnerFilterType.NONE
|
||||||
excludeUsers: ownerFilterSetResult.excludeUsers(),
|
|
||||||
hideUnowned: ownerFilterSetResult.hideUnowned(),
|
|
||||||
includeUsers: ownerFilterSetResult.includeUsers(),
|
|
||||||
ownerFilter: ownerFilterSetResult.ownerFilter(),
|
|
||||||
userID: ownerFilterSetResult.userID(),
|
|
||||||
})
|
|
||||||
component.selectionModel.ownerFilter.set(OwnerFilterType.NONE)
|
|
||||||
|
|
||||||
component.setFilter(OwnerFilterType.SELF)
|
component.setFilter(OwnerFilterType.SELF)
|
||||||
expect(emitted()).toEqual({
|
expect(ownerFilterSetResult).toEqual({
|
||||||
excludeUsers: [],
|
excludeUsers: [],
|
||||||
hideUnowned: false,
|
hideUnowned: false,
|
||||||
includeUsers: [],
|
includeUsers: [],
|
||||||
@@ -191,7 +182,7 @@ describe('PermissionsFilterDropdownComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
component.setFilter(OwnerFilterType.NOT_SELF)
|
component.setFilter(OwnerFilterType.NOT_SELF)
|
||||||
expect(emitted()).toEqual({
|
expect(ownerFilterSetResult).toEqual({
|
||||||
excludeUsers: [currentUserID],
|
excludeUsers: [currentUserID],
|
||||||
hideUnowned: false,
|
hideUnowned: false,
|
||||||
includeUsers: [],
|
includeUsers: [],
|
||||||
@@ -200,7 +191,7 @@ describe('PermissionsFilterDropdownComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
component.setFilter(OwnerFilterType.NONE)
|
component.setFilter(OwnerFilterType.NONE)
|
||||||
expect(emitted()).toEqual({
|
expect(ownerFilterSetResult).toEqual({
|
||||||
excludeUsers: [],
|
excludeUsers: [],
|
||||||
hideUnowned: false,
|
hideUnowned: false,
|
||||||
includeUsers: [],
|
includeUsers: [],
|
||||||
@@ -209,7 +200,7 @@ describe('PermissionsFilterDropdownComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
component.setFilter(OwnerFilterType.SHARED_BY_ME)
|
component.setFilter(OwnerFilterType.SHARED_BY_ME)
|
||||||
expect(emitted()).toEqual({
|
expect(ownerFilterSetResult).toEqual({
|
||||||
excludeUsers: [],
|
excludeUsers: [],
|
||||||
hideUnowned: false,
|
hideUnowned: false,
|
||||||
includeUsers: [],
|
includeUsers: [],
|
||||||
@@ -218,7 +209,7 @@ describe('PermissionsFilterDropdownComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
component.setFilter(OwnerFilterType.UNOWNED)
|
component.setFilter(OwnerFilterType.UNOWNED)
|
||||||
expect(emitted()).toEqual({
|
expect(ownerFilterSetResult).toEqual({
|
||||||
excludeUsers: [],
|
excludeUsers: [],
|
||||||
hideUnowned: false,
|
hideUnowned: false,
|
||||||
includeUsers: [],
|
includeUsers: [],
|
||||||
|
|||||||
+53
-53
@@ -25,18 +25,18 @@ import { ComponentWithPermissions } from '../../with-permissions/with-permission
|
|||||||
import { ClearableBadgeComponent } from '../clearable-badge/clearable-badge.component'
|
import { ClearableBadgeComponent } from '../clearable-badge/clearable-badge.component'
|
||||||
|
|
||||||
export class PermissionsSelectionModel {
|
export class PermissionsSelectionModel {
|
||||||
readonly ownerFilter = signal(OwnerFilterType.NONE)
|
ownerFilter: OwnerFilterType
|
||||||
readonly hideUnowned = signal(false)
|
hideUnowned: boolean
|
||||||
readonly userID = signal<number>(null)
|
userID: number
|
||||||
readonly includeUsers = signal<number[]>([])
|
includeUsers: number[]
|
||||||
readonly excludeUsers = signal<number[]>([])
|
excludeUsers: number[]
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this.ownerFilter.set(OwnerFilterType.NONE)
|
this.ownerFilter = OwnerFilterType.NONE
|
||||||
this.userID.set(null)
|
this.userID = null
|
||||||
this.hideUnowned.set(false)
|
this.hideUnowned = false
|
||||||
this.includeUsers.set([])
|
this.includeUsers = []
|
||||||
this.excludeUsers.set([])
|
this.excludeUsers = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,31 +84,33 @@ export class PermissionsFilterDropdownComponent extends ComponentWithPermissions
|
|||||||
|
|
||||||
readonly users = signal<User[]>([])
|
readonly users = signal<User[]>([])
|
||||||
|
|
||||||
|
hideUnowned: boolean
|
||||||
|
|
||||||
get isActive(): boolean {
|
get isActive(): boolean {
|
||||||
return (
|
return (
|
||||||
this.selectionModel.ownerFilter() !== OwnerFilterType.NONE ||
|
this.selectionModel.ownerFilter !== OwnerFilterType.NONE ||
|
||||||
this.selectionModel.hideUnowned()
|
this.selectionModel.hideUnowned
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
get ownerFilterLabel(): string {
|
get ownerFilterLabel(): string {
|
||||||
if (
|
if (
|
||||||
this.selectionModel?.ownerFilter() !== OwnerFilterType.SELF ||
|
this.selectionModel?.ownerFilter !== OwnerFilterType.SELF ||
|
||||||
this.selectionModel?.userID() === this.settingsService.currentUser()?.id
|
this.selectionModel?.userID === this.settingsService.currentUser()?.id
|
||||||
) {
|
) {
|
||||||
return $localize`My documents`
|
return $localize`My documents`
|
||||||
}
|
}
|
||||||
|
|
||||||
const username = this.getUsername(this.selectionModel?.userID())
|
const username = this.getUsername(this.selectionModel?.userID)
|
||||||
return username
|
return username
|
||||||
? $localize`Owned by ${username}`
|
? $localize`Owned by ${username}`
|
||||||
: $localize`Owned by another user`
|
: $localize`Owned by another user`
|
||||||
}
|
}
|
||||||
|
|
||||||
get ownerExclusionFilterLabel(): string {
|
get ownerExclusionFilterLabel(): string {
|
||||||
const excludedUsers = this.selectionModel?.excludeUsers() ?? []
|
const excludedUsers = this.selectionModel?.excludeUsers ?? []
|
||||||
if (
|
if (
|
||||||
this.selectionModel?.ownerFilter() !== OwnerFilterType.NOT_SELF ||
|
this.selectionModel?.ownerFilter !== OwnerFilterType.NOT_SELF ||
|
||||||
(excludedUsers.length === 1 &&
|
(excludedUsers.length === 1 &&
|
||||||
excludedUsers[0] === this.settingsService.currentUser()?.id)
|
excludedUsers[0] === this.settingsService.currentUser()?.id)
|
||||||
) {
|
) {
|
||||||
@@ -128,13 +130,13 @@ export class PermissionsFilterDropdownComponent extends ComponentWithPermissions
|
|||||||
|
|
||||||
get sharedByFilterLabel(): string {
|
get sharedByFilterLabel(): string {
|
||||||
if (
|
if (
|
||||||
this.selectionModel?.ownerFilter() !== OwnerFilterType.SHARED_BY_ME ||
|
this.selectionModel?.ownerFilter !== OwnerFilterType.SHARED_BY_ME ||
|
||||||
this.selectionModel?.userID() === this.settingsService.currentUser()?.id
|
this.selectionModel?.userID === this.settingsService.currentUser()?.id
|
||||||
) {
|
) {
|
||||||
return $localize`Shared by me`
|
return $localize`Shared by me`
|
||||||
}
|
}
|
||||||
|
|
||||||
const username = this.getUsername(this.selectionModel?.userID())
|
const username = this.getUsername(this.selectionModel?.userID)
|
||||||
return username
|
return username
|
||||||
? $localize`Shared by ${username}`
|
? $localize`Shared by ${username}`
|
||||||
: $localize`Shared by another user`
|
: $localize`Shared by another user`
|
||||||
@@ -167,36 +169,34 @@ export class PermissionsFilterDropdownComponent extends ComponentWithPermissions
|
|||||||
}
|
}
|
||||||
|
|
||||||
setFilter(type: OwnerFilterType) {
|
setFilter(type: OwnerFilterType) {
|
||||||
this.selectionModel.ownerFilter.set(type)
|
this.selectionModel.ownerFilter = type
|
||||||
if (this.selectionModel.ownerFilter() === OwnerFilterType.SELF) {
|
if (this.selectionModel.ownerFilter === OwnerFilterType.SELF) {
|
||||||
this.selectionModel.includeUsers.set([])
|
this.selectionModel.includeUsers = []
|
||||||
this.selectionModel.excludeUsers.set([])
|
this.selectionModel.excludeUsers = []
|
||||||
this.selectionModel.userID.set(this.settingsService.currentUser().id)
|
this.selectionModel.userID = this.settingsService.currentUser().id
|
||||||
this.selectionModel.hideUnowned.set(false)
|
this.selectionModel.hideUnowned = false
|
||||||
} else if (this.selectionModel.ownerFilter() === OwnerFilterType.NOT_SELF) {
|
} else if (this.selectionModel.ownerFilter === OwnerFilterType.NOT_SELF) {
|
||||||
this.selectionModel.userID.set(null)
|
this.selectionModel.userID = null
|
||||||
this.selectionModel.includeUsers.set([])
|
this.selectionModel.includeUsers = []
|
||||||
this.selectionModel.excludeUsers.set([
|
this.selectionModel.excludeUsers = [this.settingsService.currentUser().id]
|
||||||
this.settingsService.currentUser().id,
|
this.selectionModel.hideUnowned = false
|
||||||
])
|
} else if (this.selectionModel.ownerFilter === OwnerFilterType.NONE) {
|
||||||
this.selectionModel.hideUnowned.set(false)
|
this.selectionModel.userID = null
|
||||||
} else if (this.selectionModel.ownerFilter() === OwnerFilterType.NONE) {
|
this.selectionModel.includeUsers = []
|
||||||
this.selectionModel.userID.set(null)
|
this.selectionModel.excludeUsers = []
|
||||||
this.selectionModel.includeUsers.set([])
|
this.selectionModel.hideUnowned = false
|
||||||
this.selectionModel.excludeUsers.set([])
|
|
||||||
this.selectionModel.hideUnowned.set(false)
|
|
||||||
} else if (
|
} else if (
|
||||||
this.selectionModel.ownerFilter() === OwnerFilterType.SHARED_BY_ME
|
this.selectionModel.ownerFilter === OwnerFilterType.SHARED_BY_ME
|
||||||
) {
|
) {
|
||||||
this.selectionModel.userID.set(this.settingsService.currentUser()?.id)
|
this.selectionModel.userID = this.settingsService.currentUser()?.id
|
||||||
this.selectionModel.includeUsers.set([])
|
this.selectionModel.includeUsers = []
|
||||||
this.selectionModel.excludeUsers.set([])
|
this.selectionModel.excludeUsers = []
|
||||||
this.selectionModel.hideUnowned.set(false)
|
this.selectionModel.hideUnowned = false
|
||||||
} else if (this.selectionModel.ownerFilter() === OwnerFilterType.UNOWNED) {
|
} else if (this.selectionModel.ownerFilter === OwnerFilterType.UNOWNED) {
|
||||||
this.selectionModel.userID.set(null)
|
this.selectionModel.userID = null
|
||||||
this.selectionModel.includeUsers.set([])
|
this.selectionModel.includeUsers = []
|
||||||
this.selectionModel.excludeUsers.set([])
|
this.selectionModel.excludeUsers = []
|
||||||
this.selectionModel.hideUnowned.set(false)
|
this.selectionModel.hideUnowned = false
|
||||||
}
|
}
|
||||||
this.onChange()
|
this.onChange()
|
||||||
}
|
}
|
||||||
@@ -206,11 +206,11 @@ export class PermissionsFilterDropdownComponent extends ComponentWithPermissions
|
|||||||
}
|
}
|
||||||
|
|
||||||
onUserSelect() {
|
onUserSelect() {
|
||||||
this.selectionModel.ownerFilter.set(
|
if (this.selectionModel.includeUsers?.length) {
|
||||||
this.selectionModel.includeUsers()?.length
|
this.selectionModel.ownerFilter = OwnerFilterType.OTHERS
|
||||||
? OwnerFilterType.OTHERS
|
} else {
|
||||||
: OwnerFilterType.NONE
|
this.selectionModel.ownerFilter = OwnerFilterType.NONE
|
||||||
)
|
}
|
||||||
this.onChange()
|
this.onChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1209,53 +1209,24 @@ describe('DocumentDetailComponent', () => {
|
|||||||
expect(fixture.debugElement.queryAll(By.css('textarea.rtl'))).not.toBeNull()
|
expect(fixture.debugElement.queryAll(By.css('textarea.rtl'))).not.toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should display built-in pdf viewer if not disabled', async () => {
|
it('should display built-in pdf viewer if not disabled', () => {
|
||||||
initNormally()
|
initNormally()
|
||||||
component.document.update((document) => ({
|
component.document().archived_file_name = 'file.pdf'
|
||||||
...document,
|
|
||||||
archived_file_name: 'file.pdf',
|
|
||||||
}))
|
|
||||||
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, false)
|
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, false)
|
||||||
expect(component.useNativePdfViewer).toBeFalsy()
|
expect(component.useNativePdfViewer).toBeFalsy()
|
||||||
await fixture.whenStable()
|
fixture.detectChanges()
|
||||||
expect(fixture.debugElement.query(By.css('pngx-pdf-viewer'))).not.toBeNull()
|
expect(fixture.debugElement.query(By.css('pngx-pdf-viewer'))).not.toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should display native pdf viewer if enabled', () => {
|
it('should display native pdf viewer if enabled', () => {
|
||||||
initNormally()
|
initNormally()
|
||||||
component.document.update((document) => ({
|
component.document().archived_file_name = 'file.pdf'
|
||||||
...document,
|
|
||||||
archived_file_name: 'file.pdf',
|
|
||||||
}))
|
|
||||||
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, true)
|
settingsService.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, true)
|
||||||
expect(component.useNativePdfViewer).toBeTruthy()
|
expect(component.useNativePdfViewer).toBeTruthy()
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(fixture.debugElement.query(By.css('object'))).not.toBeNull()
|
expect(fixture.debugElement.query(By.css('object'))).not.toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should reflect signal-backed document detail display settings', () => {
|
|
||||||
settingsService.set(SETTINGS_KEYS.DOCUMENT_EDITING_OVERLAY_THUMBNAIL, false)
|
|
||||||
settingsService.set(SETTINGS_KEYS.DOCUMENT_DETAILS_HIDDEN_FIELDS, [
|
|
||||||
component.DocumentDetailFieldID.Correspondent,
|
|
||||||
])
|
|
||||||
|
|
||||||
expect(component.showThumbnailOverlay).toBeFalsy()
|
|
||||||
expect(
|
|
||||||
component.isFieldHidden(component.DocumentDetailFieldID.Correspondent)
|
|
||||||
).toBeTruthy()
|
|
||||||
expect(
|
|
||||||
component.isFieldHidden(component.DocumentDetailFieldID.DocumentType)
|
|
||||||
).toBeFalsy()
|
|
||||||
|
|
||||||
settingsService.set(SETTINGS_KEYS.DOCUMENT_EDITING_OVERLAY_THUMBNAIL, true)
|
|
||||||
settingsService.set(SETTINGS_KEYS.DOCUMENT_DETAILS_HIDDEN_FIELDS, [])
|
|
||||||
|
|
||||||
expect(component.showThumbnailOverlay).toBeTruthy()
|
|
||||||
expect(
|
|
||||||
component.isFieldHidden(component.DocumentDetailFieldID.Correspondent)
|
|
||||||
).toBeFalsy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should attempt to retrieve metadata', () => {
|
it('should attempt to retrieve metadata', () => {
|
||||||
const metadataSpy = jest.spyOn(documentService, 'getMetadata')
|
const metadataSpy = jest.spyOn(documentService, 'getMetadata')
|
||||||
metadataSpy.mockReturnValue(of({ has_archive_version: true }))
|
metadataSpy.mockReturnValue(of({ has_archive_version: true }))
|
||||||
@@ -1714,10 +1685,7 @@ describe('DocumentDetailComponent', () => {
|
|||||||
|
|
||||||
it('should change preview element by render type', () => {
|
it('should change preview element by render type', () => {
|
||||||
initNormally()
|
initNormally()
|
||||||
component.document.update((document) => ({
|
component.document().archived_file_name = 'file.pdf'
|
||||||
...document,
|
|
||||||
archived_file_name: 'file.pdf',
|
|
||||||
}))
|
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(component.archiveContentRenderType).toEqual(
|
expect(component.archiveContentRenderType).toEqual(
|
||||||
component.ContentRenderType.PDF
|
component.ContentRenderType.PDF
|
||||||
@@ -1726,11 +1694,8 @@ describe('DocumentDetailComponent', () => {
|
|||||||
fixture.debugElement.query(By.css('pdf-viewer-container'))
|
fixture.debugElement.query(By.css('pdf-viewer-container'))
|
||||||
).not.toBeUndefined()
|
).not.toBeUndefined()
|
||||||
|
|
||||||
component.document.update((document) => ({
|
component.document().archived_file_name = undefined
|
||||||
...document,
|
component.document().mime_type = 'text/plain'
|
||||||
archived_file_name: undefined,
|
|
||||||
mime_type: 'text/plain',
|
|
||||||
}))
|
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(component.archiveContentRenderType).toEqual(
|
expect(component.archiveContentRenderType).toEqual(
|
||||||
component.ContentRenderType.Text
|
component.ContentRenderType.Text
|
||||||
@@ -1739,10 +1704,7 @@ describe('DocumentDetailComponent', () => {
|
|||||||
fixture.debugElement.query(By.css('div.preview-sticky'))
|
fixture.debugElement.query(By.css('div.preview-sticky'))
|
||||||
).not.toBeUndefined()
|
).not.toBeUndefined()
|
||||||
|
|
||||||
component.document.update((document) => ({
|
component.document().mime_type = 'image/jpeg'
|
||||||
...document,
|
|
||||||
mime_type: 'image/jpeg',
|
|
||||||
}))
|
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(component.archiveContentRenderType).toEqual(
|
expect(component.archiveContentRenderType).toEqual(
|
||||||
component.ContentRenderType.Image
|
component.ContentRenderType.Image
|
||||||
@@ -1750,12 +1712,9 @@ describe('DocumentDetailComponent', () => {
|
|||||||
expect(
|
expect(
|
||||||
fixture.debugElement.query(By.css('.preview-sticky img'))
|
fixture.debugElement.query(By.css('.preview-sticky img'))
|
||||||
).not.toBeUndefined()
|
).not.toBeUndefined()
|
||||||
component.document.update((document) => ({
|
;((component.document().mime_type =
|
||||||
...document,
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),
|
||||||
mime_type:
|
fixture.detectChanges())
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
||||||
}))
|
|
||||||
fixture.detectChanges()
|
|
||||||
expect(component.archiveContentRenderType).toEqual(
|
expect(component.archiveContentRenderType).toEqual(
|
||||||
component.ContentRenderType.Other
|
component.ContentRenderType.Other
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -227,19 +227,6 @@ export class DocumentDetailComponent
|
|||||||
private deviceDetectorService = inject(DeviceDetectorService)
|
private deviceDetectorService = inject(DeviceDetectorService)
|
||||||
private savedViewService = inject(SavedViewService)
|
private savedViewService = inject(SavedViewService)
|
||||||
private readonly websocketStatusService = inject(WebsocketStatusService)
|
private readonly websocketStatusService = inject(WebsocketStatusService)
|
||||||
private readonly useNativePdfViewerSetting = this.settings.getSignal<boolean>(
|
|
||||||
SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER
|
|
||||||
)
|
|
||||||
private readonly aiEnabledSetting = this.settings.getSignal<boolean>(
|
|
||||||
SETTINGS_KEYS.AI_ENABLED
|
|
||||||
)
|
|
||||||
private readonly showThumbnailOverlaySetting =
|
|
||||||
this.settings.getSignal<boolean>(
|
|
||||||
SETTINGS_KEYS.DOCUMENT_EDITING_OVERLAY_THUMBNAIL
|
|
||||||
)
|
|
||||||
private readonly hiddenFieldsSetting = this.settings.getSignal<
|
|
||||||
DocumentDetailFieldID[]
|
|
||||||
>(SETTINGS_KEYS.DOCUMENT_DETAILS_HIDDEN_FIELDS)
|
|
||||||
|
|
||||||
@ViewChild('inputTitle')
|
@ViewChild('inputTitle')
|
||||||
titleInput: TextComponent
|
titleInput: TextComponent
|
||||||
@@ -346,7 +333,8 @@ export class DocumentDetailComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get useNativePdfViewer(): boolean {
|
get useNativePdfViewer(): boolean {
|
||||||
return this.useNativePdfViewerSetting()
|
this.settings.trackChanges()
|
||||||
|
return this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER)
|
||||||
}
|
}
|
||||||
|
|
||||||
get isMobile(): boolean {
|
get isMobile(): boolean {
|
||||||
@@ -354,10 +342,12 @@ export class DocumentDetailComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get aiEnabled(): boolean {
|
get aiEnabled(): boolean {
|
||||||
return this.aiEnabledSetting()
|
this.settings.trackChanges()
|
||||||
|
return this.settings.get(SETTINGS_KEYS.AI_ENABLED)
|
||||||
}
|
}
|
||||||
|
|
||||||
get archiveContentRenderType(): ContentRenderType {
|
get archiveContentRenderType(): ContentRenderType {
|
||||||
|
this.settings.trackChanges()
|
||||||
const hasArchiveVersion =
|
const hasArchiveVersion =
|
||||||
this.metadata()?.has_archive_version ??
|
this.metadata()?.has_archive_version ??
|
||||||
!!this.document()?.archived_file_name
|
!!this.document()?.archived_file_name
|
||||||
@@ -369,17 +359,22 @@ export class DocumentDetailComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get originalContentRenderType(): ContentRenderType {
|
get originalContentRenderType(): ContentRenderType {
|
||||||
|
this.settings.trackChanges()
|
||||||
return this.getRenderType(
|
return this.getRenderType(
|
||||||
this.metadata()?.original_mime_type || this.document()?.mime_type
|
this.metadata()?.original_mime_type || this.document()?.mime_type
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
get showThumbnailOverlay(): boolean {
|
get showThumbnailOverlay(): boolean {
|
||||||
return this.showThumbnailOverlaySetting()
|
this.settings.trackChanges()
|
||||||
|
return this.settings.get(SETTINGS_KEYS.DOCUMENT_EDITING_OVERLAY_THUMBNAIL)
|
||||||
}
|
}
|
||||||
|
|
||||||
isFieldHidden(fieldId: DocumentDetailFieldID): boolean {
|
isFieldHidden(fieldId: DocumentDetailFieldID): boolean {
|
||||||
return this.hiddenFieldsSetting().includes(fieldId)
|
this.settings.trackChanges()
|
||||||
|
return this.settings
|
||||||
|
.get(SETTINGS_KEYS.DOCUMENT_DETAILS_HIDDEN_FIELDS)
|
||||||
|
.includes(fieldId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRenderType(mimeType: string): ContentRenderType {
|
private getRenderType(mimeType: string): ContentRenderType {
|
||||||
|
|||||||
@@ -121,8 +121,6 @@ export class DocumentListComponent
|
|||||||
settingsService = inject(SettingsService)
|
settingsService = inject(SettingsService)
|
||||||
private hotKeyService = inject(HotKeyService)
|
private hotKeyService = inject(HotKeyService)
|
||||||
permissionService = inject(PermissionsService)
|
permissionService = inject(PermissionsService)
|
||||||
private readonly notesEnabledSetting =
|
|
||||||
this.settingsService.getSignal<boolean>(SETTINGS_KEYS.NOTES_ENABLED)
|
|
||||||
|
|
||||||
DisplayField = DisplayField
|
DisplayField = DisplayField
|
||||||
DisplayMode = DisplayMode
|
DisplayMode = DisplayMode
|
||||||
@@ -576,7 +574,8 @@ export class DocumentListComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
get notesEnabled(): boolean {
|
get notesEnabled(): boolean {
|
||||||
return this.notesEnabledSetting()
|
this.settingsService.trackChanges()
|
||||||
|
return this.settingsService.get(SETTINGS_KEYS.NOTES_ENABLED)
|
||||||
}
|
}
|
||||||
|
|
||||||
resetFilters() {
|
resetFilters() {
|
||||||
|
|||||||
+20
-86
@@ -621,43 +621,6 @@ describe('FilterEditorComponent', () => {
|
|||||||
component.toggleTag(2) // coverage
|
component.toggleTag(2) // coverage
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should reflect ingested tag filter rules in the dropdown toggle', () => {
|
|
||||||
const dropdown = fixture.debugElement.query(
|
|
||||||
By.css('pngx-filterable-dropdown')
|
|
||||||
)
|
|
||||||
const toggle = dropdown.nativeElement.querySelector('#dropdown_tags')
|
|
||||||
expect(toggle.classList.contains('btn-primary')).toBeFalsy()
|
|
||||||
expect(
|
|
||||||
dropdown.nativeElement.querySelector('pngx-clearable-badge')
|
|
||||||
).toBeNull()
|
|
||||||
|
|
||||||
// switching to a view with a tag filter
|
|
||||||
component.filterRules = [
|
|
||||||
{
|
|
||||||
rule_type: FILTER_HAS_TAGS_ALL,
|
|
||||||
value: '2',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
fixture.detectChanges()
|
|
||||||
expect(toggle.classList.contains('btn-primary')).toBeTruthy()
|
|
||||||
expect(
|
|
||||||
dropdown.nativeElement.querySelector('pngx-clearable-badge')
|
|
||||||
).not.toBeNull()
|
|
||||||
|
|
||||||
// and back to a view without one
|
|
||||||
component.filterRules = [
|
|
||||||
{
|
|
||||||
rule_type: FILTER_HAS_CORRESPONDENT_ANY,
|
|
||||||
value: '12',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
fixture.detectChanges()
|
|
||||||
expect(toggle.classList.contains('btn-primary')).toBeFalsy()
|
|
||||||
expect(
|
|
||||||
dropdown.nativeElement.querySelector('pngx-clearable-badge')
|
|
||||||
).toBeNull()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should ingest filter rules for has any tags', () => {
|
it('should ingest filter rules for has any tags', () => {
|
||||||
expect(component.tagSelectionModel.getSelectedItems()).toHaveLength(0)
|
expect(component.tagSelectionModel.getSelectedItems()).toHaveLength(0)
|
||||||
component.filterRules = [
|
component.filterRules = [
|
||||||
@@ -1115,7 +1078,7 @@ describe('FilterEditorComponent', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should ingest filter rules for owner', () => {
|
it('should ingest filter rules for owner', () => {
|
||||||
expect(component.permissionsSelectionModel.ownerFilter()).toEqual(
|
expect(component.permissionsSelectionModel.ownerFilter).toEqual(
|
||||||
OwnerFilterType.NONE
|
OwnerFilterType.NONE
|
||||||
)
|
)
|
||||||
component.filterRules = [
|
component.filterRules = [
|
||||||
@@ -1124,38 +1087,15 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '100',
|
value: '100',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.permissionsSelectionModel.ownerFilter()).toEqual(
|
expect(component.permissionsSelectionModel.ownerFilter).toEqual(
|
||||||
OwnerFilterType.SELF
|
OwnerFilterType.SELF
|
||||||
)
|
)
|
||||||
expect(component.permissionsSelectionModel.hideUnowned()).toBeFalsy()
|
expect(component.permissionsSelectionModel.hideUnowned).toBeFalsy()
|
||||||
expect(component.permissionsSelectionModel.userID()).toEqual(100)
|
expect(component.permissionsSelectionModel.userID).toEqual(100)
|
||||||
})
|
|
||||||
|
|
||||||
it('should reflect ingested owner filter rules in the dropdown toggle', () => {
|
|
||||||
const dropdown = fixture.debugElement.query(
|
|
||||||
By.css('pngx-permissions-filter-dropdown')
|
|
||||||
)
|
|
||||||
const toggle = dropdown.nativeElement.querySelector('button')
|
|
||||||
expect(toggle.classList.contains('btn-primary')).toBeFalsy()
|
|
||||||
|
|
||||||
// switching to a view with an owner filter
|
|
||||||
component.filterRules = [
|
|
||||||
{
|
|
||||||
rule_type: FILTER_OWNER,
|
|
||||||
value: '100',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
fixture.detectChanges()
|
|
||||||
expect(toggle.classList.contains('btn-primary')).toBeTruthy()
|
|
||||||
|
|
||||||
// and back to a view without one
|
|
||||||
component.filterRules = []
|
|
||||||
fixture.detectChanges()
|
|
||||||
expect(toggle.classList.contains('btn-primary')).toBeFalsy()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ingest filter rules for owner is others', () => {
|
it('should ingest filter rules for owner is others', () => {
|
||||||
expect(component.permissionsSelectionModel.ownerFilter()).toEqual(
|
expect(component.permissionsSelectionModel.ownerFilter).toEqual(
|
||||||
OwnerFilterType.NONE
|
OwnerFilterType.NONE
|
||||||
)
|
)
|
||||||
component.filterRules = [
|
component.filterRules = [
|
||||||
@@ -1164,14 +1104,14 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '50',
|
value: '50',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.permissionsSelectionModel.ownerFilter()).toEqual(
|
expect(component.permissionsSelectionModel.ownerFilter).toEqual(
|
||||||
OwnerFilterType.OTHERS
|
OwnerFilterType.OTHERS
|
||||||
)
|
)
|
||||||
expect(component.permissionsSelectionModel.includeUsers()).toContain(50)
|
expect(component.permissionsSelectionModel.includeUsers).toContain(50)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ingest filter rules for owner does not include others', () => {
|
it('should ingest filter rules for owner does not include others', () => {
|
||||||
expect(component.permissionsSelectionModel.ownerFilter()).toEqual(
|
expect(component.permissionsSelectionModel.ownerFilter).toEqual(
|
||||||
OwnerFilterType.NONE
|
OwnerFilterType.NONE
|
||||||
)
|
)
|
||||||
component.filterRules = [
|
component.filterRules = [
|
||||||
@@ -1180,14 +1120,14 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '50',
|
value: '50',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.permissionsSelectionModel.ownerFilter()).toEqual(
|
expect(component.permissionsSelectionModel.ownerFilter).toEqual(
|
||||||
OwnerFilterType.NOT_SELF
|
OwnerFilterType.NOT_SELF
|
||||||
)
|
)
|
||||||
expect(component.permissionsSelectionModel.excludeUsers()).toContain(50)
|
expect(component.permissionsSelectionModel.excludeUsers).toContain(50)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ingest filter rules for owner is null', () => {
|
it('should ingest filter rules for owner is null', () => {
|
||||||
expect(component.permissionsSelectionModel.ownerFilter()).toEqual(
|
expect(component.permissionsSelectionModel.ownerFilter).toEqual(
|
||||||
OwnerFilterType.NONE
|
OwnerFilterType.NONE
|
||||||
)
|
)
|
||||||
component.filterRules = [
|
component.filterRules = [
|
||||||
@@ -1196,10 +1136,10 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: 'true',
|
value: 'true',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.permissionsSelectionModel.ownerFilter()).toEqual(
|
expect(component.permissionsSelectionModel.ownerFilter).toEqual(
|
||||||
OwnerFilterType.UNOWNED
|
OwnerFilterType.UNOWNED
|
||||||
)
|
)
|
||||||
expect(component.permissionsSelectionModel.hideUnowned()).toBeFalsy()
|
expect(component.permissionsSelectionModel.hideUnowned).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ingest filter rules for owner is not null', () => {
|
it('should ingest filter rules for owner is not null', () => {
|
||||||
@@ -1209,14 +1149,14 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: 'false',
|
value: 'false',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.permissionsSelectionModel.hideUnowned()).toBeTruthy()
|
expect(component.permissionsSelectionModel.hideUnowned).toBeTruthy()
|
||||||
component.filterRules = [
|
component.filterRules = [
|
||||||
{
|
{
|
||||||
rule_type: FILTER_OWNER_ISNULL,
|
rule_type: FILTER_OWNER_ISNULL,
|
||||||
value: '0',
|
value: '0',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.permissionsSelectionModel.hideUnowned()).toBeTruthy()
|
expect(component.permissionsSelectionModel.hideUnowned).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ingest filter rules for shared by me', () => {
|
it('should ingest filter rules for shared by me', () => {
|
||||||
@@ -1226,7 +1166,7 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '2',
|
value: '2',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
expect(component.permissionsSelectionModel.userID()).toEqual(2)
|
expect(component.permissionsSelectionModel.userID).toEqual(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
// GET filterRules
|
// GET filterRules
|
||||||
@@ -1992,10 +1932,7 @@ describe('FilterEditorComponent', () => {
|
|||||||
value: '1',
|
value: '1',
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
component.permissionsSelectionModel.excludeUsers.update((users) => [
|
component.permissionsSelectionModel.excludeUsers.push(2)
|
||||||
...users,
|
|
||||||
2,
|
|
||||||
])
|
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(component.filterRules).toEqual([
|
expect(component.filterRules).toEqual([
|
||||||
{
|
{
|
||||||
@@ -2045,11 +1982,8 @@ describe('FilterEditorComponent', () => {
|
|||||||
// TODO: mock input in code
|
// TODO: mock input in code
|
||||||
// userSelect.query(By.css('input')).nativeElement.value = '3'
|
// userSelect.query(By.css('input')).nativeElement.value = '3'
|
||||||
// userSelect.triggerEventHandler('change')
|
// userSelect.triggerEventHandler('change')
|
||||||
component.permissionsSelectionModel.ownerFilter.set(OwnerFilterType.OTHERS)
|
component.permissionsSelectionModel.ownerFilter = OwnerFilterType.OTHERS
|
||||||
component.permissionsSelectionModel.includeUsers.update((users) => [
|
component.permissionsSelectionModel.includeUsers.push(3)
|
||||||
...users,
|
|
||||||
3,
|
|
||||||
])
|
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(component.filterRules).toEqual([
|
expect(component.filterRules).toEqual([
|
||||||
{
|
{
|
||||||
@@ -2069,7 +2003,7 @@ describe('FilterEditorComponent', () => {
|
|||||||
ownerToggle.nativeElement.checked = true
|
ownerToggle.nativeElement.checked = true
|
||||||
// ownerToggle.triggerEventHandler('change')
|
// ownerToggle.triggerEventHandler('change')
|
||||||
// TODO: ngModel isn't doing this here
|
// TODO: ngModel isn't doing this here
|
||||||
component.permissionsSelectionModel.hideUnowned.set(true)
|
component.permissionsSelectionModel.hideUnowned = true
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(component.filterRules).toEqual([
|
expect(component.filterRules).toEqual([
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -735,50 +735,38 @@ export class FilterEditorComponent
|
|||||||
this._textFilter = rule.value
|
this._textFilter = rule.value
|
||||||
break
|
break
|
||||||
case FILTER_OWNER:
|
case FILTER_OWNER:
|
||||||
this.permissionsSelectionModel.ownerFilter.set(OwnerFilterType.SELF)
|
this.permissionsSelectionModel.ownerFilter = OwnerFilterType.SELF
|
||||||
this.permissionsSelectionModel.hideUnowned.set(false)
|
this.permissionsSelectionModel.hideUnowned = false
|
||||||
if (rule.value)
|
if (rule.value)
|
||||||
this.permissionsSelectionModel.userID.set(
|
this.permissionsSelectionModel.userID = parseInt(rule.value, 10)
|
||||||
Number.parseInt(rule.value, 10)
|
|
||||||
)
|
|
||||||
break
|
break
|
||||||
case FILTER_OWNER_ANY:
|
case FILTER_OWNER_ANY:
|
||||||
this.permissionsSelectionModel.ownerFilter.set(OwnerFilterType.OTHERS)
|
this.permissionsSelectionModel.ownerFilter = OwnerFilterType.OTHERS
|
||||||
if (rule.value)
|
if (rule.value)
|
||||||
this.permissionsSelectionModel.includeUsers.update((users) => [
|
this.permissionsSelectionModel.includeUsers.push(
|
||||||
...users,
|
parseInt(rule.value, 10)
|
||||||
Number.parseInt(rule.value, 10),
|
)
|
||||||
])
|
|
||||||
break
|
break
|
||||||
case FILTER_OWNER_DOES_NOT_INCLUDE:
|
case FILTER_OWNER_DOES_NOT_INCLUDE:
|
||||||
this.permissionsSelectionModel.ownerFilter.set(
|
this.permissionsSelectionModel.ownerFilter = OwnerFilterType.NOT_SELF
|
||||||
OwnerFilterType.NOT_SELF
|
|
||||||
)
|
|
||||||
if (rule.value)
|
if (rule.value)
|
||||||
this.permissionsSelectionModel.excludeUsers.update((users) => [
|
this.permissionsSelectionModel.excludeUsers.push(
|
||||||
...users,
|
parseInt(rule.value, 10)
|
||||||
Number.parseInt(rule.value, 10),
|
)
|
||||||
])
|
|
||||||
break
|
break
|
||||||
case FILTER_SHARED_BY_USER:
|
case FILTER_SHARED_BY_USER:
|
||||||
this.permissionsSelectionModel.ownerFilter.set(
|
this.permissionsSelectionModel.ownerFilter =
|
||||||
OwnerFilterType.SHARED_BY_ME
|
OwnerFilterType.SHARED_BY_ME
|
||||||
)
|
|
||||||
if (rule.value)
|
if (rule.value)
|
||||||
this.permissionsSelectionModel.userID.set(
|
this.permissionsSelectionModel.userID = parseInt(rule.value, 10)
|
||||||
Number.parseInt(rule.value, 10)
|
|
||||||
)
|
|
||||||
break
|
break
|
||||||
case FILTER_OWNER_ISNULL:
|
case FILTER_OWNER_ISNULL:
|
||||||
if (rule.value === 'true' || rule.value === '1') {
|
if (rule.value === 'true' || rule.value === '1') {
|
||||||
this.permissionsSelectionModel.hideUnowned.set(false)
|
this.permissionsSelectionModel.hideUnowned = false
|
||||||
this.permissionsSelectionModel.ownerFilter.set(
|
this.permissionsSelectionModel.ownerFilter = OwnerFilterType.UNOWNED
|
||||||
OwnerFilterType.UNOWNED
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
this.permissionsSelectionModel.hideUnowned.set(
|
this.permissionsSelectionModel.hideUnowned =
|
||||||
rule.value === 'false' || rule.value === '0'
|
rule.value === 'false' || rule.value === '0'
|
||||||
)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1086,35 +1074,34 @@ export class FilterEditorComponent
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.permissionsSelectionModel.ownerFilter() == OwnerFilterType.SELF) {
|
if (this.permissionsSelectionModel.ownerFilter == OwnerFilterType.SELF) {
|
||||||
filterRules.push({
|
filterRules.push({
|
||||||
rule_type: FILTER_OWNER,
|
rule_type: FILTER_OWNER,
|
||||||
value: this.permissionsSelectionModel.userID().toString(),
|
value: this.permissionsSelectionModel.userID.toString(),
|
||||||
})
|
})
|
||||||
} else if (
|
} else if (
|
||||||
this.permissionsSelectionModel.ownerFilter() == OwnerFilterType.NOT_SELF
|
this.permissionsSelectionModel.ownerFilter == OwnerFilterType.NOT_SELF
|
||||||
) {
|
) {
|
||||||
filterRules.push({
|
filterRules.push({
|
||||||
rule_type: FILTER_OWNER_DOES_NOT_INCLUDE,
|
rule_type: FILTER_OWNER_DOES_NOT_INCLUDE,
|
||||||
value: this.permissionsSelectionModel.excludeUsers()?.join(','),
|
value: this.permissionsSelectionModel.excludeUsers?.join(','),
|
||||||
})
|
})
|
||||||
} else if (
|
} else if (
|
||||||
this.permissionsSelectionModel.ownerFilter() == OwnerFilterType.OTHERS
|
this.permissionsSelectionModel.ownerFilter == OwnerFilterType.OTHERS
|
||||||
) {
|
) {
|
||||||
filterRules.push({
|
filterRules.push({
|
||||||
rule_type: FILTER_OWNER_ANY,
|
rule_type: FILTER_OWNER_ANY,
|
||||||
value: this.permissionsSelectionModel.includeUsers()?.join(','),
|
value: this.permissionsSelectionModel.includeUsers?.join(','),
|
||||||
})
|
})
|
||||||
} else if (
|
} else if (
|
||||||
this.permissionsSelectionModel.ownerFilter() ==
|
this.permissionsSelectionModel.ownerFilter == OwnerFilterType.SHARED_BY_ME
|
||||||
OwnerFilterType.SHARED_BY_ME
|
|
||||||
) {
|
) {
|
||||||
filterRules.push({
|
filterRules.push({
|
||||||
rule_type: FILTER_SHARED_BY_USER,
|
rule_type: FILTER_SHARED_BY_USER,
|
||||||
value: this.permissionsSelectionModel.userID().toString(),
|
value: this.permissionsSelectionModel.userID.toString(),
|
||||||
})
|
})
|
||||||
} else if (
|
} else if (
|
||||||
this.permissionsSelectionModel.ownerFilter() == OwnerFilterType.UNOWNED
|
this.permissionsSelectionModel.ownerFilter == OwnerFilterType.UNOWNED
|
||||||
) {
|
) {
|
||||||
filterRules.push({
|
filterRules.push({
|
||||||
rule_type: FILTER_OWNER_ISNULL,
|
rule_type: FILTER_OWNER_ISNULL,
|
||||||
@@ -1122,7 +1109,7 @@ export class FilterEditorComponent
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.permissionsSelectionModel.hideUnowned()) {
|
if (this.permissionsSelectionModel.hideUnowned) {
|
||||||
filterRules.push({
|
filterRules.push({
|
||||||
rule_type: FILTER_OWNER_ISNULL,
|
rule_type: FILTER_OWNER_ISNULL,
|
||||||
value: 'false',
|
value: 'false',
|
||||||
|
|||||||
@@ -210,48 +210,6 @@ describe('SettingsService', () => {
|
|||||||
expect(settingsService.get(SETTINGS_KEYS.THEME_COLOR)).toEqual('#000000')
|
expect(settingsService.get(SETTINGS_KEYS.THEME_COLOR)).toEqual('#000000')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('provides stable signals that update when settings change', () => {
|
|
||||||
const req = httpTestingController.expectOne(
|
|
||||||
`${environment.apiBaseUrl}ui_settings/`
|
|
||||||
)
|
|
||||||
req.flush(ui_settings)
|
|
||||||
|
|
||||||
const notesEnabled = settingsService.getSignal<boolean>(
|
|
||||||
SETTINGS_KEYS.NOTES_ENABLED
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(notesEnabled()).toBeTruthy()
|
|
||||||
expect(
|
|
||||||
settingsService.getSignal<boolean>(SETTINGS_KEYS.NOTES_ENABLED)
|
|
||||||
).toBe(notesEnabled)
|
|
||||||
|
|
||||||
settingsService.set(SETTINGS_KEYS.NOTES_ENABLED, false)
|
|
||||||
|
|
||||||
expect(notesEnabled()).toBeFalsy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('updates setting signals when settings are reinitialized', () => {
|
|
||||||
let req = httpTestingController.expectOne(
|
|
||||||
`${environment.apiBaseUrl}ui_settings/`
|
|
||||||
)
|
|
||||||
req.flush(ui_settings)
|
|
||||||
const appTitle = settingsService.getSignal<string>(SETTINGS_KEYS.APP_TITLE)
|
|
||||||
|
|
||||||
settingsService.initializeSettings().subscribe()
|
|
||||||
req = httpTestingController.expectOne(
|
|
||||||
`${environment.apiBaseUrl}ui_settings/`
|
|
||||||
)
|
|
||||||
req.flush({
|
|
||||||
...ui_settings,
|
|
||||||
settings: {
|
|
||||||
...ui_settings.settings,
|
|
||||||
app_title: 'Updated title',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(appTitle()).toBe('Updated title')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('sets django cookie for languages', () => {
|
it('sets django cookie for languages', () => {
|
||||||
httpTestingController
|
httpTestingController
|
||||||
.expectOne(`${environment.apiBaseUrl}ui_settings/`)
|
.expectOne(`${environment.apiBaseUrl}ui_settings/`)
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { HttpClient } from '@angular/common/http'
|
|||||||
import {
|
import {
|
||||||
DOCUMENT,
|
DOCUMENT,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
Signal,
|
|
||||||
computed,
|
|
||||||
inject,
|
inject,
|
||||||
Injectable,
|
Injectable,
|
||||||
LOCALE_ID,
|
LOCALE_ID,
|
||||||
@@ -299,7 +297,6 @@ export class SettingsService {
|
|||||||
|
|
||||||
private settings: Record<string, any> = {}
|
private settings: Record<string, any> = {}
|
||||||
private readonly settingsVersion = signal(0)
|
private readonly settingsVersion = signal(0)
|
||||||
private readonly settingSignals = new Map<string, Signal<unknown>>()
|
|
||||||
readonly currentUser = signal<User>(undefined)
|
readonly currentUser = signal<User>(undefined)
|
||||||
|
|
||||||
public settingsSaved: EventEmitter<any> = new EventEmitter()
|
public settingsSaved: EventEmitter<any> = new EventEmitter()
|
||||||
@@ -329,6 +326,10 @@ export class SettingsService {
|
|||||||
return !UNSAFE_OBJECT_KEYS.has(key)
|
return !UNSAFE_OBJECT_KEYS.has(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public trackChanges(): void {
|
||||||
|
this.settingsVersion()
|
||||||
|
}
|
||||||
|
|
||||||
private assignSafeSettings(source: Record<string, any>) {
|
private assignSafeSettings(source: Record<string, any>) {
|
||||||
if (!source || typeof source !== 'object' || Array.isArray(source)) {
|
if (!source || typeof source !== 'object' || Array.isArray(source)) {
|
||||||
return
|
return
|
||||||
@@ -338,7 +339,6 @@ export class SettingsService {
|
|||||||
if (!this.isSafeObjectKey(key)) continue
|
if (!this.isSafeObjectKey(key)) continue
|
||||||
this.settings[key] = source[key]
|
this.settings[key] = source[key]
|
||||||
}
|
}
|
||||||
this.settingsVersion.update((version) => version + 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is called by the app initializer in app.module
|
// this is called by the app initializer in app.module
|
||||||
@@ -594,18 +594,6 @@ export class SettingsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getSignal<T = any>(key: string): Signal<T> {
|
|
||||||
let settingSignal = this.settingSignals.get(key)
|
|
||||||
if (!settingSignal) {
|
|
||||||
settingSignal = computed(() => {
|
|
||||||
this.settingsVersion()
|
|
||||||
return this.get(key)
|
|
||||||
})
|
|
||||||
this.settingSignals.set(key, settingSignal)
|
|
||||||
}
|
|
||||||
return settingSignal as Signal<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
set(key: string, value: any) {
|
set(key: string, value: any) {
|
||||||
// parse key:key:key into nested object
|
// parse key:key:key into nested object
|
||||||
let settingObj = this.settings
|
let settingObj = this.settings
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export const environment = {
|
|||||||
apiVersion: '10', // match src/paperless/settings.py
|
apiVersion: '10', // match src/paperless/settings.py
|
||||||
appTitle: DEFAULT_APP_TITLE,
|
appTitle: DEFAULT_APP_TITLE,
|
||||||
tag: 'prod',
|
tag: 'prod',
|
||||||
version: '3.1.3',
|
version: '3.1.2',
|
||||||
webSocketHost: window.location.host,
|
webSocketHost: window.location.host,
|
||||||
webSocketProtocol: window.location.protocol == 'https:' ? 'wss:' : 'ws:',
|
webSocketProtocol: window.location.protocol == 'https:' ? 'wss:' : 'ws:',
|
||||||
webSocketBaseUrl: base_url.pathname + 'ws/',
|
webSocketBaseUrl: base_url.pathname + 'ws/',
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -507,8 +507,8 @@ def rotate(
|
|||||||
logger.info(
|
logger.info(
|
||||||
f"Queued new rotated version for document {pair.root_doc.id} by {degrees} degrees",
|
f"Queued new rotated version for document {pair.root_doc.id} by {degrees} degrees",
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.exception(f"Error rotating document {pair.root_doc.id}: {e}")
|
logger.exception(f"Error rotating document {pair.root_doc.id}")
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|
||||||
@@ -554,9 +554,9 @@ def merge(
|
|||||||
affected_docs.append(doc.id)
|
affected_docs.append(doc.id)
|
||||||
if handoff_asn is None and doc.archive_serial_number is not None:
|
if handoff_asn is None and doc.archive_serial_number is not None:
|
||||||
handoff_asn = doc.archive_serial_number
|
handoff_asn = doc.archive_serial_number
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"Error merging document {doc.id}, it will not be included in the merge: {e}",
|
f"Error merging document {doc.id}, it will not be included in the merge",
|
||||||
)
|
)
|
||||||
if len(affected_docs) == 0:
|
if len(affected_docs) == 0:
|
||||||
logger.warning("No documents were merged")
|
logger.warning("No documents were merged")
|
||||||
@@ -805,8 +805,8 @@ def split(
|
|||||||
else:
|
else:
|
||||||
group(consume_tasks).delay()
|
group(consume_tasks).delay()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.exception(f"Error splitting document {doc.id}: {e}")
|
logger.exception(f"Error splitting document {doc.id}")
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|
||||||
@@ -858,8 +858,8 @@ def delete_pages(
|
|||||||
logger.info(
|
logger.info(
|
||||||
f"Queued new version for document {pair.root_doc.id} after deleting pages {pages}",
|
f"Queued new version for document {pair.root_doc.id} after deleting pages {pages}",
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.exception(f"Error deleting pages from document {pair.root_doc.id}: {e}")
|
logger.exception(f"Error deleting pages from document {pair.root_doc.id}")
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|
||||||
@@ -986,7 +986,7 @@ def edit_pdf(
|
|||||||
group(consume_tasks).delay()
|
group(consume_tasks).delay()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"Error editing document {pair.root_doc.id}: {e}")
|
logger.exception(f"Error editing document {pair.root_doc.id}")
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"An error occurred while editing the document: {e}",
|
f"An error occurred while editing the document: {e}",
|
||||||
) from e
|
) from e
|
||||||
@@ -1097,7 +1097,7 @@ def remove_password(
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"Error removing password from document {pair.root_doc.id}: {e}",
|
f"Error removing password from document {pair.root_doc.id}",
|
||||||
)
|
)
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"An error occurred while removing the password: {e}",
|
f"An error occurred while removing the password: {e}",
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ def load_classifier(*, raise_exception: bool = False) -> DocumentClassifier | No
|
|||||||
Path(settings.MODEL_FILE).unlink()
|
Path(settings.MODEL_FILE).unlink()
|
||||||
classifier = None
|
classifier = None
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
raise e
|
raise
|
||||||
except ClassifierModelCorruptError as e:
|
except ClassifierModelCorruptError:
|
||||||
# there's something wrong with the model file.
|
# there's something wrong with the model file.
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Unrecoverable error while loading document "
|
"Unrecoverable error while loading document "
|
||||||
@@ -82,17 +82,17 @@ def load_classifier(*, raise_exception: bool = False) -> DocumentClassifier | No
|
|||||||
Path(settings.MODEL_FILE).unlink()
|
Path(settings.MODEL_FILE).unlink()
|
||||||
classifier = None
|
classifier = None
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
raise e
|
raise
|
||||||
except OSError as e:
|
except OSError:
|
||||||
logger.exception("IO error while loading document classification model")
|
logger.exception("IO error while loading document classification model")
|
||||||
classifier = None
|
classifier = None
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
raise e
|
raise
|
||||||
except Exception as e: # pragma: no cover
|
except Exception: # pragma: no cover
|
||||||
logger.exception("Unknown error while loading document classification model")
|
logger.exception("Unknown error while loading document classification model")
|
||||||
classifier = None
|
classifier = None
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
return classifier
|
return classifier
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ class ConsumerPluginMixin:
|
|||||||
current_progress,
|
current_progress,
|
||||||
max_progress,
|
max_progress,
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
owner_id=self.metadata.owner_id if self.metadata.owner_id else None,
|
owner_id=self.metadata.owner_id or None,
|
||||||
users_can_view=(self.metadata.view_users or [])
|
users_can_view=(self.metadata.view_users or [])
|
||||||
+ (self.metadata.change_users or []),
|
+ (self.metadata.change_users or []),
|
||||||
groups_can_view=(self.metadata.view_groups or [])
|
groups_can_view=(self.metadata.view_groups or [])
|
||||||
@@ -675,9 +675,7 @@ class ConsumerPlugin(
|
|||||||
document=document,
|
document=document,
|
||||||
logging_group=self.logging_group,
|
logging_group=self.logging_group,
|
||||||
classifier=classifier,
|
classifier=classifier,
|
||||||
original_file=self.unmodified_original
|
original_file=self.unmodified_original or self.working_copy,
|
||||||
if self.unmodified_original
|
|
||||||
else self.working_copy,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# After everything is in the database, copy the files into
|
# After everything is in the database, copy the files into
|
||||||
@@ -858,7 +856,7 @@ class ConsumerPlugin(
|
|||||||
else:
|
else:
|
||||||
stats = Path(self.input_doc.original_file).stat()
|
stats = Path(self.input_doc.original_file).stat()
|
||||||
create_date = timezone.make_aware(
|
create_date = timezone.make_aware(
|
||||||
datetime.datetime.fromtimestamp(stats.st_mtime),
|
datetime.datetime.fromtimestamp(stats.st_mtime), # noqa: DTZ006 - make_aware() requires a naive datetime
|
||||||
)
|
)
|
||||||
self.log.debug(f"Creation date from st_mtime: {create_date}")
|
self.log.debug(f"Creation date from st_mtime: {create_date}")
|
||||||
|
|
||||||
@@ -972,7 +970,7 @@ class ConsumerPlugin(
|
|||||||
try:
|
try:
|
||||||
copy_basic_file_stats(source, target)
|
copy_basic_file_stats(source, target)
|
||||||
except Exception: # pragma: no cover
|
except Exception: # pragma: no cover
|
||||||
pass
|
self.log.debug("Unable to copy file stats from %s to %s", source, target)
|
||||||
|
|
||||||
|
|
||||||
class ConsumerPreflightPlugin(
|
class ConsumerPreflightPlugin(
|
||||||
|
|||||||
@@ -78,7 +78,9 @@ class CollatePlugin(NoCleanupPluginMixin, NoSetupPluginMixin, ConsumeTaskPlugin)
|
|||||||
stats = staging.stat()
|
stats = staging.stat()
|
||||||
# if the file is older than the timeout, we don't consider
|
# if the file is older than the timeout, we don't consider
|
||||||
# it valid
|
# it valid
|
||||||
if (dt.datetime.now().timestamp() - stats.st_mtime) > TIMEOUT_SECONDS:
|
if (
|
||||||
|
dt.datetime.now(tz=dt.UTC).timestamp() - stats.st_mtime
|
||||||
|
) > TIMEOUT_SECONDS:
|
||||||
logger.warning("Outdated double sided staging file exists, deleting it")
|
logger.warning("Outdated double sided staging file exists, deleting it")
|
||||||
staging.unlink()
|
staging.unlink()
|
||||||
else:
|
else:
|
||||||
@@ -134,7 +136,7 @@ class CollatePlugin(NoCleanupPluginMixin, NoSetupPluginMixin, ConsumeTaskPlugin)
|
|||||||
shutil.move(pdf_file, staging)
|
shutil.move(pdf_file, staging)
|
||||||
# update access to modification time so we know if the file
|
# update access to modification time so we know if the file
|
||||||
# is outdated when another file gets uploaded
|
# is outdated when another file gets uploaded
|
||||||
timestamp = dt.datetime.now().timestamp()
|
timestamp = dt.datetime.now(tz=dt.UTC).timestamp()
|
||||||
os.utime(staging, (timestamp, timestamp))
|
os.utime(staging, (timestamp, timestamp))
|
||||||
logger.info(
|
logger.info(
|
||||||
"Got scan with odd numbered pages of double-sided scan, moved it to %s",
|
"Got scan with odd numbered pages of double-sided scan, moved it to %s",
|
||||||
|
|||||||
@@ -734,7 +734,7 @@ class CustomFieldQueryParser:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Check if any of the requested IDs are missing.
|
# Check if any of the requested IDs are missing.
|
||||||
missing_ids = set(value) - set(link.document_id for link in links)
|
missing_ids = set(value) - {link.document_id for link in links}
|
||||||
if missing_ids:
|
if missing_ids:
|
||||||
# The result should be an empty set in this case.
|
# The result should be an empty set in this case.
|
||||||
return Q(id__in=[])
|
return Q(id__in=[])
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ def _consume_file(
|
|||||||
consumption_dir: Path,
|
consumption_dir: Path,
|
||||||
*,
|
*,
|
||||||
subdirs_as_tags: bool,
|
subdirs_as_tags: bool,
|
||||||
) -> bool:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Queue a file for consumption.
|
Queue a file for consumption.
|
||||||
|
|
||||||
@@ -322,20 +322,15 @@ def _consume_file(
|
|||||||
filepath: Path to the file to consume.
|
filepath: Path to the file to consume.
|
||||||
consumption_dir: Base consumption directory.
|
consumption_dir: Base consumption directory.
|
||||||
subdirs_as_tags: Whether to create tags from subdirectory names.
|
subdirs_as_tags: Whether to create tags from subdirectory names.
|
||||||
|
|
||||||
Returns:
|
|
||||||
True if the file was successfully handed to Celery, False otherwise.
|
|
||||||
Callers must not record the file as queued on failure, or the rescan
|
|
||||||
will never retry it.
|
|
||||||
"""
|
"""
|
||||||
# Verify file still exists and is accessible
|
# Verify file still exists and is accessible
|
||||||
try:
|
try:
|
||||||
if not filepath.is_file():
|
if not filepath.is_file():
|
||||||
logger.debug(f"Not consuming {filepath}: not a file or doesn't exist")
|
logger.debug(f"Not consuming {filepath}: not a file or doesn't exist")
|
||||||
return False
|
return
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
logger.warning(f"Not consuming {filepath}: {e}")
|
logger.warning(f"Not consuming {filepath}: {e}")
|
||||||
return False
|
return
|
||||||
|
|
||||||
# Get tags from path if configured
|
# Get tags from path if configured
|
||||||
tag_ids: list[int] | None = None
|
tag_ids: list[int] | None = None
|
||||||
@@ -360,9 +355,6 @@ def _consume_file(
|
|||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(f"Error while queuing document {filepath}")
|
logger.exception(f"Error while queuing document {filepath}")
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@@ -500,12 +492,12 @@ class Command(BaseCommand):
|
|||||||
if not consumer_filter(Change.added, str(filepath)):
|
if not consumer_filter(Change.added, str(filepath)):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if _consume_file(
|
_consume_file(
|
||||||
filepath=filepath,
|
filepath=filepath,
|
||||||
consumption_dir=directory,
|
consumption_dir=directory,
|
||||||
subdirs_as_tags=subdirs_as_tags,
|
subdirs_as_tags=subdirs_as_tags,
|
||||||
):
|
)
|
||||||
queued.add(filepath.resolve())
|
queued.add(filepath.resolve())
|
||||||
|
|
||||||
return queued
|
return queued
|
||||||
|
|
||||||
@@ -639,36 +631,36 @@ class Command(BaseCommand):
|
|||||||
):
|
):
|
||||||
# Process each change
|
# Process each change
|
||||||
for change_type, path in changes:
|
for change_type, path in changes:
|
||||||
path = Path(path).resolve()
|
resolved_path = Path(path).resolve()
|
||||||
if change_type == Change.deleted:
|
if change_type == Change.deleted:
|
||||||
# Consumed (or otherwise removed); a later file
|
# Consumed (or otherwise removed); a later file
|
||||||
# reusing this name must not be skipped as
|
# reusing this name must not be skipped as
|
||||||
# already-queued.
|
# already-queued.
|
||||||
queued.discard(path)
|
queued.discard(resolved_path)
|
||||||
if not path.is_file():
|
if not resolved_path.is_file():
|
||||||
continue
|
continue
|
||||||
if path in queued:
|
if resolved_path in queued:
|
||||||
# Already queued and awaiting consumption; a stray
|
# Already queued and awaiting consumption; a stray
|
||||||
# event (NAS metadata touch, AV scan, etc.) while
|
# event (NAS metadata touch, AV scan, etc.) while
|
||||||
# the file sits on disk mid-consumption must not
|
# the file sits on disk mid-consumption must not
|
||||||
# cause it to be queued a second time (GH #13511).
|
# cause it to be queued a second time (GH #13511).
|
||||||
logger.debug(f"Ignoring event for queued file: {path}")
|
logger.debug(
|
||||||
|
f"Ignoring event for queued file: {resolved_path}",
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
logger.debug(f"Event: {change_type.name} for {path}")
|
logger.debug(f"Event: {change_type.name} for {resolved_path}")
|
||||||
tracker.track(path, change_type)
|
tracker.track(resolved_path, change_type)
|
||||||
|
|
||||||
# Check for stable files
|
# Check for stable files
|
||||||
for stable_path in tracker.get_stable_files():
|
for stable_path in tracker.get_stable_files():
|
||||||
# Only remember files that were actually queued, so the
|
_consume_file(
|
||||||
# rescan does not re-queue them while the consume task
|
|
||||||
# has yet to remove them from disk, but does retry a
|
|
||||||
# failed publish instead of stranding it
|
|
||||||
if _consume_file(
|
|
||||||
filepath=stable_path,
|
filepath=stable_path,
|
||||||
consumption_dir=directory,
|
consumption_dir=directory,
|
||||||
subdirs_as_tags=subdirs_as_tags,
|
subdirs_as_tags=subdirs_as_tags,
|
||||||
):
|
)
|
||||||
queued.add(stable_path)
|
# Remember it so the rescan does not re-queue it while
|
||||||
|
# the consume task has yet to remove it from disk
|
||||||
|
queued.add(stable_path)
|
||||||
|
|
||||||
# Exit watch loop to reconfigure timeout
|
# Exit watch loop to reconfigure timeout
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ if TYPE_CHECKING:
|
|||||||
logger = logging.getLogger("paperless.matching")
|
logger = logging.getLogger("paperless.matching")
|
||||||
|
|
||||||
|
|
||||||
|
class UnsupportedWorkflowTriggerTypeError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def log_reason(
|
def log_reason(
|
||||||
matching_model: MatchingModel | WorkflowTrigger,
|
matching_model: MatchingModel | WorkflowTrigger,
|
||||||
document: Document,
|
document: Document,
|
||||||
@@ -691,7 +695,9 @@ def document_matches_workflow(
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# New trigger types need to be explicitly checked above
|
# New trigger types need to be explicitly checked above
|
||||||
raise Exception(f"Trigger type {trigger_type} not yet supported")
|
raise UnsupportedWorkflowTriggerTypeError(
|
||||||
|
f"Trigger type {trigger_type} not yet supported",
|
||||||
|
)
|
||||||
|
|
||||||
if trigger_matched:
|
if trigger_matched:
|
||||||
logger.info(f"Document matched {trigger} from {workflow}")
|
logger.info(f"Document matched {trigger} from {workflow}")
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ def recompute_checksums(apps, schema_editor):
|
|||||||
if updated_fields:
|
if updated_fields:
|
||||||
batch.append(doc)
|
batch.append(doc)
|
||||||
|
|
||||||
processed += 1
|
processed += 1 # noqa: SIM113
|
||||||
|
|
||||||
if len(batch) >= _BATCH_SIZE:
|
if len(batch) >= _BATCH_SIZE:
|
||||||
Document.objects.bulk_update(batch, ["checksum", "archive_checksum"])
|
Document.objects.bulk_update(batch, ["checksum", "archive_checksum"])
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ class Document(SoftDeleteModel, ModelWithOwner): # type: ignore[django-manager-
|
|||||||
from documents.versioning import versions_newest_first
|
from documents.versioning import versions_newest_first
|
||||||
|
|
||||||
if hasattr(self, "effective_content"):
|
if hasattr(self, "effective_content"):
|
||||||
return getattr(self, "effective_content")
|
return self.effective_content
|
||||||
|
|
||||||
if self.root_document_id is not None or self.pk is None:
|
if self.root_document_id is not None or self.pk is None:
|
||||||
return self.content
|
return self.content
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ def get_default_file_extension(mime_type: str) -> str:
|
|||||||
return supported[mime_type]
|
return supported[mime_type]
|
||||||
|
|
||||||
ext = mimetypes.guess_extension(mime_type)
|
ext = mimetypes.guess_extension(mime_type)
|
||||||
return ext if ext else ""
|
return ext or ""
|
||||||
|
|
||||||
|
|
||||||
def is_file_ext_supported(ext: str) -> bool:
|
def is_file_ext_supported(ext: str) -> bool:
|
||||||
@@ -110,7 +110,7 @@ def run_convert(
|
|||||||
args += ["-define", "pdf:use-cropbox=true"] if use_cropbox else []
|
args += ["-define", "pdf:use-cropbox=true"] if use_cropbox else []
|
||||||
args += [str(input_file), str(output_file)]
|
args += [str(input_file), str(output_file)]
|
||||||
|
|
||||||
logger.debug("Execute: " + " ".join(args), extra={"group": logging_group})
|
logger.debug("Execute: %s", " ".join(args), extra={"group": logging_group})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
run_subprocess(args, environment, logger)
|
run_subprocess(args, environment, logger)
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ def _discover_parser_class() -> type[DateParserPluginBase]:
|
|||||||
valid_plugins.append(ep)
|
valid_plugins.append(ep)
|
||||||
else:
|
else:
|
||||||
logger.warning(f"Plugin {ep.name} does not subclass DateParser.")
|
logger.warning(f"Plugin {ep.name} does not subclass DateParser.")
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.exception(f"Unable to load date parser plugin {ep.name}: {e}")
|
logger.exception(f"Unable to load date parser plugin {ep.name}")
|
||||||
|
|
||||||
if not valid_plugins:
|
if not valid_plugins:
|
||||||
return RegexDateParserPlugin
|
return RegexDateParserPlugin
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ class DateParserPluginBase(ABC):
|
|||||||
},
|
},
|
||||||
locales=self.config.languages,
|
locales=self.config.languages,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.exception(f"Error while parsing date string '{date_string}': {e}")
|
logger.exception(f"Error while parsing date string '{date_string}'")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _filter_date(
|
def _filter_date(
|
||||||
|
|||||||
@@ -59,11 +59,10 @@ def safe_regex_match(pattern: str, text: str, *, flags: int = 0):
|
|||||||
try:
|
try:
|
||||||
validate_regex_pattern(pattern)
|
validate_regex_pattern(pattern)
|
||||||
compiled = regex.compile(pattern, flags=flags)
|
compiled = regex.compile(pattern, flags=flags)
|
||||||
except (regex.error, ValueError) as exc:
|
except (regex.error, ValueError):
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Error while processing regular expression %s: %s",
|
"Error while processing regular expression %s",
|
||||||
textwrap.shorten(pattern, width=80, placeholder="…"),
|
textwrap.shorten(pattern, width=80, placeholder="…"),
|
||||||
exc,
|
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -86,11 +85,10 @@ def safe_regex_sub(pattern: str, repl: str, text: str, *, flags: int = 0) -> str
|
|||||||
try:
|
try:
|
||||||
validate_regex_pattern(pattern)
|
validate_regex_pattern(pattern)
|
||||||
compiled = regex.compile(pattern, flags=flags)
|
compiled = regex.compile(pattern, flags=flags)
|
||||||
except (regex.error, ValueError) as exc:
|
except (regex.error, ValueError):
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Error while processing regular expression %s: %s",
|
"Error while processing regular expression %s",
|
||||||
textwrap.shorten(pattern, width=80, placeholder="…"),
|
textwrap.shorten(pattern, width=80, placeholder="…"),
|
||||||
exc,
|
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -1142,7 +1142,7 @@ def get_backend() -> TantivyBackend:
|
|||||||
Returns:
|
Returns:
|
||||||
Thread-safe singleton TantivyBackend instance
|
Thread-safe singleton TantivyBackend instance
|
||||||
"""
|
"""
|
||||||
global _backend, _backend_path
|
global _backend, _backend_path # noqa: PLW0603 - module-level singleton, no class to hold this state
|
||||||
|
|
||||||
current_path: Path = settings.INDEX_DIR
|
current_path: Path = settings.INDEX_DIR
|
||||||
|
|
||||||
@@ -1173,7 +1173,7 @@ def reset_backend() -> None:
|
|||||||
Forces creation of a new backend instance on the next get_backend() call.
|
Forces creation of a new backend instance on the next get_backend() call.
|
||||||
Used for test isolation and when switching between different index directories.
|
Used for test isolation and when switching between different index directories.
|
||||||
"""
|
"""
|
||||||
global _backend, _backend_path
|
global _backend, _backend_path # noqa: PLW0603 - module-level singleton, no class to hold this state
|
||||||
|
|
||||||
with _backend_lock:
|
with _backend_lock:
|
||||||
if _backend is not None:
|
if _backend is not None:
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ def parse_user_query(
|
|||||||
DEFAULT_SEARCH_FIELDS,
|
DEFAULT_SEARCH_FIELDS,
|
||||||
field_boosts=_FIELD_BOOSTS,
|
field_boosts=_FIELD_BOOSTS,
|
||||||
# (prefix=True, distance=1, transposition_cost_one=True) — edit-distance fuzziness
|
# (prefix=True, distance=1, transposition_cost_one=True) — edit-distance fuzziness
|
||||||
fuzzy_fields={f: (True, 1, True) for f in DEFAULT_SEARCH_FIELDS},
|
fuzzy_fields=dict.fromkeys(DEFAULT_SEARCH_FIELDS, (True, 1, True)),
|
||||||
)
|
)
|
||||||
# 0.1 boost keeps fuzzy hits ranked below exact matches (intentional)
|
# 0.1 boost keeps fuzzy hits ranked below exact matches (intentional)
|
||||||
clauses.append((tantivy.Occur.Should, tantivy.Query.boost_query(fuzzy, 0.1)))
|
clauses.append((tantivy.Occur.Should, tantivy.Query.boost_query(fuzzy, 0.1)))
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ class OwnedObjectSerializer(
|
|||||||
return set()
|
return set()
|
||||||
|
|
||||||
ctype = ContentType.objects.get_for_model(first_obj)
|
ctype = ContentType.objects.get_for_model(first_obj)
|
||||||
object_pks = list(obj.pk for obj in objects)
|
object_pks = [obj.pk for obj in objects]
|
||||||
pk_type = type(first_obj.pk)
|
pk_type = type(first_obj.pk)
|
||||||
|
|
||||||
def get_pks_for_permission_type(model):
|
def get_pks_for_permission_type(model):
|
||||||
@@ -730,7 +730,7 @@ class TagSerializer(MatchingModelSerializer, OwnedObjectSerializer):
|
|||||||
self.instance.clean()
|
self.instance.clean()
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
logger.debug("Tag parent validation failed: %s", e)
|
logger.debug("Tag parent validation failed: %s", e)
|
||||||
raise e
|
raise
|
||||||
finally:
|
finally:
|
||||||
self.instance.tn_parent = original_parent
|
self.instance.tn_parent = original_parent
|
||||||
else:
|
else:
|
||||||
@@ -740,7 +740,7 @@ class TagSerializer(MatchingModelSerializer, OwnedObjectSerializer):
|
|||||||
temp.clean()
|
temp.clean()
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
logger.debug("Tag parent validation failed: %s", e)
|
logger.debug("Tag parent validation failed: %s", e)
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
return super().validate(attrs)
|
return super().validate(attrs)
|
||||||
|
|
||||||
@@ -1150,7 +1150,7 @@ class DocumentSerializer(
|
|||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
doc = super().to_representation(instance)
|
doc = super().to_representation(instance)
|
||||||
if "content" in self.fields and hasattr(instance, "effective_content"):
|
if "content" in self.fields and hasattr(instance, "effective_content"):
|
||||||
doc["content"] = getattr(instance, "effective_content") or ""
|
doc["content"] = instance.effective_content or ""
|
||||||
if self.truncate_content and "content" in self.fields:
|
if self.truncate_content and "content" in self.fields:
|
||||||
doc["content"] = doc.get("content")[0:550]
|
doc["content"] = doc.get("content")[0:550]
|
||||||
return doc
|
return doc
|
||||||
@@ -1860,8 +1860,8 @@ class BulkEditSerializer(
|
|||||||
if isinstance(custom_fields, dict):
|
if isinstance(custom_fields, dict):
|
||||||
try:
|
try:
|
||||||
ids = [int(i[0]) for i in custom_fields.items()]
|
ids = [int(i[0]) for i in custom_fields.items()]
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.exception(f"Error validating custom fields: {e}")
|
logger.exception("Error validating custom fields")
|
||||||
raise serializers.ValidationError(
|
raise serializers.ValidationError(
|
||||||
f"{name} must be a list of integers or a dict of id:value pairs, see the log for details",
|
f"{name} must be a list of integers or a dict of id:value pairs, see the log for details",
|
||||||
)
|
)
|
||||||
@@ -2059,13 +2059,12 @@ class BulkEditSerializer(
|
|||||||
for doc in docs:
|
for doc in docs:
|
||||||
if "-" in doc:
|
if "-" in doc:
|
||||||
pages.append(
|
pages.append(
|
||||||
[
|
list(
|
||||||
x
|
range(
|
||||||
for x in range(
|
|
||||||
int(doc.split("-")[0]),
|
int(doc.split("-")[0]),
|
||||||
int(doc.split("-")[1]) + 1,
|
int(doc.split("-")[1]) + 1,
|
||||||
)
|
),
|
||||||
],
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
pages.append([int(doc)])
|
pages.append([int(doc)])
|
||||||
@@ -2926,7 +2925,7 @@ class ShareLinkBundleSerializer(OwnedObjectSerializer):
|
|||||||
return share_link_bundle
|
return share_link_bundle
|
||||||
|
|
||||||
def get_document_count(self, obj: ShareLinkBundle) -> int:
|
def get_document_count(self, obj: ShareLinkBundle) -> int:
|
||||||
return getattr(obj, "document_total") or obj.documents.count()
|
return obj.document_total or obj.documents.count()
|
||||||
|
|
||||||
|
|
||||||
class BulkEditObjectsSerializer(SerializerWithPerms, SetPermissionsMixin):
|
class BulkEditObjectsSerializer(SerializerWithPerms, SetPermissionsMixin):
|
||||||
|
|||||||
@@ -637,7 +637,7 @@ def update_filename_and_move_files(
|
|||||||
# so this is not the end of the world.
|
# so this is not the end of the world.
|
||||||
# B: if moving the original file failed, nothing has changed
|
# B: if moving the original file failed, nothing has changed
|
||||||
# anyway.
|
# anyway.
|
||||||
pass
|
logger.exception("Error reverting document changes")
|
||||||
|
|
||||||
# restore old values on the instance
|
# restore old values on the instance
|
||||||
instance.filename = old_filename
|
instance.filename = old_filename
|
||||||
@@ -1003,7 +1003,7 @@ def run_workflows(
|
|||||||
|
|
||||||
# kwargs so the PaperlessTask record can note the
|
# kwargs so the PaperlessTask record can note the
|
||||||
# document, see _extract_input_data
|
# document, see _extract_input_data
|
||||||
apply_ai_suggestions.delay_on_commit(
|
apply_ai_suggestions.delay(
|
||||||
action_id=action.pk,
|
action_id=action.pk,
|
||||||
document_id=document.pk,
|
document_id=document.pk,
|
||||||
)
|
)
|
||||||
@@ -1102,10 +1102,11 @@ def _extract_input_data(
|
|||||||
if v is None or k.startswith("_"):
|
if v is None or k.startswith("_"):
|
||||||
continue
|
continue
|
||||||
if isinstance(v, datetime.date):
|
if isinstance(v, datetime.date):
|
||||||
v = v.isoformat()
|
override_dict[k] = v.isoformat()
|
||||||
elif isinstance(v, Path):
|
elif isinstance(v, Path):
|
||||||
v = str(v)
|
override_dict[k] = str(v)
|
||||||
override_dict[k] = v
|
else:
|
||||||
|
override_dict[k] = v
|
||||||
if override_dict:
|
if override_dict:
|
||||||
data["overrides"] = override_dict
|
data["overrides"] = override_dict
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -217,9 +217,9 @@ def consume_file(
|
|||||||
overrides.filename or input_doc.original_file.name,
|
overrides.filename or input_doc.original_file.name,
|
||||||
self.request.id,
|
self.request.id,
|
||||||
) as status_mgr,
|
) as status_mgr,
|
||||||
TemporaryDirectory(dir=settings.SCRATCH_DIR) as tmp_dir,
|
TemporaryDirectory(dir=settings.SCRATCH_DIR) as tmp_dir_name,
|
||||||
):
|
):
|
||||||
tmp_dir = Path(tmp_dir)
|
tmp_dir = Path(tmp_dir_name)
|
||||||
msg = None
|
msg = None
|
||||||
for plugin_class in plugins:
|
for plugin_class in plugins:
|
||||||
plugin_name = plugin_class.NAME
|
plugin_name = plugin_class.NAME
|
||||||
@@ -261,7 +261,7 @@ def consume_file(
|
|||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"{plugin_name} failed: {e}")
|
logger.exception(f"{plugin_name} failed")
|
||||||
status_mgr.send_progress(
|
status_mgr.send_progress(
|
||||||
ProgressStatusOptions.FAILED,
|
ProgressStatusOptions.FAILED,
|
||||||
f"{e}",
|
f"{e}",
|
||||||
@@ -495,8 +495,8 @@ def empty_trash(doc_ids=None) -> None:
|
|||||||
content_type=ContentType.objects.get_for_model(Document),
|
content_type=ContentType.objects.get_for_model(Document),
|
||||||
object_id__in=deleted_document_ids,
|
object_id__in=deleted_document_ids,
|
||||||
).delete()
|
).delete()
|
||||||
except Exception as e: # pragma: no cover
|
except Exception: # pragma: no cover
|
||||||
logger.exception(f"Error while emptying trash: {e}")
|
logger.exception("Error while emptying trash")
|
||||||
finally:
|
finally:
|
||||||
models.signals.post_delete.disconnect(
|
models.signals.post_delete.disconnect(
|
||||||
cleanup_document_deletion,
|
cleanup_document_deletion,
|
||||||
@@ -832,9 +832,8 @@ def build_share_link_bundle(bundle_id: int) -> None:
|
|||||||
logger.info("Built share link bundle %s", bundle.pk)
|
logger.info("Built share link bundle %s", bundle.pk)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Failed to build share link bundle %s: %s",
|
"Failed to build share link bundle %s",
|
||||||
bundle_id,
|
bundle_id,
|
||||||
exc,
|
|
||||||
)
|
)
|
||||||
bundle.status = ShareLinkBundle.Status.FAILED
|
bundle.status = ShareLinkBundle.Status.FAILED
|
||||||
bundle.last_error = {
|
bundle.last_error = {
|
||||||
|
|||||||
@@ -78,6 +78,10 @@ class PlaceholderString(str):
|
|||||||
def __ne__(self, other) -> bool:
|
def __ne__(self, other) -> bool:
|
||||||
return not self.__eq__(other)
|
return not self.__eq__(other)
|
||||||
|
|
||||||
|
def __hash__(self) -> int:
|
||||||
|
# Equal to both "-none-" and "none", so hash to a single canonical value
|
||||||
|
return hash("-none-")
|
||||||
|
|
||||||
|
|
||||||
NO_VALUE_PLACEHOLDER = PlaceholderString("-none-")
|
NO_VALUE_PLACEHOLDER = PlaceholderString("-none-")
|
||||||
|
|
||||||
|
|||||||
@@ -138,9 +138,9 @@ def parse_w_workflow_placeholders(
|
|||||||
|
|
||||||
# We're good!
|
# We're good!
|
||||||
return rendered_template
|
return rendered_template
|
||||||
except UndefinedError as e:
|
except UndefinedError:
|
||||||
# The undefined class logs this already for us
|
# The undefined class logs this already for us
|
||||||
raise e
|
raise
|
||||||
except TemplateSyntaxError as e:
|
except TemplateSyntaxError as e:
|
||||||
logger.warning(f"Template syntax error in title generation: {e}")
|
logger.warning(f"Template syntax error in title generation: {e}")
|
||||||
except SecurityError as e:
|
except SecurityError as e:
|
||||||
@@ -150,5 +150,5 @@ def parse_w_workflow_placeholders(
|
|||||||
logger.warning(
|
logger.warning(
|
||||||
f"Invalid title format '{text}', workflow not applied: {e}",
|
f"Invalid title format '{text}', workflow not applied: {e}",
|
||||||
)
|
)
|
||||||
raise e
|
raise
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ class TestRegexDateParser:
|
|||||||
|
|
||||||
# simulate parse failure for malformed input
|
# simulate parse failure for malformed input
|
||||||
if "99/99/9999" in date_string or "bad date" in date_string:
|
if "99/99/9999" in date_string or "bad date" in date_string:
|
||||||
raise Exception("parse failed for malformed date")
|
raise Exception("parse failed for malformed date") # noqa: TRY002 - simulates a generic parser failure
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ class MultiprocessCommand(PaperlessCommand):
|
|||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
items = list(range(5))
|
items = list(range(5))
|
||||||
results = []
|
results = list(
|
||||||
for result in self.process_parallel(
|
self.process_parallel(
|
||||||
_double_value,
|
_double_value,
|
||||||
items,
|
items,
|
||||||
description="Processing...",
|
description="Processing...",
|
||||||
):
|
),
|
||||||
results.append(result)
|
)
|
||||||
successes = sum(1 for r in results if r.success)
|
successes = sum(1 for r in results if r.success)
|
||||||
self.stdout.write(f"Successes: {successes}")
|
self.stdout.write(f"Successes: {successes}")
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class TestWriteBatchLockRetry:
|
|||||||
)
|
)
|
||||||
mock_sleep = mocker.patch(
|
mock_sleep = mocker.patch(
|
||||||
"documents.search._backend.time.sleep",
|
"documents.search._backend.time.sleep",
|
||||||
side_effect=lambda s: sleep_values.append(s),
|
side_effect=sleep_values.append,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Should not raise — 4th attempt succeeds
|
# Should not raise — 4th attempt succeeds
|
||||||
@@ -111,7 +111,7 @@ class TestWriteBatchLockRetry:
|
|||||||
sleep_values: list[float] = []
|
sleep_values: list[float] = []
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
"documents.search._backend.time.sleep",
|
"documents.search._backend.time.sleep",
|
||||||
side_effect=lambda s: sleep_values.append(s),
|
side_effect=sleep_values.append,
|
||||||
)
|
)
|
||||||
for _ in range(50):
|
for _ in range(50):
|
||||||
sleep_values.clear()
|
sleep_values.clear()
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user