Reworked inbox, added more information and allow suggestions to be directly clicked

This commit is contained in:
Anton Stubenbord
2023-01-15 01:05:57 +01:00
parent 21462c0463
commit 31b6335f95
13 changed files with 551 additions and 210 deletions

View File

@@ -4,6 +4,7 @@ part 'field_suggestions.g.dart';
@JsonSerializable(fieldRename: FieldRename.snake)
class FieldSuggestions {
final int? documentId;
final Iterable<int> correspondents;
final Iterable<int> tags;
final Iterable<int> documentTypes;
@@ -11,6 +12,7 @@ class FieldSuggestions {
final Iterable<DateTime> dates;
const FieldSuggestions({
this.documentId,
this.correspondents = const [],
this.tags = const [],
this.documentTypes = const [],
@@ -38,6 +40,15 @@ class FieldSuggestions {
(storagePaths.isNotEmpty ? 1 : 0) +
(dates.isNotEmpty ? 1 : 0);
FieldSuggestions forDocumentId(int id) => FieldSuggestions(
documentId: id,
correspondents: correspondents,
dates: dates,
documentTypes: documentTypes,
tags: tags,
storagePaths: storagePaths,
);
factory FieldSuggestions.fromJson(Map<String, dynamic> json) =>
_$FieldSuggestionsFromJson(json);

View File

@@ -8,6 +8,7 @@ part of 'field_suggestions.dart';
FieldSuggestions _$FieldSuggestionsFromJson(Map<String, dynamic> json) =>
FieldSuggestions(
documentId: json['document_id'] as int?,
correspondents:
(json['correspondents'] as List<dynamic>?)?.map((e) => e as int) ??
const [],
@@ -25,6 +26,7 @@ FieldSuggestions _$FieldSuggestionsFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> _$FieldSuggestionsToJson(FieldSuggestions instance) =>
<String, dynamic>{
'document_id': instance.documentId,
'correspondents': instance.correspondents.toList(),
'tags': instance.tags.toList(),
'document_types': instance.documentTypes.toList(),

View File

@@ -259,7 +259,8 @@ class PaperlessDocumentsApiImpl implements PaperlessDocumentsApi {
final response =
await client.get("/api/documents/${document.id}/suggestions/");
if (response.statusCode == 200) {
return FieldSuggestions.fromJson(response.data);
return FieldSuggestions.fromJson(response.data)
.forDocumentId(document.id);
}
throw const PaperlessServerException(ErrorCode.suggestionsQueryError);
} on DioError catch (err) {