mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	default saved view names
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
import { Component, OnInit, ViewChild } from '@angular/core';
 | 
			
		||||
import { ActivatedRoute, Router } from '@angular/router';
 | 
			
		||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
 | 
			
		||||
import { FILTER_CORRESPONDENT } from 'src/app/data/filter-rule-type';
 | 
			
		||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view';
 | 
			
		||||
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
 | 
			
		||||
import { DOCUMENT_SORT_FIELDS } from 'src/app/services/rest/document.service';
 | 
			
		||||
@@ -83,6 +84,7 @@ export class DocumentListComponent implements OnInit {
 | 
			
		||||
 | 
			
		||||
  saveViewConfigAs() {
 | 
			
		||||
    let modal = this.modalService.open(SaveViewConfigDialogComponent, {backdrop: 'static'})
 | 
			
		||||
    modal.componentInstance.defaultName = this.filterEditor.generateFilterName()
 | 
			
		||||
    modal.componentInstance.saveClicked.subscribe(formValue => {
 | 
			
		||||
      let savedView = {
 | 
			
		||||
        name: formValue.name,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
 | 
			
		||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
 | 
			
		||||
import { FormControl, FormGroup } from '@angular/forms';
 | 
			
		||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 | 
			
		||||
 | 
			
		||||
@@ -14,6 +14,19 @@ export class SaveViewConfigDialogComponent implements OnInit {
 | 
			
		||||
  @Output()
 | 
			
		||||
  public saveClicked = new EventEmitter()
 | 
			
		||||
 | 
			
		||||
  _defaultName = ""
 | 
			
		||||
 | 
			
		||||
  get defaultName() {
 | 
			
		||||
    return this._defaultName
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Input()
 | 
			
		||||
  set defaultName(value: string) {
 | 
			
		||||
    this._defaultName = value
 | 
			
		||||
    this.saveViewConfigForm.patchValue({name: value})
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  saveViewConfigForm = new FormGroup({
 | 
			
		||||
    name: new FormControl(''),
 | 
			
		||||
    showInSideBar: new FormControl(false),
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,26 @@ import { DateSelection } from './filter-dropdown-date/filter-dropdown-date.compo
 | 
			
		||||
})
 | 
			
		||||
export class FilterEditorComponent implements OnInit, OnDestroy {
 | 
			
		||||
 | 
			
		||||
  generateFilterName() {
 | 
			
		||||
    if (this.filterRules.length == 1) {
 | 
			
		||||
      let rule = this.filterRules[0]
 | 
			
		||||
      switch(this.filterRules[0].rule_type) {
 | 
			
		||||
        
 | 
			
		||||
        case FILTER_CORRESPONDENT:
 | 
			
		||||
          return `Correspondent: ${this.correspondents.find(c => c.id == +rule.value)?.name}`
 | 
			
		||||
 | 
			
		||||
        case FILTER_DOCUMENT_TYPE:
 | 
			
		||||
          return `Type: ${this.documentTypes.find(dt => dt.id == +rule.value)?.name}`
 | 
			
		||||
 | 
			
		||||
        case FILTER_HAS_TAG:
 | 
			
		||||
          return `Tag: ${this.tags.find(t => t.id == +rule.value)?.name}`
 | 
			
		||||
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return ""
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  constructor(
 | 
			
		||||
    private documentTypeService: DocumentTypeService,
 | 
			
		||||
    private tagService: TagService,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user