* 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
43 lines
1.1 KiB
TypeScript
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()))
|
|
}
|
|
}
|