mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Refactoring a few frontend components
This commit is contained in:
		| @@ -8,6 +8,7 @@ import { | |||||||
| } from 'src/app/services/permissions.service' | } from 'src/app/services/permissions.service' | ||||||
| import { UserService } from 'src/app/services/rest/user.service' | import { UserService } from 'src/app/services/rest/user.service' | ||||||
| import { SettingsService } from 'src/app/services/settings.service' | import { SettingsService } from 'src/app/services/settings.service' | ||||||
|  | import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component' | ||||||
|  |  | ||||||
| export class PermissionsSelectionModel { | export class PermissionsSelectionModel { | ||||||
|   ownerFilter: OwnerFilterType |   ownerFilter: OwnerFilterType | ||||||
| @@ -38,9 +39,7 @@ export enum OwnerFilterType { | |||||||
|   templateUrl: './permissions-filter-dropdown.component.html', |   templateUrl: './permissions-filter-dropdown.component.html', | ||||||
|   styleUrls: ['./permissions-filter-dropdown.component.scss'], |   styleUrls: ['./permissions-filter-dropdown.component.scss'], | ||||||
| }) | }) | ||||||
| export class PermissionsFilterDropdownComponent { | export class PermissionsFilterDropdownComponent extends ComponentWithPermissions { | ||||||
|   public PermissionAction = PermissionAction |  | ||||||
|   public PermissionType = PermissionType |  | ||||||
|   public OwnerFilterType = OwnerFilterType |   public OwnerFilterType = OwnerFilterType | ||||||
|  |  | ||||||
|   @Input() |   @Input() | ||||||
| @@ -71,6 +70,7 @@ export class PermissionsFilterDropdownComponent { | |||||||
|     userService: UserService, |     userService: UserService, | ||||||
|     private settingsService: SettingsService |     private settingsService: SettingsService | ||||||
|   ) { |   ) { | ||||||
|  |     super() | ||||||
|     if ( |     if ( | ||||||
|       permissionsService.currentUserCan( |       permissionsService.currentUserCan( | ||||||
|         PermissionAction.View, |         PermissionAction.View, | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ import { | |||||||
|   PermissionsService, |   PermissionsService, | ||||||
|   PermissionType, |   PermissionType, | ||||||
| } from 'src/app/services/permissions.service' | } from 'src/app/services/permissions.service' | ||||||
|  | import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component' | ||||||
|  |  | ||||||
| @Component({ | @Component({ | ||||||
|   providers: [ |   providers: [ | ||||||
| @@ -25,11 +26,9 @@ import { | |||||||
|   styleUrls: ['./permissions-select.component.scss'], |   styleUrls: ['./permissions-select.component.scss'], | ||||||
| }) | }) | ||||||
| export class PermissionsSelectComponent | export class PermissionsSelectComponent | ||||||
|  |   extends ComponentWithPermissions | ||||||
|   implements OnInit, ControlValueAccessor |   implements OnInit, ControlValueAccessor | ||||||
| { | { | ||||||
|   PermissionType = PermissionType |  | ||||||
|   PermissionAction = PermissionAction |  | ||||||
|  |  | ||||||
|   @Input() |   @Input() | ||||||
|   title: string = 'Permissions' |   title: string = 'Permissions' | ||||||
|  |  | ||||||
| @@ -62,6 +61,7 @@ export class PermissionsSelectComponent | |||||||
|   inheritedWarning: string = $localize`Inherited from group` |   inheritedWarning: string = $localize`Inherited from group` | ||||||
|  |  | ||||||
|   constructor(private readonly permissionsService: PermissionsService) { |   constructor(private readonly permissionsService: PermissionsService) { | ||||||
|  |     super() | ||||||
|     for (const type in PermissionType) { |     for (const type in PermissionType) { | ||||||
|       const control = new FormGroup({}) |       const control = new FormGroup({}) | ||||||
|       for (const action in PermissionAction) { |       for (const action in PermissionAction) { | ||||||
|   | |||||||
| @@ -44,6 +44,7 @@ import { PaperlessUser } from 'src/app/data/paperless-user' | |||||||
| import { UserService } from 'src/app/services/rest/user.service' | import { UserService } from 'src/app/services/rest/user.service' | ||||||
| import { PaperlessDocumentNote } from 'src/app/data/paperless-document-note' | import { PaperlessDocumentNote } from 'src/app/data/paperless-document-note' | ||||||
| import { HttpClient } from '@angular/common/http' | import { HttpClient } from '@angular/common/http' | ||||||
|  | import { ComponentWithPermissions } from '../with-permissions/with-permissions.component' | ||||||
|  |  | ||||||
| enum DocumentDetailNavIDs { | enum DocumentDetailNavIDs { | ||||||
|   Details = 1, |   Details = 1, | ||||||
| @@ -60,6 +61,7 @@ enum DocumentDetailNavIDs { | |||||||
|   styleUrls: ['./document-detail.component.scss'], |   styleUrls: ['./document-detail.component.scss'], | ||||||
| }) | }) | ||||||
| export class DocumentDetailComponent | export class DocumentDetailComponent | ||||||
|  |   extends ComponentWithPermissions | ||||||
|   implements OnInit, OnDestroy, DirtyComponent |   implements OnInit, OnDestroy, DirtyComponent | ||||||
| { | { | ||||||
|   @ViewChild('inputTitle') |   @ViewChild('inputTitle') | ||||||
| @@ -127,8 +129,6 @@ export class DocumentDetailComponent | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   PermissionAction = PermissionAction |  | ||||||
|   PermissionType = PermissionType |  | ||||||
|   DocumentDetailNavIDs = DocumentDetailNavIDs |   DocumentDetailNavIDs = DocumentDetailNavIDs | ||||||
|   activeNavID: number |   activeNavID: number | ||||||
|  |  | ||||||
| @@ -148,7 +148,9 @@ export class DocumentDetailComponent | |||||||
|     private permissionsService: PermissionsService, |     private permissionsService: PermissionsService, | ||||||
|     private userService: UserService, |     private userService: UserService, | ||||||
|     private http: HttpClient |     private http: HttpClient | ||||||
|   ) {} |   ) { | ||||||
|  |     super() | ||||||
|  |   } | ||||||
|  |  | ||||||
|   titleKeyUp(event) { |   titleKeyUp(event) { | ||||||
|     this.titleSubject.next(event.target?.value) |     this.titleSubject.next(event.target?.value) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon