A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: disable inline create buttons if insufficient permissions (#7401)
shamoon928580bf4fe9
diff --git a/src-ui/messages.xlf b/src-ui/messages.xlfindex 8e9778929..d5ae2afe8 100644--- a/src-ui/messages.xlf+++ b/src-ui/messages.xlf@@ -2229,7 +2229,7 @@</context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">799</context>+ <context context-type="linenumber">824</context></context-group></trans-unit><trans-unit id="7266264608936522311" datatype="html">@@ -2506,19 +2506,19 @@</context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">823</context>+ <context context-type="linenumber">848</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1114</context>+ <context context-type="linenumber">1139</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1152</context>+ <context context-type="linenumber">1177</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1193</context>+ <context context-type="linenumber">1218</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.ts</context>@@ -3101,7 +3101,7 @@</context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">776</context>+ <context context-type="linenumber">801</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.ts</context>@@ -5735,7 +5735,7 @@</context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1170</context>+ <context context-type="linenumber">1195</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/guards/dirty-saved-view.guard.ts</context>@@ -6092,36 +6092,36 @@<source>Document saved successfully.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">690</context>+ <context context-type="linenumber">715</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">704</context>+ <context context-type="linenumber">729</context></context-group></trans-unit><trans-unit id="448882439049417053" datatype="html"><source>Error saving document</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">708</context>+ <context context-type="linenumber">733</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">749</context>+ <context context-type="linenumber">774</context></context-group></trans-unit><trans-unit id="8410796510716511826" datatype="html"><source>Do you really want to move the document "<x id="PH" equiv-text="this.document.title"/>" to the trash?</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">777</context>+ <context context-type="linenumber">802</context></context-group></trans-unit><trans-unit id="282586936710748252" datatype="html"><source>Documents can be restored prior to permanent deletion.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">778</context>+ <context context-type="linenumber">803</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.ts</context>@@ -6132,7 +6132,7 @@<source>Move to trash</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">780</context>+ <context context-type="linenumber">805</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.ts</context>@@ -6143,7 +6143,7 @@<source>Reprocess confirm</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">819</context>+ <context context-type="linenumber">844</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.ts</context>@@ -6154,70 +6154,70 @@<source>This operation will permanently recreate the archive file for this document.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">820</context>+ <context context-type="linenumber">845</context></context-group></trans-unit><trans-unit id="302054111564709516" datatype="html"><source>The archive file will be re-generated with the current settings.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">821</context>+ <context context-type="linenumber">846</context></context-group></trans-unit><trans-unit id="1192507664585066165" datatype="html"><source>Reprocess operation will begin in the background. Close and re-open or reload this document after the operation has completed to see new content.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">831</context>+ <context context-type="linenumber">856</context></context-group></trans-unit><trans-unit id="4409560272830824468" datatype="html"><source>Error executing operation</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">842</context>+ <context context-type="linenumber">867</context></context-group></trans-unit><trans-unit id="4458954481601077369" datatype="html"><source>Page Fit</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">911</context>+ <context context-type="linenumber">936</context></context-group></trans-unit><trans-unit id="1217563727923422413" datatype="html"><source>Split confirm</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1112</context>+ <context context-type="linenumber">1137</context></context-group></trans-unit><trans-unit id="2805304563009985503" datatype="html"><source>This operation will split the selected document(s) into new documents.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1113</context>+ <context context-type="linenumber">1138</context></context-group></trans-unit><trans-unit id="4158171846914923744" datatype="html"><source>Split operation will begin in the background.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1129</context>+ <context context-type="linenumber">1154</context></context-group></trans-unit><trans-unit id="3235014591864339926" datatype="html"><source>Error executing split operation</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1138</context>+ <context context-type="linenumber">1163</context></context-group></trans-unit><trans-unit id="6555329262222566158" datatype="html"><source>Rotate confirm</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1150</context>+ <context context-type="linenumber">1175</context></context-group><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.ts</context>@@ -6228,49 +6228,49 @@<source>This operation will permanently rotate the original version of the current document.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1151</context>+ <context context-type="linenumber">1176</context></context-group></trans-unit><trans-unit id="4069543875319587651" datatype="html"><source>Rotation will begin in the background. Close and re-open the document after the operation has completed to see the changes.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1167</context>+ <context context-type="linenumber">1192</context></context-group></trans-unit><trans-unit id="2962674215361798818" datatype="html"><source>Error executing rotate operation</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1179</context>+ <context context-type="linenumber">1204</context></context-group></trans-unit><trans-unit id="3539261415918606512" datatype="html"><source>Delete pages confirm</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1191</context>+ <context context-type="linenumber">1216</context></context-group></trans-unit><trans-unit id="5854352498125813866" datatype="html"><source>This operation will permanently delete the selected pages from the original document.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1192</context>+ <context context-type="linenumber">1217</context></context-group></trans-unit><trans-unit id="8617528702531167646" datatype="html"><source>Delete pages operation will begin in the background. Close and re-open or reload this document after the operation has completed to see the changes.</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1207</context>+ <context context-type="linenumber">1232</context></context-group></trans-unit><trans-unit id="1249139200486584973" datatype="html"><source>Error executing delete pages operation</source><context-group purpose="location"><context context-type="sourcefile">src/app/components/document-detail/document-detail.component.ts</context>- <context context-type="linenumber">1216</context>+ <context context-type="linenumber">1241</context></context-group></trans-unit><trans-unit id="4958946940233632319" datatype="html">diff --git a/src-ui/src/app/components/common/input/tags/tags.component.html b/src-ui/src/app/components/common/input/tags/tags.component.htmlindex c7516a838..d5d5c4a7d 100644--- a/src-ui/src/app/components/common/input/tags/tags.component.html+++ b/src-ui/src/app/components/common/input/tags/tags.component.html@@ -32,7 +32,7 @@</div></ng-template></ng-select>- @if (allowCreate) {+ @if (allowCreate && !hideAddButton) {<button class="btn btn-outline-secondary" type="button" (click)="createTag()" [disabled]="disabled"><i-bs width="1.2em" height="1.2em" name="plus"></i-bs></button>diff --git a/src-ui/src/app/components/common/input/tags/tags.component.ts b/src-ui/src/app/components/common/input/tags/tags.component.tsindex d5cd70c9a..efbbb9a6e 100644--- a/src-ui/src/app/components/common/input/tags/tags.component.ts+++ b/src-ui/src/app/components/common/input/tags/tags.component.ts@@ -74,6 +74,9 @@ export class TagsComponent implements OnInit, ControlValueAccessor {@Input()allowCreate: boolean = true+ @Input()+ hideAddButton: boolean = false+@Input()showFilter: boolean = falsediff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.htmlindex d970d93b3..84ab680b1 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@@ -110,12 +110,12 @@<pngx-input-date i18n-title title="Date created" formControlName="created_date" [suggestions]="suggestions?.dates" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event)"[error]="error?.created_date"></pngx-input-date><pngx-input-select [items]="correspondents" i18n-title title="Correspondent" formControlName="correspondent" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.Correspondent)"- (createNew)="createCorrespondent($event)" [suggestions]="suggestions?.correspondents" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Correspondent }"></pngx-input-select>+ (createNew)="createCorrespondent($event)" [hideAddButton]="createDisabled(DataType.Correspondent)" [suggestions]="suggestions?.correspondents" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Correspondent }"></pngx-input-select><pngx-input-select [items]="documentTypes" i18n-title title="Document type" formControlName="document_type" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.DocumentType)"- (createNew)="createDocumentType($event)" [suggestions]="suggestions?.document_types" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.DocumentType }"></pngx-input-select>+ (createNew)="createDocumentType($event)" [hideAddButton]="createDisabled(DataType.DocumentType)" [suggestions]="suggestions?.document_types" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.DocumentType }"></pngx-input-select><pngx-input-select [items]="storagePaths" i18n-title title="Storage path" formControlName="storage_path" [allowNull]="true" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.StoragePath)"- (createNew)="createStoragePath($event)" [suggestions]="suggestions?.storage_paths" i18n-placeholder placeholder="Default" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.StoragePath }"></pngx-input-select>- <pngx-input-tags formControlName="tags" [suggestions]="suggestions?.tags" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.Tag)" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Tag }"></pngx-input-tags>+ (createNew)="createStoragePath($event)" [hideAddButton]="createDisabled(DataType.StoragePath)" [suggestions]="suggestions?.storage_paths" i18n-placeholder placeholder="Default" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.StoragePath }"></pngx-input-select>+ <pngx-input-tags formControlName="tags" [suggestions]="suggestions?.tags" [showFilter]="true" [horizontal]="true" (filterDocuments)="filterDocuments($event, DataType.Tag)" [hideAddButton]="createDisabled(DataType.Tag)" *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.Tag }"></pngx-input-tags>@for (fieldInstance of document?.custom_fields; track fieldInstance.field; let i = $index) {<div [formGroup]="customFieldFormFields.controls[i]">@switch (getCustomFieldFromInstance(fieldInstance)?.data_type) {diff --git a/src-ui/src/app/components/document-detail/document-detail.component.scss b/src-ui/src/app/components/document-detail/document-detail.component.scssindex e5032d3f3..860c5722c 100644--- a/src-ui/src/app/components/document-detail/document-detail.component.scss+++ b/src-ui/src/app/components/document-detail/document-detail.component.scss@@ -19,10 +19,6 @@--page-border: 0;}-::ng-deep form .ng-select-taggable {- max-width: calc(100% - 90px); // fudge factor for (2x) ng-select button width-}-.btn-group .dropdown-toggle-split {border-top-right-radius: inherit;border-bottom-right-radius: inherit;diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.tsindex 1a1ba44ad..c9ba5dc6a 100644--- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts+++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts@@ -1244,4 +1244,20 @@ describe('DocumentDetailComponent', () => {)fixture.detectChanges()}++ it('createDisabled should return true if the user does not have permission to add the specified data type', () => {+ currentUserCan = false+ expect(component.createDisabled(DataType.Correspondent)).toBeTruthy()+ expect(component.createDisabled(DataType.DocumentType)).toBeTruthy()+ expect(component.createDisabled(DataType.StoragePath)).toBeTruthy()+ expect(component.createDisabled(DataType.Tag)).toBeTruthy()+ })++ it('createDisabled should return false if the user has permission to add the specified data type', () => {+ currentUserCan = true+ expect(component.createDisabled(DataType.Correspondent)).toBeFalsy()+ expect(component.createDisabled(DataType.DocumentType)).toBeFalsy()+ expect(component.createDisabled(DataType.StoragePath)).toBeFalsy()+ expect(component.createDisabled(DataType.Tag)).toBeFalsy()+ })})diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.tsindex d6cbdd57e..c971870da 100644--- a/src-ui/src/app/components/document-detail/document-detail.component.ts+++ b/src-ui/src/app/components/document-detail/document-detail.component.ts@@ -651,6 +651,31 @@ export class DocumentDetailComponent})}+ createDisabled(dataType: DataType) {+ switch (dataType) {+ case DataType.Correspondent:+ return !this.permissionsService.currentUserCan(+ PermissionAction.Add,+ PermissionType.Correspondent+ )+ case DataType.DocumentType:+ return !this.permissionsService.currentUserCan(+ PermissionAction.Add,+ PermissionType.DocumentType+ )+ case DataType.StoragePath:+ return !this.permissionsService.currentUserCan(+ PermissionAction.Add,+ PermissionType.StoragePath+ )+ case DataType.Tag:+ return !this.permissionsService.currentUserCan(+ PermissionAction.Add,+ PermissionType.Tag+ )+ }+ }+discard() {this.documentsService.get(this.documentId)