mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Rename dropdown type enum & add pass as variable to use like an Enum
This commit is contained in:
		| @@ -1,12 +1,12 @@ | ||||
| <div class="btn-group" ngbDropdown role="group" (openChange)="dropdownOpenChange($event)" #dropdown="ngbDropdown"> | ||||
|   <button class="btn btn-sm" id="dropdown{{title}}" ngbDropdownToggle [ngClass]="type !== 'actions' && itemsSelected?.length > 0 ? 'btn-primary' : 'btn-outline-primary'"> | ||||
|   <button class="btn btn-sm" id="dropdown{{title}}" ngbDropdownToggle [ngClass]="type !== types.Editing && itemsSelected?.length > 0 ? 'btn-primary' : 'btn-outline-primary'"> | ||||
|     <div class="d-none d-md-inline">{{title}}</div> | ||||
|     <div class="d-inline-block d-md-none"> | ||||
|       <svg class="toolbaricon" fill="currentColor"> | ||||
|         <use attr.xlink:href="assets/bootstrap-icons.svg#{{icon}}" /> | ||||
|       </svg> | ||||
|     </div> | ||||
|     <ng-container *ngIf="type !== 'actions' && itemsSelected?.length > 0"> | ||||
|     <ng-container *ngIf="type !== types.Editing && itemsSelected?.length > 0"> | ||||
|       <div class="badge bg-secondary text-light rounded-pill badge-corner"> | ||||
|         {{itemsSelected?.length}} | ||||
|       </div> | ||||
|   | ||||
| @@ -19,7 +19,7 @@ export enum SelectableItemState { | ||||
|  | ||||
| export enum FilterableDropdownType { | ||||
|   Filtering = 'filtering', | ||||
|   Actions = 'actions' | ||||
|   Editing = 'editing' | ||||
| } | ||||
|  | ||||
| @Component({ | ||||
| @@ -47,7 +47,7 @@ export class FilterableDropdownComponent { | ||||
|  | ||||
|   @Input() | ||||
|   set selectableItems (selectableItems: SelectableItem[]) { | ||||
|     if (this.type == FilterableDropdownType.Actions && this.dropdown?.isOpen()) return | ||||
|     if (this.type == FilterableDropdownType.Editing && this.dropdown?.isOpen()) return | ||||
|     else this._selectableItems = selectableItems | ||||
|   } | ||||
|  | ||||
| @@ -75,6 +75,8 @@ export class FilterableDropdownComponent { | ||||
|   @Input() | ||||
|   type: FilterableDropdownType = FilterableDropdownType.Filtering | ||||
|  | ||||
|   types = FilterableDropdownType | ||||
|  | ||||
|   @Input() | ||||
|   singular: boolean = false | ||||
|  | ||||
|   | ||||
| @@ -26,9 +26,9 @@ | ||||
|   <div class="col mb-2 mb-xl-0"> | ||||
|     <div class="d-flex"> | ||||
|       <label class="ml-auto mt-1 mr-2">Apply:</label> | ||||
|       <app-filterable-dropdown class="mr-2 mr-md-3" title="Tags" icon="tag-fill" [selectableItems]="tagsSelectableItems" type="actions" (close)="applyTags($event)"></app-filterable-dropdown> | ||||
|       <app-filterable-dropdown class="mr-2 mr-md-3" title="Correspondent" icon="person-fill" [selectableItems]="correspondentsSelectableItems" type="actions" singular="true" (close)="applyCorrespondent($event)"></app-filterable-dropdown> | ||||
|       <app-filterable-dropdown class="mr-2 mr-md-3" title="Document Type" icon="file-earmark-fill" [selectableItems]="documentTypesSelectableItems" type="actions" singular="true" (close)="applyDocumentType($event)"></app-filterable-dropdown> | ||||
|       <app-filterable-dropdown class="mr-2 mr-md-3" title="Tags" icon="tag-fill" [selectableItems]="tagsSelectableItems" [type]="dropdownTypes.Editing" (close)="applyTags($event)"></app-filterable-dropdown> | ||||
|       <app-filterable-dropdown class="mr-2 mr-md-3" title="Correspondent" icon="person-fill" [selectableItems]="correspondentsSelectableItems" [type]="dropdownTypes.Editing" singular="true" (close)="applyCorrespondent($event)"></app-filterable-dropdown> | ||||
|       <app-filterable-dropdown class="mr-2 mr-md-3" title="Document Type" icon="file-earmark-fill" [selectableItems]="documentTypesSelectableItems" [type]="dropdownTypes.Editing" singular="true" (close)="applyDocumentType($event)"></app-filterable-dropdown> | ||||
|     </div> | ||||
|   </div> | ||||
|   <div class="w-100 d-xl-none"></div> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import { TagService } from 'src/app/services/rest/tag.service'; | ||||
| import { CorrespondentService } from 'src/app/services/rest/correspondent.service'; | ||||
| import { DocumentTypeService } from 'src/app/services/rest/document-type.service'; | ||||
| import { DocumentService } from 'src/app/services/rest/document.service'; | ||||
| import { SelectableItem, SelectableItemState } from 'src/app/components/common/filterable-dropdown/filterable-dropdown.component'; | ||||
| import { SelectableItem, SelectableItemState, FilterableDropdownType } from 'src/app/components/common/filterable-dropdown/filterable-dropdown.component'; | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'app-bulk-editor', | ||||
| @@ -47,6 +47,7 @@ export class BulkEditorComponent { | ||||
|   correspondents: PaperlessCorrespondent[] | ||||
|   documentTypes: PaperlessDocumentType[] | ||||
|  | ||||
|   dropdownTypes = FilterableDropdownType | ||||
|   get tagsSelectableItems(): SelectableItem[] { | ||||
|     let tagsSelectableItems = [] | ||||
|     let selectedDocuments: PaperlessDocument[] = this.allDocuments.filter(d => this.selectedDocuments.has(d.id)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Shamoon
					Michael Shamoon