From 111ed38cce0c887ffa615651ca85adf827bbb877 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Mon, 4 Jan 2021 00:38:29 +0100 Subject: [PATCH] fixes #121 --- .../common/input/number/number.component.html | 10 ++++++++-- .../common/input/number/number.component.ts | 20 ++++++++++++++++++- src-ui/src/app/data/filter-rule-type.ts | 3 +++ src/documents/filters.py | 2 +- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src-ui/src/app/components/common/input/number/number.component.html b/src-ui/src/app/components/common/input/number/number.component.html index aa3a893d3..7b4dcca54 100644 --- a/src-ui/src/app/components/common/input/number/number.component.html +++ b/src-ui/src/app/components/common/input/number/number.component.html @@ -1,8 +1,14 @@
- - {{hint}} +
+ +
+ +
+
{{error}}
+ {{hint}} +
\ No newline at end of file diff --git a/src-ui/src/app/components/common/input/number/number.component.ts b/src-ui/src/app/components/common/input/number/number.component.ts index 987a4090b..cdc52344d 100644 --- a/src-ui/src/app/components/common/input/number/number.component.ts +++ b/src-ui/src/app/components/common/input/number/number.component.ts @@ -1,5 +1,7 @@ import { Component, forwardRef } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; +import { FILTER_ASN_ISNULL } from 'src/app/data/filter-rule-type'; +import { DocumentService } from 'src/app/services/rest/document.service'; import { AbstractInputComponent } from '../abstract-input'; @Component({ @@ -14,8 +16,24 @@ import { AbstractInputComponent } from '../abstract-input'; }) export class NumberComponent extends AbstractInputComponent { - constructor() { + constructor(private documentService: DocumentService) { super() } + nextAsn() { + if (this.value) { + return + } + this.documentService.listFiltered(1, 1, "archive_serial_number", true, [{rule_type: FILTER_ASN_ISNULL, value: "false"}]).subscribe( + results => { + if (results.count > 0) { + this.value = results.results[0].archive_serial_number + 1 + } else { + this.value + 1 + } + this.onChange(this.value) + } + ) + } + } diff --git a/src-ui/src/app/data/filter-rule-type.ts b/src-ui/src/app/data/filter-rule-type.ts index 173425c92..577e304d2 100644 --- a/src-ui/src/app/data/filter-rule-type.ts +++ b/src-ui/src/app/data/filter-rule-type.ts @@ -18,6 +18,8 @@ export const FILTER_MODIFIED_AFTER = 16 export const FILTER_DOES_NOT_HAVE_TAG = 17 +export const FILTER_ASN_ISNULL = 18 + export const FILTER_RULE_TYPES: FilterRuleType[] = [ {id: FILTER_TITLE, name: "Title contains", filtervar: "title__icontains", datatype: "string", multi: false, default: ""}, @@ -45,6 +47,7 @@ export const FILTER_RULE_TYPES: FilterRuleType[] = [ {id: FILTER_MODIFIED_BEFORE, name: "Modified before", filtervar: "modified__date__lt", datatype: "date", multi: false}, {id: FILTER_MODIFIED_AFTER, name: "Modified after", filtervar: "modified__date__gt", datatype: "date", multi: false}, + {id: FILTER_ASN_ISNULL, name: "ASN is null", filtervar: "archive_serial_number__isnull", datatype: "boolean", multi: false} ] export interface FilterRuleType { diff --git a/src/documents/filters.py b/src/documents/filters.py index 4614d292b..2201298f3 100755 --- a/src/documents/filters.py +++ b/src/documents/filters.py @@ -4,7 +4,7 @@ from .models import Correspondent, Document, Tag, DocumentType, Log CHAR_KWARGS = ["istartswith", "iendswith", "icontains", "iexact"] ID_KWARGS = ["in", "exact"] -INT_KWARGS = ["exact", "gt", "gte", "lt", "lte"] +INT_KWARGS = ["exact", "gt", "gte", "lt", "lte", "isnull"] DATE_KWARGS = ["year", "month", "day", "date__gt", "gt", "date__lt", "lt"]