mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-07 22:07:49 -06:00
Reworked inbox, added more information and allow suggestions to be directly clicked
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user