Saved views, some refactoring

This commit is contained in:
Jonas Winkler
2020-10-30 22:46:43 +01:00
parent a5c2ed1d76
commit c39d94b8cb
43 changed files with 461 additions and 232 deletions

View File

@@ -1,6 +1,6 @@
import { Directive, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { MatchingModel } from 'src/app/data/matching-model';
import { MatchingModel, MATCHING_ALGORITHMS, MATCH_AUTO } from 'src/app/data/matching-model';
import { ObjectWithId } from 'src/app/data/object-with-id';
import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service';
import { DeleteDialogComponent } from '../../common/delete-dialog/delete-dialog.component';
@@ -21,10 +21,10 @@ export abstract class GenericListComponent<T extends ObjectWithId> implements On
public collectionSize = 0
getMatching(o: MatchingModel) {
if (o.matching_algorithm == MatchingModel.MATCH_AUTO) {
if (o.matching_algorithm == MATCH_AUTO) {
return "Automatic"
} else if (o.match && o.match.length > 0) {
return `${o.match} (${MatchingModel.MATCHING_ALGORITHMS.find(a => a.id == o.matching_algorithm).name})`
return `${o.match} (${MATCHING_ALGORITHMS.find(a => a.id == o.matching_algorithm).name})`
} else {
return "-"
}

View File

@@ -2,5 +2,38 @@
</app-page-header>
<p>items per page, documents per view type</p>
<!-- <p>items per page, documents per view type</p> -->
<ul ngbNav #nav="ngbNav" class="nav-tabs">
<li [ngbNavItem]="1">
<a ngbNavLink>Document List Settings</a>
<ng-template ngbNavContent>
</ng-template>
</li>
<li [ngbNavItem]="2">
<a ngbNavLink>Saved views</a>
<ng-template ngbNavContent>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Show in dashboard</th>
<th scope="col">Show in sidebar</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let config of savedViewConfigService.getConfigs()">
<td>{{ config.title }}</td>
<td>{{ config.showInDashboard }}</td>
<td>{{ config.showInSideBar }}</td>
<td><button type="button" class="btn btn-sm btn-outline-danger" (click)="deleteViewConfig(config)">Delete</button></td>
</tr>
</tbody>
</table>
</ng-template>
</li>
</ul>
<div [ngbNavOutlet]="nav" class="mt-2"></div>

View File

@@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { SavedViewConfig } from 'src/app/data/saved-view-config';
import { SavedViewConfigService } from 'src/app/services/saved-view-config.service';
@Component({
selector: 'app-settings',
@@ -7,9 +9,17 @@ import { Component, OnInit } from '@angular/core';
})
export class SettingsComponent implements OnInit {
constructor() { }
constructor(
private savedViewConfigService: SavedViewConfigService
) { }
active
ngOnInit(): void {
}
deleteViewConfig(config: SavedViewConfig) {
this.savedViewConfigService.deleteConfig(config)
}
}

View File

@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component';
import { PaperlessTag } from 'src/app/data/paperless-tag';
import { TAG_COLOURS, PaperlessTag } from 'src/app/data/paperless-tag';
import { TagService } from 'src/app/services/rest/tag.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -29,11 +29,11 @@ export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
}
getColours() {
return PaperlessTag.COLOURS
return TAG_COLOURS
}
getColor(id: number) {
return PaperlessTag.COLOURS.find(c => c.id == id)
return TAG_COLOURS.find(c => c.id == id)
}
}

View File

@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { PaperlessTag } from 'src/app/data/paperless-tag';
import { TAG_COLOURS, PaperlessTag } from 'src/app/data/paperless-tag';
import { TagService } from 'src/app/services/rest/tag.service';
import { CorrespondentEditDialogComponent } from '../correspondent-list/correspondent-edit-dialog/correspondent-edit-dialog.component';
import { GenericListComponent } from '../generic-list/generic-list.component';
@@ -18,7 +18,7 @@ export class TagListComponent extends GenericListComponent<PaperlessTag> {
}
getColor(id) {
return PaperlessTag.COLOURS.find(c => c.id == id)
return TAG_COLOURS.find(c => c.id == id)
}
getObjectName(object: PaperlessTag) {