diff --git a/src-ui/cypress/e2e/documents/documents-list.cy.ts b/src-ui/cypress/e2e/documents/documents-list.cy.ts index 5c17ef5d9..847d038b8 100644 --- a/src-ui/cypress/e2e/documents/documents-list.cy.ts +++ b/src-ui/cypress/e2e/documents/documents-list.cy.ts @@ -150,7 +150,7 @@ describe('documents-list', () => { cy.contains('button', 'Corresp 11').click() cy.contains('label', 'Exclude').click() }) - cy.contains('One document') + cy.contains('3 documents') }) it('should apply tags', () => { diff --git a/src-ui/cypress/e2e/documents/query-params.cy.ts b/src-ui/cypress/e2e/documents/query-params.cy.ts index eb160e9de..78a85d185 100644 --- a/src-ui/cypress/e2e/documents/query-params.cy.ts +++ b/src-ui/cypress/e2e/documents/query-params.cy.ts @@ -190,6 +190,36 @@ describe('documents query params', () => { response.count = response.results.length } + if (req.query.hasOwnProperty('owner__id')) { + response.results = ( + documentsJson.results as Array + ).filter((d) => d.owner == req.query['owner__id']) + response.count = response.results.length + } else if (req.query.hasOwnProperty('owner__id__in')) { + const owners = req.query['owner__id__in'] + .toString() + .split(',') + .map((o) => parseInt(o)) + response.results = ( + documentsJson.results as Array + ).filter((d) => owners.includes(d.owner)) + response.count = response.results.length + } else if (req.query.hasOwnProperty('owner__id__none')) { + const owners = req.query['owner__id__none'] + .toString() + .split(',') + .map((o) => parseInt(o)) + response.results = ( + documentsJson.results as Array + ).filter((d) => !owners.includes(d.owner)) + response.count = response.results.length + } else if (req.query.hasOwnProperty('owner__isnull')) { + response.results = ( + documentsJson.results as Array + ).filter((d) => d.owner === null) + response.count = response.results.length + } + req.reply(response) }) }) @@ -202,7 +232,7 @@ describe('documents query params', () => { it('should show a list of documents reverse sorted by created', () => { cy.visit('/documents?sort=created&reverse=true') - cy.get('app-document-card-small').first().contains('sit amet') + cy.get('app-document-card-small').first().contains('Doc 6') }) it('should show a list of documents sorted by added', () => { @@ -212,7 +242,7 @@ describe('documents query params', () => { it('should show a list of documents reverse sorted by added', () => { cy.visit('/documents?sort=added&reverse=true') - cy.get('app-document-card-small').first().contains('sit amet') + cy.get('app-document-card-small').first().contains('Doc 6') }) it('should show a list of documents filtered by any tags', () => { @@ -222,12 +252,12 @@ describe('documents query params', () => { it('should show a list of documents filtered by excluded tags', () => { cy.visit('/documents?sort=created&reverse=true&tags__id__none=2,4') - cy.contains('One document') + cy.contains('3 documents') }) it('should show a list of documents filtered by no tags', () => { cy.visit('/documents?sort=created&reverse=true&is_tagged=0') - cy.contains('One document') + cy.contains('3 documents') }) it('should show a list of documents filtered by document type', () => { @@ -242,7 +272,7 @@ describe('documents query params', () => { it('should show a list of documents filtered by no document type', () => { cy.visit('/documents?sort=created&reverse=true&document_type__isnull=1') - cy.contains('One document') + cy.contains('3 documents') }) it('should show a list of documents filtered by correspondent', () => { @@ -257,7 +287,7 @@ describe('documents query params', () => { it('should show a list of documents filtered by no correspondent', () => { cy.visit('/documents?sort=created&reverse=true&correspondent__isnull=1') - cy.contains('One document') + cy.contains('3 documents') }) it('should show a list of documents filtered by storage path', () => { @@ -267,7 +297,7 @@ describe('documents query params', () => { it('should show a list of documents filtered by no storage path', () => { cy.visit('/documents?sort=created&reverse=true&storage_path__isnull=1') - cy.contains('3 documents') + cy.contains('5 documents') }) it('should show a list of documents filtered by title or content', () => { @@ -312,7 +342,7 @@ describe('documents query params', () => { cy.visit( '/documents?sort=created&reverse=true&created__date__gt=2022-03-23' ) - cy.contains('3 documents') + cy.contains('5 documents') }) it('should show a list of documents filtered by created date less than', () => { @@ -324,7 +354,7 @@ describe('documents query params', () => { it('should show a list of documents filtered by added date greater than', () => { cy.visit('/documents?sort=created&reverse=true&added__date__gt=2022-03-24') - cy.contains('2 documents') + cy.contains('4 documents') }) it('should show a list of documents filtered by added date less than', () => { @@ -338,4 +368,24 @@ describe('documents query params', () => { ) cy.contains('2 documents') }) + + it('should show a list of documents filtered by owner', () => { + cy.visit('/documents?owner__id=15') + cy.contains('One document') + }) + + it('should show a list of documents filtered by multiple owners', () => { + cy.visit('/documents?owner__id__in=6,15') + cy.contains('2 documents') + }) + + it('should show a list of documents filtered by excluded owners', () => { + cy.visit('/documents?owner__id__none=6') + cy.contains('5 documents') + }) + + it('should show a list of documents filtered by null owner', () => { + cy.visit('/documents?owner__isnull=true') + cy.contains('4 documents') + }) }) diff --git a/src-ui/cypress/fixtures/documents/documents.json b/src-ui/cypress/fixtures/documents/documents.json index 6b284f7b2..a33e4e43f 100644 --- a/src-ui/cypress/fixtures/documents/documents.json +++ b/src-ui/cypress/fixtures/documents/documents.json @@ -143,6 +143,64 @@ } }, "notes": [] + }, + { + "id": 5, + "correspondent": null, + "document_type": null, + "storage_path": null, + "title": "Doc 5", + "content": "Test document 5", + "tags": [], + "created": "2023-05-01T07:24:18Z", + "created_date": "2023-05-02", + "modified": "2023-05-02T07:24:23.264859Z", + "added": "2023-05-02T07:24:22.922631Z", + "archive_serial_number": null, + "original_file_name": "doc5.pdf", + "archived_file_name": "doc5.pdf", + "owner": 15, + "user_can_change": true, + "permissions": { + "view": { + "users": [1], + "groups": [] + }, + "change": { + "users": [], + "groups": [] + } + }, + "notes": [] + }, + { + "id": 6, + "correspondent": null, + "document_type": null, + "storage_path": null, + "title": "Doc 6", + "content": "Test document 6", + "tags": [], + "created": "2023-05-01T10:24:18Z", + "created_date": "2023-05-02", + "modified": "2023-05-02T10:24:23.264859Z", + "added": "2023-05-02T10:24:22.922631Z", + "archive_serial_number": null, + "original_file_name": "doc6.pdf", + "archived_file_name": "doc6.pdf", + "owner": 6, + "user_can_change": true, + "permissions": { + "view": { + "users": [1], + "groups": [] + }, + "change": { + "users": [], + "groups": [] + } + }, + "notes": [] } ] } diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 1a5d4402c..dd49f8306 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -574,7 +574,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 28 + 26 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -1146,7 +1146,11 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 81 + 78 + + + src/app/components/document-list/filter-editor/filter-editor.component.html + 77 @@ -1547,7 +1551,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 141 + 138 src/app/components/manage/management-list/management-list.component.html @@ -1852,6 +1856,10 @@ src/app/components/common/filterable-dropdown/filterable-dropdown.component.html 16 + + src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.html + 18 + src/app/components/common/permissions-select/permissions-select.component.html 6 @@ -2000,7 +2008,7 @@ src/app/components/document-list/document-card-small/document-card-small.component.html - 78 + 83 src/app/components/manage/management-list/management-list.component.html @@ -2102,6 +2110,45 @@ 43 + + My documents + + src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.html + 28 + + + + Shared with me + + src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.html + 38 + + + + Unowned + + src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.html + 48 + + + + Users + + src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.html + 68 + + + src/app/components/manage/settings/settings.component.html + 332 + + + + Hide unowned + + src/app/components/common/permissions-filter-dropdown/permissions-filter-dropdown.component.html + 77 + + Type @@ -2196,7 +2243,7 @@ src/app/components/document-list/document-list.component.html - 172 + 184 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2223,11 +2270,11 @@ src/app/components/document-list/document-list.component.html - 144 + 149 src/app/components/document-list/filter-editor/filter-editor.component.ts - 172 + 191 src/app/services/rest/document.service.ts @@ -2421,7 +2468,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 105 + 102 src/app/components/document-list/document-card-large/document-card-large.component.html @@ -2429,7 +2476,7 @@ src/app/components/document-list/document-card-small/document-card-small.component.html - 94 + 99 @@ -2447,7 +2494,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 92 + 89 @@ -2508,11 +2555,11 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 40 + 38 src/app/components/document-list/document-list.component.html - 137 + 142 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2531,11 +2578,11 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 51 + 49 src/app/components/document-list/document-list.component.html - 158 + 170 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2554,11 +2601,11 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.html - 62 + 60 src/app/components/document-list/document-list.component.html - 165 + 177 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2891,14 +2938,14 @@ Edit: src/app/components/document-list/bulk-editor/bulk-editor.component.html - 27 + 25 Filter tags src/app/components/document-list/bulk-editor/bulk-editor.component.html - 29 + 27 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2909,7 +2956,7 @@ Filter correspondents src/app/components/document-list/bulk-editor/bulk-editor.component.html - 41 + 39 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2920,7 +2967,7 @@ Filter document types src/app/components/document-list/bulk-editor/bulk-editor.component.html - 52 + 50 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2931,7 +2978,7 @@ Filter storage paths src/app/components/document-list/bulk-editor/bulk-editor.component.html - 63 + 61 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2942,7 +2989,7 @@ Actions src/app/components/document-list/bulk-editor/bulk-editor.component.html - 89 + 86 src/app/components/manage/management-list/management-list.component.html @@ -2989,28 +3036,28 @@ Include: src/app/components/document-list/bulk-editor/bulk-editor.component.html - 111 + 108 Archived files src/app/components/document-list/bulk-editor/bulk-editor.component.html - 115,117 + 112,114 Original files src/app/components/document-list/bulk-editor/bulk-editor.component.html - 121,123 + 118,120 Use formatted filename src/app/components/document-list/bulk-editor/bulk-editor.component.html - 128,130 + 125,127 @@ -3198,7 +3245,7 @@ src/app/components/document-list/document-list.component.html - 194 + 206 @@ -3209,7 +3256,7 @@ src/app/components/document-list/document-list.component.html - 199 + 211 @@ -3234,7 +3281,7 @@ src/app/components/document-list/document-list.component.html - 212 + 227 @@ -3245,7 +3292,7 @@ src/app/components/document-list/document-list.component.html - 217 + 232 @@ -3285,7 +3332,7 @@ Score: src/app/components/document-list/document-card-large/document-card-large.component.html - 110 + 116 @@ -3390,29 +3437,40 @@ 99 + + Reset filters + + src/app/components/document-list/document-list.component.html + 104 + + + src/app/components/document-list/filter-editor/filter-editor.component.html + 85 + + Error while loading documents src/app/components/document-list/document-list.component.html - 112 + 117 Sort by ASN src/app/components/document-list/document-list.component.html - 126 + 131 ASN src/app/components/document-list/document-list.component.html - 131,130 + 136,135 src/app/components/document-list/filter-editor/filter-editor.component.ts - 177 + 196 src/app/services/rest/document.service.ts @@ -3423,28 +3481,46 @@ Sort by correspondent src/app/components/document-list/document-list.component.html - 133 + 138 Sort by title src/app/components/document-list/document-list.component.html - 140 + 145 + + + + Sort by owner + + src/app/components/document-list/document-list.component.html + 152 + + + + Owner + + src/app/components/document-list/document-list.component.html + 156 + + + src/app/services/rest/document.service.ts + 26 Sort by notes src/app/components/document-list/document-list.component.html - 147 + 159 Notes src/app/components/document-list/document-list.component.html - 151 + 163 src/app/components/manage/settings/settings.component.html @@ -3459,35 +3535,35 @@ Sort by document type src/app/components/document-list/document-list.component.html - 154 + 166 Sort by storage path src/app/components/document-list/document-list.component.html - 161 + 173 Sort by created date src/app/components/document-list/document-list.component.html - 168 + 180 Sort by added date src/app/components/document-list/document-list.component.html - 175 + 187 Added src/app/components/document-list/document-list.component.html - 179 + 191 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -3502,7 +3578,7 @@ Edit document src/app/components/document-list/document-list.component.html - 198 + 210 @@ -3519,123 +3595,137 @@ 246 - - Reset filters - - src/app/components/document-list/filter-editor/filter-editor.component.html - 82 - - Correspondent: src/app/components/document-list/filter-editor/filter-editor.component.ts - 108,110 + 117,119 Without correspondent src/app/components/document-list/filter-editor/filter-editor.component.ts - 112 + 121 Type: src/app/components/document-list/filter-editor/filter-editor.component.ts - 117,119 + 126,128 Without document type src/app/components/document-list/filter-editor/filter-editor.component.ts - 121 + 130 Tag: src/app/components/document-list/filter-editor/filter-editor.component.ts - 125,127 + 134,136 Without any tag src/app/components/document-list/filter-editor/filter-editor.component.ts - 131 + 140 Title: src/app/components/document-list/filter-editor/filter-editor.component.ts - 135 + 144 ASN: src/app/components/document-list/filter-editor/filter-editor.component.ts - 138 + 147 + + + + Owner: + + src/app/components/document-list/filter-editor/filter-editor.component.ts + 150 + + + + Owner not in: + + src/app/components/document-list/filter-editor/filter-editor.component.ts + 153 + + + + Without an owner + + src/app/components/document-list/filter-editor/filter-editor.component.ts + 156 Title & content src/app/components/document-list/filter-editor/filter-editor.component.ts - 175 + 194 Advanced search src/app/components/document-list/filter-editor/filter-editor.component.ts - 180 + 199 More like src/app/components/document-list/filter-editor/filter-editor.component.ts - 186 + 205 equals src/app/components/document-list/filter-editor/filter-editor.component.ts - 205 + 224 is empty src/app/components/document-list/filter-editor/filter-editor.component.ts - 209 + 228 is not empty src/app/components/document-list/filter-editor/filter-editor.component.ts - 213 + 232 greater than src/app/components/document-list/filter-editor/filter-editor.component.ts - 217 + 236 less than src/app/components/document-list/filter-editor/filter-editor.component.ts - 221 + 240 @@ -4338,13 +4428,6 @@ 327 - - Users - - src/app/components/manage/settings/settings.component.html - 332 - - Add User @@ -4917,6 +5000,13 @@ 11 + + Shared + + src/app/pipes/username.pipe.ts + 33 + + Yes @@ -5079,7 +5169,7 @@ Search score src/app/services/rest/document.service.ts - 32 + 33 Score is a value returned by the full text search engine and specifies how well a result matches the given query diff --git a/src-ui/src/app/app.module.ts b/src-ui/src/app/app.module.ts index ed847d41a..6c6d13f6c 100644 --- a/src-ui/src/app/app.module.ts +++ b/src-ui/src/app/app.module.ts @@ -88,6 +88,10 @@ import { PermissionsUserComponent } from './components/common/input/permissions/ import { PermissionsGroupComponent } from './components/common/input/permissions/permissions-group/permissions-group.component' import { IfOwnerDirective } from './directives/if-owner.directive' import { IfObjectPermissionsDirective } from './directives/if-object-permissions.directive' +import { PermissionsDialogComponent } from './components/common/permissions-dialog/permissions-dialog.component' +import { PermissionsFormComponent } from './components/common/input/permissions/permissions-form/permissions-form.component' +import { PermissionsFilterDropdownComponent } from './components/common/permissions-filter-dropdown/permissions-filter-dropdown.component' +import { UsernamePipe } from './pipes/username.pipe' import localeAr from '@angular/common/locales/ar' import localeBe from '@angular/common/locales/be' @@ -111,8 +115,6 @@ import localeSr from '@angular/common/locales/sr' import localeSv from '@angular/common/locales/sv' import localeTr from '@angular/common/locales/tr' import localeZh from '@angular/common/locales/zh' -import { PermissionsDialogComponent } from './components/common/permissions-dialog/permissions-dialog.component' -import { PermissionsFormComponent } from './components/common/input/permissions/permissions-form/permissions-form.component' registerLocaleData(localeAr) registerLocaleData(localeBe) @@ -213,6 +215,8 @@ function initializeApp(settings: SettingsService) { IfObjectPermissionsDirective, PermissionsDialogComponent, PermissionsFormComponent, + PermissionsFilterDropdownComponent, + UsernamePipe, ], imports: [ BrowserModule, @@ -253,6 +257,7 @@ function initializeApp(settings: SettingsService) { PermissionsGuard, DirtyDocGuard, DirtySavedViewGuard, + UsernamePipe, ], bootstrap: [AppComponent], }) diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html index be0240eb5..83fe13d81 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.html +++ b/src-ui/src/app/components/app-frame/app-frame.component.html @@ -18,8 +18,8 @@ @@ -107,7 +107,7 @@  {{d.title | documentTitle}} - + diff --git a/src-ui/src/app/components/common/date-dropdown/date-dropdown.component.html b/src-ui/src/app/components/common/date-dropdown/date-dropdown.component.html index 58634b4d0..05547fed6 100644 --- a/src-ui/src/app/components/common/date-dropdown/date-dropdown.component.html +++ b/src-ui/src/app/components/common/date-dropdown/date-dropdown.component.html @@ -6,10 +6,10 @@