mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Change detection of modified filter rules to wait for filter editor changes only
This commit is contained in:
		@@ -78,7 +78,7 @@
 | 
			
		||||
</app-page-header>
 | 
			
		||||
 | 
			
		||||
<div class="w-100 mb-2 mb-sm-4">
 | 
			
		||||
  <app-filter-editor [hidden]="isBulkEditing" [(filterRules)]="list.filterRules" [rulesModified]="filterRulesModified" (reset)="resetFilters()" #filterEditor></app-filter-editor>
 | 
			
		||||
  <app-filter-editor [hidden]="isBulkEditing" [(filterRules)]="list.filterRules" [rulesModified]="filterRulesModified" (filterRulesChange)="rulesChanged()" (reset)="resetFilters()" #filterEditor></app-filter-editor>
 | 
			
		||||
  <app-bulk-editor [hidden]="!isBulkEditing"></app-bulk-editor>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -66,9 +66,12 @@ export class DocumentListComponent implements OnInit {
 | 
			
		||||
 | 
			
		||||
      this.list.reload()
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    this.rulesChanged()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  loadViewConfig(view: PaperlessSavedView) {
 | 
			
		||||
    this.filterRulesModified = false
 | 
			
		||||
    this.list.load(view)
 | 
			
		||||
    this.list.reload()
 | 
			
		||||
  }
 | 
			
		||||
@@ -105,6 +108,7 @@ export class DocumentListComponent implements OnInit {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  resetFilters(): void {
 | 
			
		||||
    this.filterRulesModified = false;
 | 
			
		||||
    if (this.list.savedViewId) {
 | 
			
		||||
      this.savedViewService.getCached(this.list.savedViewId).subscribe(viewUntouched => {
 | 
			
		||||
        this.list.filterRules = viewUntouched.filter_rules
 | 
			
		||||
@@ -116,12 +120,14 @@ export class DocumentListComponent implements OnInit {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  get filterRulesModified(): boolean {
 | 
			
		||||
  filterRulesModified: boolean = false
 | 
			
		||||
 | 
			
		||||
  rulesChanged() {
 | 
			
		||||
    let modified = false
 | 
			
		||||
    if (this.list.savedView == null) {
 | 
			
		||||
      return this.list.filterRules.length > 0 // documents list is modified if it has any filters
 | 
			
		||||
      modified = this.list.filterRules.length > 0 // documents list is modified if it has any filters
 | 
			
		||||
    } else {
 | 
			
		||||
      // compare savedView current filters vs original
 | 
			
		||||
      let modified = false
 | 
			
		||||
      this.savedViewService.getCached(this.list.savedViewId).subscribe(view => {
 | 
			
		||||
        let filterRulesInitial = view.filter_rules
 | 
			
		||||
 | 
			
		||||
@@ -135,8 +141,8 @@ export class DocumentListComponent implements OnInit {
 | 
			
		||||
          })
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
      return modified
 | 
			
		||||
    }
 | 
			
		||||
    this.filterRulesModified = modified
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  clickTag(tagID: number) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user