mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 08:08:14 -06:00
Changed saved views handling, changed repository structure with automatic persistence.
This commit is contained in:
@@ -100,6 +100,7 @@ class DocumentFilter extends Equatable {
|
||||
DateRangeQuery? created,
|
||||
DateRangeQuery? modified,
|
||||
TextQuery? query,
|
||||
int? selectedViewId,
|
||||
}) {
|
||||
final newFilter = DocumentFilter(
|
||||
pageSize: pageSize ?? this.pageSize,
|
||||
@@ -135,7 +136,7 @@ class DocumentFilter extends Equatable {
|
||||
created != initial.created,
|
||||
modified != initial.modified,
|
||||
asnQuery != initial.asnQuery,
|
||||
(query.queryText != initial.query.queryText),
|
||||
((query.queryText ?? '') != (initial.query.queryText ?? '')),
|
||||
].fold(0, (previousValue, element) => previousValue += element ? 1 : 0);
|
||||
|
||||
@override
|
||||
|
||||
@@ -52,7 +52,7 @@ class PagedSearchResult<T> extends Equatable {
|
||||
required this.results,
|
||||
});
|
||||
|
||||
factory PagedSearchResult.fromJson(Map<String, dynamic> json,
|
||||
factory PagedSearchResult.fromJsonT(Map<String, dynamic> json,
|
||||
JsonConverter<T, Map<String, dynamic>> converter) {
|
||||
return PagedSearchResult(
|
||||
count: json['count'],
|
||||
@@ -77,7 +77,7 @@ class PagedSearchResult<T> extends Equatable {
|
||||
factory PagedSearchResult.fromJsonSingleParam(
|
||||
PagedSearchResultJsonSerializer<T> serializer,
|
||||
) {
|
||||
return PagedSearchResult.fromJson(serializer.json, serializer.converter);
|
||||
return PagedSearchResult.fromJsonT(serializer.json, serializer.converter);
|
||||
}
|
||||
|
||||
PagedSearchResult copyWith({
|
||||
|
||||
@@ -5,9 +5,6 @@ import 'include_tag_id_query.dart';
|
||||
import 'tag_id_query.dart';
|
||||
import 'tags_query.dart';
|
||||
|
||||
part 'ids_tags_query.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class IdsTagsQuery extends TagsQuery {
|
||||
final Iterable<TagIdQuery> _idQueries;
|
||||
|
||||
@@ -77,8 +74,15 @@ class IdsTagsQuery extends TagsQuery {
|
||||
List<Object?> get props => [_idQueries];
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$IdsTagsQueryToJson(this);
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'queries': _idQueries.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
factory IdsTagsQuery.fromJson(Map<String, dynamic> json) =>
|
||||
_$IdsTagsQueryFromJson(json);
|
||||
factory IdsTagsQuery.fromJson(Map<String, dynamic> json) {
|
||||
return IdsTagsQuery(
|
||||
(json['queries'] as List).map((e) => TagIdQuery.fromJson(e)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'ids_tags_query.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
IdsTagsQuery _$IdsTagsQueryFromJson(Map<String, dynamic> json) =>
|
||||
IdsTagsQuery();
|
||||
|
||||
Map<String, dynamic> _$IdsTagsQueryToJson(IdsTagsQuery instance) =>
|
||||
<String, dynamic>{};
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
|
||||
abstract class TagIdQuery extends Equatable {
|
||||
final int id;
|
||||
@@ -11,4 +12,24 @@ abstract class TagIdQuery extends Equatable {
|
||||
List<Object?> get props => [id, methodName];
|
||||
|
||||
TagIdQuery toggle();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'type': methodName,
|
||||
'id': id,
|
||||
};
|
||||
}
|
||||
|
||||
factory TagIdQuery.fromJson(Map<String, dynamic> json) {
|
||||
final type = json['type'] as String;
|
||||
var id = json['id'];
|
||||
switch (type) {
|
||||
case 'include':
|
||||
return IncludeTagIdQuery(id);
|
||||
case 'exclude':
|
||||
return ExcludeTagIdQuery(id);
|
||||
default:
|
||||
throw Exception('Error parsing TagIdQuery: Unknown type $type');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class TextQuery {
|
||||
|
||||
Map<String, String> toQueryParameter() {
|
||||
final params = <String, String>{};
|
||||
if (queryText != null) {
|
||||
if (queryText != null && queryText!.isNotEmpty) {
|
||||
params.addAll({queryType.queryParam: queryText!});
|
||||
}
|
||||
return params;
|
||||
|
||||
Reference in New Issue
Block a user