Initial commit

This commit is contained in:
Anton Stubenbord
2022-10-30 14:15:37 +01:00
commit cb797df7d2
272 changed files with 16278 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/id_query_parameter.dart';
class AsnQuery extends IdQueryParameter {
const AsnQuery.fromId(super.id) : super.fromId();
const AsnQuery.unset() : super.unset();
const AsnQuery.notAssigned() : super.notAssigned();
@override
String get queryParameterKey => 'archive_serial_number';
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/id_query_parameter.dart';
class CorrespondentQuery extends IdQueryParameter {
const CorrespondentQuery.fromId(super.id) : super.fromId();
const CorrespondentQuery.unset() : super.unset();
const CorrespondentQuery.notAssigned() : super.notAssigned();
@override
String get queryParameterKey => 'correspondent';
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/id_query_parameter.dart';
class DocumentTypeQuery extends IdQueryParameter {
const DocumentTypeQuery.fromId(super.id) : super.fromId();
const DocumentTypeQuery.unset() : super.unset();
const DocumentTypeQuery.notAssigned() : super.notAssigned();
@override
String get queryParameterKey => 'document_type';
}

View File

@@ -0,0 +1,39 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/widgets.dart';
abstract class IdQueryParameter extends Equatable {
final bool _onlyNotAssigned;
final int? _id;
const IdQueryParameter.notAssigned()
: _onlyNotAssigned = true,
_id = null;
const IdQueryParameter.fromId(int? id)
: _onlyNotAssigned = false,
_id = id;
const IdQueryParameter.unset() : this.fromId(null);
bool get isUnset => _id == null && _onlyNotAssigned == false;
bool get isSet => _id != null && _onlyNotAssigned == false;
bool get onlyNotAssigned => _onlyNotAssigned;
int? get id => _id;
@protected
String get queryParameterKey;
String toQueryParameter() {
if (onlyNotAssigned) {
return "&${queryParameterKey}__isnull=1";
}
return isUnset ? "" : "&${queryParameterKey}__id=$id";
}
@override
List<Object?> get props => [_onlyNotAssigned, _id];
}

View File

@@ -0,0 +1,29 @@
import 'package:equatable/equatable.dart';
abstract class IdsQueryParameter with EquatableMixin {
final List<int> _ids;
final bool onlyNotAssigned;
const IdsQueryParameter.fromIds(List<int> ids)
: onlyNotAssigned = false,
_ids = ids;
const IdsQueryParameter.notAssigned()
: onlyNotAssigned = true,
_ids = const [];
const IdsQueryParameter.unset()
: onlyNotAssigned = false,
_ids = const [];
bool get isUnset => _ids.isEmpty && onlyNotAssigned == false;
bool get isSet => _ids.isNotEmpty && onlyNotAssigned == false;
List<int> get ids => _ids;
String toQueryParameter();
@override
List<Object?> get props => [onlyNotAssigned, _ids];
}

View File

@@ -0,0 +1,9 @@
enum QueryType {
title('title__icontains'),
titleAndContent('title_content'),
extended('query'),
asn('asn');
final String queryParam;
const QueryType(this.queryParam);
}

View File

@@ -0,0 +1,18 @@
enum SortField {
archiveSerialNumber("archive_serial_number"),
correspondentName("correspondent__name"),
title("title"),
documentType("documentType"),
created("created"),
added("added"),
modified("modified");
final String queryString;
const SortField(this.queryString);
@override
String toString() {
return name.toLowerCase();
}
}

View File

@@ -0,0 +1,11 @@
enum SortOrder {
ascending(""),
descending("-");
final String queryString;
const SortOrder(this.queryString);
SortOrder toggle() {
return this == ascending ? descending : ascending;
}
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/id_query_parameter.dart';
class StoragePathQuery extends IdQueryParameter {
const StoragePathQuery.fromId(super.id) : super.fromId();
const StoragePathQuery.unset() : super.unset();
const StoragePathQuery.notAssigned() : super.notAssigned();
@override
String get queryParameterKey => 'storage_path';
}

View File

@@ -0,0 +1,15 @@
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/ids_query_parameter.dart';
class TagsQuery extends IdsQueryParameter {
const TagsQuery.fromIds(super.ids) : super.fromIds();
const TagsQuery.unset() : super.unset();
const TagsQuery.notAssigned() : super.notAssigned();
@override
String toQueryParameter() {
if (onlyNotAssigned) {
return '&is_tagged=false';
}
return isUnset ? "" : '&tags__id__all=${ids.join(',')}';
}
}