paperless-ngx/src-ui/src/app/services/rest/consumption-template.service.ts
shamoon 9712ac109d
Feature: consumption templates (#4196)
* Initial implementation of consumption templates

* Frontend implementation of consumption templates

Testing

* Support consumption template source

* order templates, automatically add permissions

* Support title assignment in consumption templates

* Refactoring, filters to and, show sources on list

Show sources on template list, update some translation strings

Make filters and

minor testing

* Update strings

* Only update django-multiselectfield

* Basic docs, document some methods

* Improve testing coverage, template multi-assignment merges
2023-09-22 16:53:13 -07:00

43 lines
1.1 KiB
TypeScript

import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { tap } from 'rxjs'
import { PaperlessConsumptionTemplate } from 'src/app/data/paperless-consumption-template'
import { AbstractPaperlessService } from './abstract-paperless-service'
@Injectable({
providedIn: 'root',
})
export class ConsumptionTemplateService extends AbstractPaperlessService<PaperlessConsumptionTemplate> {
loading: boolean
constructor(http: HttpClient) {
super(http, 'consumption_templates')
}
public reload() {
this.loading = true
this.listAll().subscribe((r) => {
this.templates = r.results
this.loading = false
})
}
private templates: PaperlessConsumptionTemplate[] = []
public get allTemplates(): PaperlessConsumptionTemplate[] {
return this.templates
}
create(o: PaperlessConsumptionTemplate) {
return super.create(o).pipe(tap(() => this.reload()))
}
update(o: PaperlessConsumptionTemplate) {
return super.update(o).pipe(tap(() => this.reload()))
}
delete(o: PaperlessConsumptionTemplate) {
return super.delete(o).pipe(tap(() => this.reload()))
}
}