diff --git a/docker/docker-prepare.sh b/docker/docker-prepare.sh index b088cef40..d6eab4281 100755 --- a/docker/docker-prepare.sh +++ b/docker/docker-prepare.sh @@ -80,7 +80,7 @@ django_checks() { search_index() { - local -r index_version=3 + local -r index_version=4 local -r index_version_file=${DATA_DIR}/.index_version if [[ (! -f "${index_version_file}") || $(<"${index_version_file}") != "$index_version" ]]; then diff --git a/src-ui/cypress/e2e/documents/document-detail.cy.ts b/src-ui/cypress/e2e/documents/document-detail.cy.ts index 0cacbd81f..dd5f8fac8 100644 --- a/src-ui/cypress/e2e/documents/document-detail.cy.ts +++ b/src-ui/cypress/e2e/documents/document-detail.cy.ts @@ -17,28 +17,28 @@ describe('document-detail', () => { req.reply({ result: 'OK' }) }).as('saveDoc') - cy.fixture('documents/1/comments.json').then((commentsJson) => { + cy.fixture('documents/1/notes.json').then((notesJson) => { cy.intercept( 'GET', - 'http://localhost:8000/api/documents/1/comments/', + 'http://localhost:8000/api/documents/1/notes/', (req) => { - req.reply(commentsJson.filter((c) => c.id != 10)) // 3 + req.reply(notesJson.filter((c) => c.id != 10)) // 3 } ) cy.intercept( 'DELETE', - 'http://localhost:8000/api/documents/1/comments/?id=9', + 'http://localhost:8000/api/documents/1/notes/?id=9', (req) => { - req.reply(commentsJson.filter((c) => c.id != 9 && c.id != 10)) // 2 + req.reply(notesJson.filter((c) => c.id != 9 && c.id != 10)) // 2 } ) cy.intercept( 'POST', - 'http://localhost:8000/api/documents/1/comments/', + 'http://localhost:8000/api/documents/1/notes/', (req) => { - req.reply(commentsJson) // 4 + req.reply(notesJson) // 4 } ) }) @@ -75,33 +75,40 @@ describe('document-detail', () => { cy.get('pdf-viewer').should('be.visible') }) - it('should show a list of comments', () => { - cy.wait(1000) - .get('a') - .contains('Comments') - .click({ force: true }) - .wait(1000) - cy.get('app-document-comments').find('.card').its('length').should('eq', 3) + it('should show a list of notes', () => { + cy.wait(1000).get('a').contains('Notes').click({ force: true }).wait(1000) + cy.get('app-document-notes').find('.card').its('length').should('eq', 3) }) - it('should support comment deletion', () => { - cy.wait(1000).get('a').contains('Comments').click().wait(1000) - cy.get('app-document-comments') + it('should support note deletion', () => { + cy.wait(1000).get('a').contains('Notes').click().wait(1000) + cy.get('app-document-notes') .find('.card') .first() .find('button') .click({ force: true }) .wait(500) - cy.get('app-document-comments').find('.card').its('length').should('eq', 2) + cy.get('app-document-notes').find('.card').its('length').should('eq', 2) }) - it('should support comment insertion', () => { - cy.wait(1000).get('a').contains('Comments').click().wait(1000) - cy.get('app-document-comments') + it('should support note insertion', () => { + cy.wait(1000).get('a').contains('Notes').click().wait(1000) + cy.get('app-document-notes') .find('form textarea') - .type('Testing new comment') + .type('Testing new note') .wait(500) - cy.get('app-document-comments').find('form button').click().wait(1500) - cy.get('app-document-comments').find('.card').its('length').should('eq', 4) + cy.get('app-document-notes').find('form button').click().wait(1500) + cy.get('app-document-notes').find('.card').its('length').should('eq', 4) + }) + + it('should support navigation to notes tab by url', () => { + cy.visit('/documents/1/notes') + cy.get('app-document-notes').should('exist') + }) + + it('should dynamically update note counts', () => { + cy.visit('/documents/1/notes') + cy.get('app-document-notes').within(() => cy.contains('Delete').click()) + cy.get('ul.nav').find('li').contains('Notes').find('.badge').contains('2') }) }) diff --git a/src-ui/cypress/fixtures/documents/1/comments.json b/src-ui/cypress/fixtures/documents/1/comments.json deleted file mode 100644 index a6013b513..000000000 --- a/src-ui/cypress/fixtures/documents/1/comments.json +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "id": 10, - "comment": "Testing new comment", - "created": "2022-08-08T04:24:55.176008Z", - "user": { - "id": 1, - "username": "user2", - "first_name": "", - "last_name": "" - } - }, - { - "id": 9, - "comment": "Testing one more time", - "created": "2022-02-18T04:24:55.176008Z", - "user": { - "id": 2, - "username": "user1", - "first_name": "", - "last_name": "" - } - }, - { - "id": 8, - "comment": "Another comment", - "created": "2021-11-08T04:24:47.925042Z", - "user": { - "id": 2, - "username": "user33", - "first_name": "", - "last_name": "" - } - }, - { - "id": 7, - "comment": "Cupcake ipsum dolor sit amet cheesecake candy cookie tiramisu. Donut chocolate chupa chups macaroon brownie halvah pie cheesecake gummies. Sweet chocolate bar candy donut gummi bears bear claw liquorice bonbon shortbread.\n\nDonut chocolate bar candy wafer wafer tiramisu. Gummies chocolate cake muffin toffee carrot cake macaroon. Toffee toffee jelly beans danish lollipop cake.", - "created": "2021-02-08T02:37:49.724132Z", - "user": { - "id": 3, - "username": "admin", - "first_name": "", - "last_name": "" - } - } -] diff --git a/src-ui/cypress/fixtures/documents/1/notes.json b/src-ui/cypress/fixtures/documents/1/notes.json new file mode 100644 index 000000000..97c8e5ace --- /dev/null +++ b/src-ui/cypress/fixtures/documents/1/notes.json @@ -0,0 +1,26 @@ +[ + { + "id": 10, + "note": "Testing new note", + "created": "2022-08-08T04:24:55.176008Z", + "user": 3 + }, + { + "id": 9, + "note": "Testing one more time", + "created": "2022-02-18T04:24:55.176008Z", + "user": 15 + }, + { + "id": 8, + "note": "Another note", + "created": "2021-11-08T04:24:47.925042Z", + "user": 3 + }, + { + "id": 7, + "note": "Cupcake ipsum dolor sit amet cheesecake candy cookie tiramisu. Donut chocolate chupa chups macaroon brownie halvah pie cheesecake gummies. Sweet chocolate bar candy donut gummi bears bear claw liquorice bonbon shortbread.\n\nDonut chocolate bar candy wafer wafer tiramisu. Gummies chocolate cake muffin toffee carrot cake macaroon. Toffee toffee jelly beans danish lollipop cake.", + "created": "2021-02-08T02:37:49.724132Z", + "user": 3 + } +] diff --git a/src-ui/cypress/fixtures/documents/documents.json b/src-ui/cypress/fixtures/documents/documents.json index e7275b4b5..be7640c8f 100644 --- a/src-ui/cypress/fixtures/documents/documents.json +++ b/src-ui/cypress/fixtures/documents/documents.json @@ -21,7 +21,27 @@ "original_file_name": "2022-03-22 no latin title.pdf", "archived_file_name": "2022-03-22 no latin title.pdf", "owner": null, - "permissions": [] + "permissions": [], + "notes": [ + { + "id": 9, + "note": "Testing one more time", + "created": "2022-02-18T04:24:55.176008Z", + "user": 15 + }, + { + "id": 8, + "note": "Another note", + "created": "2021-11-08T04:24:47.925042Z", + "user": 3 + }, + { + "id": 7, + "note": "Cupcake ipsum dolor sit amet cheesecake candy cookie tiramisu. Donut chocolate chupa chups macaroon brownie halvah pie cheesecake gummies. Sweet chocolate bar candy donut gummi bears bear claw liquorice bonbon shortbread.\n\nDonut chocolate bar candy wafer wafer tiramisu. Gummies chocolate cake muffin toffee carrot cake macaroon. Toffee toffee jelly beans danish lollipop cake.", + "created": "2021-02-08T02:37:49.724132Z", + "user": 3 + } + ] }, { "id": 2, @@ -39,7 +59,8 @@ "original_file_name": "2022-03-23 lorem ipsum dolor sit amet.pdf", "archived_file_name": "2022-03-23 llorem ipsum dolor sit amet.pdf", "owner": null, - "permissions": [] + "permissions": [], + "notes": [] }, { "id": 3, @@ -59,7 +80,8 @@ "original_file_name": "2022-03-24 dolor.pdf", "archived_file_name": "2022-03-24 dolor.pdf", "owner": null, - "permissions": [] + "permissions": [], + "notes": [] }, { "id": 4, @@ -79,7 +101,8 @@ "original_file_name": "2022-06-01 sit amet.pdf", "archived_file_name": "2022-06-01 sit amet.pdf", "owner": null, - "permissions": [] + "permissions": [], + "notes": [] } ] } diff --git a/src-ui/cypress/fixtures/groups/groups.json b/src-ui/cypress/fixtures/groups/groups.json index 0bf2655d9..f6051be90 100644 --- a/src-ui/cypress/fixtures/groups/groups.json +++ b/src-ui/cypress/fixtures/groups/groups.json @@ -11,10 +11,10 @@ "change_user", "delete_user", "view_user", - "add_comment", - "change_comment", - "delete_comment", - "view_comment" + "add_note", + "change_note", + "delete_note", + "view_note" ] }, { @@ -73,10 +73,10 @@ "change_task", "delete_task", "view_task", - "add_comment", - "change_comment", - "delete_comment", - "view_comment", + "add_note", + "change_note", + "delete_note", + "view_note", "add_correspondent", "change_correspondent", "delete_correspondent", diff --git a/src-ui/cypress/fixtures/ui_settings/settings.json b/src-ui/cypress/fixtures/ui_settings/settings.json index f552054df..3183943fe 100644 --- a/src-ui/cypress/fixtures/ui_settings/settings.json +++ b/src-ui/cypress/fixtures/ui_settings/settings.json @@ -94,10 +94,10 @@ "change_task", "delete_task", "view_task", - "add_comment", - "change_comment", - "delete_comment", - "view_comment", + "add_note", + "change_note", + "delete_note", + "view_note", "add_correspondent", "change_correspondent", "delete_correspondent", diff --git a/src-ui/cypress/fixtures/ui_settings/settings_restricted.json b/src-ui/cypress/fixtures/ui_settings/settings_restricted.json index 921d4274d..72ebe51b1 100644 --- a/src-ui/cypress/fixtures/ui_settings/settings_restricted.json +++ b/src-ui/cypress/fixtures/ui_settings/settings_restricted.json @@ -74,7 +74,7 @@ "change_task", "delete_task", "view_task", - "add_comment", + "add_note", "add_frontendsettings", "change_frontendsettings", "delete_frontendsettings", diff --git a/src-ui/cypress/fixtures/users/users.json b/src-ui/cypress/fixtures/users/users.json index ca477667a..a69a86b92 100644 --- a/src-ui/cypress/fixtures/users/users.json +++ b/src-ui/cypress/fixtures/users/users.json @@ -30,7 +30,7 @@ "django_celery_results.delete_taskresult", "paperless_mail.add_mailaccount", "auth.change_group", - "documents.add_comment", + "documents.add_note", "paperless_mail.delete_mailaccount", "authtoken.delete_tokenproxy", "guardian.delete_groupobjectpermission", @@ -44,7 +44,7 @@ "documents.add_documenttype", "django_q.change_success", "documents.delete_tag", - "documents.change_comment", + "documents.change_note", "django_q.delete_task", "documents.add_savedviewfilterrule", "django_q.view_task", @@ -59,7 +59,7 @@ "documents.add_savedview", "auth.delete_user", "documents.view_log", - "documents.view_comment", + "documents.view_note", "guardian.change_groupobjectpermission", "sessions.delete_session", "django_q.change_failure", @@ -139,7 +139,7 @@ "django_celery_results.view_taskresult", "contenttypes.add_contenttype", "django_q.delete_success", - "documents.delete_comment", + "documents.delete_note", "django_q.add_failure", "guardian.add_userobjectpermission", "sessions.view_session", @@ -216,10 +216,10 @@ "change_task", "delete_task", "view_task", - "add_comment", - "change_comment", - "delete_comment", - "view_comment", + "add_note", + "change_note", + "delete_note", + "view_note", "add_frontendsettings", "change_frontendsettings", "delete_frontendsettings", @@ -256,7 +256,7 @@ "django_celery_results.delete_taskresult", "authtoken.change_token", "auth.change_group", - "documents.add_comment", + "documents.add_note", "authtoken.delete_tokenproxy", "documents.view_documenttype", "contenttypes.delete_contenttype", @@ -285,7 +285,7 @@ "django_q.change_task", "sessions.add_session", "documents.change_taskattributes", - "documents.change_comment", + "documents.change_note", "django_q.delete_task", "django_q.delete_ormq", "auth.change_permission", @@ -311,7 +311,7 @@ "documents.view_document", "documents.add_savedview", "django_q.view_failure", - "documents.view_comment", + "documents.view_note", "documents.view_log", "documents.add_log", "documents.change_savedview", @@ -324,7 +324,7 @@ "django_celery_results.view_taskresult", "contenttypes.add_contenttype", "django_q.delete_success", - "documents.delete_comment", + "documents.delete_note", "django_q.add_failure", "sessions.view_session", "contenttypes.view_contenttype", @@ -373,7 +373,7 @@ "django_celery_results.delete_taskresult", "authtoken.change_token", "auth.change_group", - "documents.add_comment", + "documents.add_note", "authtoken.delete_tokenproxy", "documents.view_documenttype", "contenttypes.delete_contenttype", @@ -402,7 +402,7 @@ "django_q.change_task", "sessions.add_session", "documents.change_taskattributes", - "documents.change_comment", + "documents.change_note", "django_q.delete_task", "django_q.delete_ormq", "auth.change_permission", @@ -429,7 +429,7 @@ "documents.view_document", "documents.add_savedview", "django_q.view_failure", - "documents.view_comment", + "documents.view_note", "documents.view_log", "auth.delete_user", "documents.add_log", @@ -443,7 +443,7 @@ "django_celery_results.view_taskresult", "contenttypes.add_contenttype", "django_q.delete_success", - "documents.delete_comment", + "documents.delete_note", "django_q.add_failure", "sessions.view_session", "contenttypes.view_contenttype", diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 1f46b1d6c..ce470a9a4 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -492,7 +492,7 @@ src/app/components/document-list/document-list.component.ts - 94 + 97 src/app/components/manage/management-list/management-list.component.html @@ -1826,7 +1826,7 @@ Not assigned src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts - 321 + 335 Filter drop down element to filter for documents with no correspondent/type/tag assigned @@ -1922,7 +1922,7 @@ src/app/components/document-list/document-card-small/document-card-small.component.html - 70 + 78 src/app/components/manage/management-list/management-list.component.html @@ -2157,7 +2157,7 @@ src/app/components/document-list/document-list.component.html - 159 + 165 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2328,41 +2328,6 @@ 1 - - Enter comment - - src/app/components/document-comments/document-comments.component.html - 4 - - - - Please enter a comment. - - src/app/components/document-comments/document-comments.component.html - 5,7 - - - - Add comment - - src/app/components/document-comments/document-comments.component.html - 11 - - - - Error saving comment: - - src/app/components/document-comments/document-comments.component.ts - 71 - - - - Error deleting comment: - - src/app/components/document-comments/document-comments.component.ts - 86 - - Page @@ -2397,7 +2362,7 @@ src/app/components/document-list/document-card-small/document-card-small.component.html - 86 + 94 @@ -2503,7 +2468,7 @@ src/app/components/document-list/document-list.component.html - 147 + 153 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2526,7 +2491,7 @@ src/app/components/document-list/document-list.component.html - 153 + 159 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -2653,15 +2618,11 @@ 215 - - Comments + + Notes src/app/components/document-detail/document-detail.component.html - 175 - - - src/app/components/manage/settings/settings.component.html - 159 + 175,176 @@ -2682,32 +2643,32 @@ Error retrieving metadata src/app/components/document-detail/document-detail.component.ts - 305 + 341 Error retrieving suggestions src/app/components/document-detail/document-detail.component.ts - 325 + 361 Error saving document src/app/components/document-detail/document-detail.component.ts - 439 + 475 src/app/components/document-detail/document-detail.component.ts - 483 + 519 Confirm delete src/app/components/document-detail/document-detail.component.ts - 512 + 548 src/app/components/manage/management-list/management-list.component.ts @@ -2718,35 +2679,35 @@ Do you really want to delete document ""? src/app/components/document-detail/document-detail.component.ts - 513 + 549 The files for this document will be deleted permanently. This operation cannot be undone. src/app/components/document-detail/document-detail.component.ts - 514 + 550 Delete document src/app/components/document-detail/document-detail.component.ts - 516 + 552 Error deleting document: src/app/components/document-detail/document-detail.component.ts - 532 + 568 Redo OCR confirm src/app/components/document-detail/document-detail.component.ts - 552 + 588 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -2757,14 +2718,14 @@ This operation will permanently redo OCR for this document. src/app/components/document-detail/document-detail.component.ts - 553 + 589 This operation cannot be undone. src/app/components/document-detail/document-detail.component.ts - 554 + 590 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -2795,7 +2756,7 @@ Proceed src/app/components/document-detail/document-detail.component.ts - 556 + 592 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -2822,7 +2783,7 @@ Redo OCR operation will begin in the background. Close and re-open or reload this document after the operation has completed to see new content. src/app/components/document-detail/document-detail.component.ts - 564 + 600 @@ -2831,7 +2792,7 @@ )"/> src/app/components/document-detail/document-detail.component.ts - 575,577 + 611,613 @@ -3152,7 +3113,7 @@ src/app/components/document-list/document-list.component.html - 180 + 186 @@ -3163,69 +3124,83 @@ src/app/components/document-list/document-list.component.html - 185 + 191 + + + + View notes + + src/app/components/document-list/document-card-large/document-card-large.component.html + 70 + + + + Notes + + src/app/components/document-list/document-card-large/document-card-large.component.html + 74 Filter by document type src/app/components/document-list/document-card-large/document-card-large.component.html - 69 + 76 src/app/components/document-list/document-list.component.html - 189 + 204 Filter by storage path src/app/components/document-list/document-card-large/document-card-large.component.html - 76 + 83 src/app/components/document-list/document-list.component.html - 194 + 209 Created: src/app/components/document-list/document-card-large/document-card-large.component.html - 91,92 + 98,99 src/app/components/document-list/document-card-small/document-card-small.component.html - 48,49 + 56,57 Added: src/app/components/document-list/document-card-large/document-card-large.component.html - 92,93 + 99,100 src/app/components/document-list/document-card-small/document-card-small.component.html - 49,50 + 57,58 Modified: src/app/components/document-list/document-card-large/document-card-large.component.html - 93,94 + 100,101 src/app/components/document-list/document-card-small/document-card-small.component.html - 50,51 + 58,59 Score: src/app/components/document-list/document-card-large/document-card-large.component.html - 104 + 110 @@ -3239,21 +3214,21 @@ Toggle correspondent filter src/app/components/document-list/document-card-small/document-card-small.component.html - 24 + 32 Toggle document type filter src/app/components/document-list/document-card-small/document-card-small.component.html - 31 + 39 Toggle storage path filter src/app/components/document-list/document-card-small/document-card-small.component.html - 38 + 46 @@ -3352,11 +3327,26 @@ 18 + + Notes + + src/app/components/document-list/document-list.component.html + 147 + + + src/app/components/manage/settings/settings.component.html + 159 + + + src/app/services/rest/document.service.ts + 25 + + Added src/app/components/document-list/document-list.component.html - 165 + 171 src/app/components/document-list/filter-editor/filter-editor.component.html @@ -3371,21 +3361,21 @@ Edit document src/app/components/document-list/document-list.component.html - 184 + 190 View "" saved successfully. src/app/components/document-list/document-list.component.ts - 202 + 205 View "" created successfully. src/app/components/document-list/document-list.component.ts - 243 + 246 @@ -3550,6 +3540,52 @@ 13 + + Enter note + + src/app/components/document-notes/document-notes.component.html + 4 + + + + Please enter a note. + + src/app/components/document-notes/document-notes.component.html + 5,7 + + + + Add note + + src/app/components/document-notes/document-notes.component.html + 11 + + + + Delete note + + src/app/components/document-notes/document-notes.component.html + 21 + + + src/app/components/document-notes/document-notes.component.html + 25 + + + + Error saving note: + + src/app/components/document-notes/document-notes.component.ts + 65 + + + + Error deleting note: + + src/app/components/document-notes/document-notes.component.ts + 81 + + correspondent @@ -4018,8 +4054,8 @@ 155 - - Enable comments + + Enable notes src/app/components/manage/settings/settings.component.html 163 @@ -4670,11 +4706,11 @@ src/app/services/open-documents.service.ts - 103 + 104 src/app/services/open-documents.service.ts - 130 + 131 @@ -4685,7 +4721,7 @@ src/app/services/open-documents.service.ts - 131 + 132 @@ -4857,35 +4893,35 @@ You have unsaved changes to the document src/app/services/open-documents.service.ts - 105 + 106 Are you sure you want to close this document? src/app/services/open-documents.service.ts - 109 + 110 Close document src/app/services/open-documents.service.ts - 111 + 112 Are you sure you want to close all documents? src/app/services/open-documents.service.ts - 132 + 133 Close documents src/app/services/open-documents.service.ts - 134 + 135 @@ -4899,7 +4935,7 @@ Search score src/app/services/rest/document.service.ts - 31 + 32 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-routing.module.ts b/src-ui/src/app/app-routing.module.ts index 6f26a81fd..4d12ee4f3 100644 --- a/src-ui/src/app/app-routing.module.ts +++ b/src-ui/src/app/app-routing.module.ts @@ -65,6 +65,17 @@ const routes: Routes = [ }, }, }, + { + path: 'documents/:id/:section', + component: DocumentDetailComponent, + canActivate: [PermissionsGuard], + data: { + requiredPermission: { + action: PermissionAction.View, + type: PermissionType.Document, + }, + }, + }, { path: 'asn/:id', component: DocumentAsnComponent, @@ -143,17 +154,6 @@ const routes: Routes = [ }, }, }, - { - path: 'tasks', - component: TasksComponent, - canActivate: [PermissionsGuard], - data: { - requiredPermission: { - action: PermissionAction.View, - type: PermissionType.PaperlessTask, - }, - }, - }, { path: 'settings/:section', component: SettingsComponent, @@ -171,6 +171,17 @@ const routes: Routes = [ component: SettingsComponent, canDeactivate: [DirtyFormGuard], }, + { + path: 'tasks', + component: TasksComponent, + canActivate: [PermissionsGuard], + data: { + requiredPermission: { + action: PermissionAction.View, + type: PermissionType.PaperlessTask, + }, + }, + }, { path: 'tasks', component: TasksComponent }, ], }, diff --git a/src-ui/src/app/app.module.ts b/src-ui/src/app/app.module.ts index beb3b0935..446f63254 100644 --- a/src-ui/src/app/app.module.ts +++ b/src-ui/src/app/app.module.ts @@ -70,7 +70,7 @@ import { ApiVersionInterceptor } from './interceptors/api-version.interceptor' import { ColorSliderModule } from 'ngx-color/slider' import { ColorComponent } from './components/common/input/color/color.component' import { DocumentAsnComponent } from './components/document-asn/document-asn.component' -import { DocumentCommentsComponent } from './components/document-comments/document-comments.component' +import { DocumentNotesComponent } from './components/document-notes/document-notes.component' import { PermissionsGuard } from './guards/permissions.guard' import { DirtyDocGuard } from './guards/dirty-doc.guard' import { DirtySavedViewGuard } from './guards/dirty-saved-view.guard' @@ -196,7 +196,7 @@ function initializeApp(settings: SettingsService) { DateComponent, ColorComponent, DocumentAsnComponent, - DocumentCommentsComponent, + DocumentNotesComponent, TasksComponent, UserEditDialogComponent, GroupEditDialogComponent, diff --git a/src-ui/src/app/components/document-comments/document-comments.component.ts b/src-ui/src/app/components/document-comments/document-comments.component.ts deleted file mode 100644 index f5c63ab07..000000000 --- a/src-ui/src/app/components/document-comments/document-comments.component.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { Component, Input } from '@angular/core' -import { DocumentCommentsService } from 'src/app/services/rest/document-comments.service' -import { PaperlessDocumentComment } from 'src/app/data/paperless-document-comment' -import { FormControl, FormGroup } from '@angular/forms' -import { first } from 'rxjs/operators' -import { ToastService } from 'src/app/services/toast.service' -import { ComponentWithPermissions } from '../with-permissions/with-permissions.component' - -@Component({ - selector: 'app-document-comments', - templateUrl: './document-comments.component.html', - styleUrls: ['./document-comments.component.scss'], -}) -export class DocumentCommentsComponent extends ComponentWithPermissions { - commentForm: FormGroup = new FormGroup({ - newComment: new FormControl(''), - }) - - networkActive = false - comments: PaperlessDocumentComment[] = [] - newCommentError: boolean = false - - private _documentId: number - - @Input() - set documentId(id: number) { - if (id != this._documentId) { - this._documentId = id - this.update() - } - } - - constructor( - private commentsService: DocumentCommentsService, - private toastService: ToastService - ) { - super() - } - - update(): void { - this.networkActive = true - this.commentsService - .getComments(this._documentId) - .pipe(first()) - .subscribe((comments) => { - this.comments = comments - this.networkActive = false - }) - } - - addComment() { - const comment: string = this.commentForm - .get('newComment') - .value.toString() - .trim() - if (comment.length == 0) { - this.newCommentError = true - return - } - this.newCommentError = false - this.networkActive = true - this.commentsService.addComment(this._documentId, comment).subscribe({ - next: (result) => { - this.comments = result - this.commentForm.get('newComment').reset() - this.networkActive = false - }, - error: (e) => { - this.networkActive = false - this.toastService.showError( - $localize`Error saving comment: ${e.toString()}` - ) - }, - }) - } - - deleteComment(commentId: number) { - this.commentsService.deleteComment(this._documentId, commentId).subscribe({ - next: (result) => { - this.comments = result - this.networkActive = false - }, - error: (e) => { - this.networkActive = false - this.toastService.showError( - $localize`Error deleting comment: ${e.toString()}` - ) - }, - }) - } - - displayName(comment: PaperlessDocumentComment): string { - if (!comment.user) return '' - let nameComponents = [] - if (comment.user.first_name) nameComponents.unshift(comment.user.first_name) - if (comment.user.last_name) nameComponents.unshift(comment.user.last_name) - if (comment.user.username) { - if (nameComponents.length > 0) - nameComponents.push(`(${comment.user.username})`) - else nameComponents.push(comment.user.username) - } - return nameComponents.join(' ') - } -} diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index 3459ce2ae..3cd4c9a17 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -67,8 +67,8 @@
-