mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 16:07:52 -06:00
Fixes asn not being assigned
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_paperless_mobile/core/type/json.dart';
|
||||
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/id_query_parameter.dart';
|
||||
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/ids_query_parameter.dart';
|
||||
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/tags_query.dart';
|
||||
|
||||
class DocumentModel extends Equatable {
|
||||
static const idKey = 'id';
|
||||
@@ -86,7 +86,7 @@ class DocumentModel extends Equatable {
|
||||
DocumentModel copyWith({
|
||||
String? title,
|
||||
String? content,
|
||||
IdsQueryParameter? tags,
|
||||
TagsQuery? tags,
|
||||
IdQueryParameter? documentType,
|
||||
IdQueryParameter? correspondent,
|
||||
IdQueryParameter? storagePath,
|
||||
@@ -121,7 +121,7 @@ class DocumentModel extends Equatable {
|
||||
return query.id;
|
||||
}
|
||||
|
||||
List<int> fromListQuery(IdsQueryParameter? query, List<int> previous) {
|
||||
List<int> fromListQuery(TagsQuery? query, List<int> previous) {
|
||||
if (query == null) {
|
||||
return previous;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ class AsnQuery extends IdQueryParameter {
|
||||
const AsnQuery.fromId(super.id) : super.fromId();
|
||||
const AsnQuery.unset() : super.unset();
|
||||
const AsnQuery.notAssigned() : super.notAssigned();
|
||||
const AsnQuery.anyAssigned() : super.anyAssigned();
|
||||
|
||||
@override
|
||||
String get queryParameterKey => 'archive_serial_number';
|
||||
|
||||
@@ -4,6 +4,7 @@ class CorrespondentQuery extends IdQueryParameter {
|
||||
const CorrespondentQuery.fromId(super.id) : super.fromId();
|
||||
const CorrespondentQuery.unset() : super.unset();
|
||||
const CorrespondentQuery.notAssigned() : super.notAssigned();
|
||||
const CorrespondentQuery.anyAssigned() : super.anyAssigned();
|
||||
|
||||
@override
|
||||
String get queryParameterKey => 'correspondent';
|
||||
|
||||
@@ -4,6 +4,7 @@ class DocumentTypeQuery extends IdQueryParameter {
|
||||
const DocumentTypeQuery.fromId(super.id) : super.fromId();
|
||||
const DocumentTypeQuery.unset() : super.unset();
|
||||
const DocumentTypeQuery.notAssigned() : super.notAssigned();
|
||||
const DocumentTypeQuery.anyAssigned() : super.anyAssigned();
|
||||
|
||||
@override
|
||||
String get queryParameterKey => 'document_type';
|
||||
|
||||
@@ -2,24 +2,30 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
abstract class IdQueryParameter extends Equatable {
|
||||
final bool _onlyNotAssigned;
|
||||
final int? _assignmentStatus;
|
||||
final int? _id;
|
||||
|
||||
const IdQueryParameter.notAssigned()
|
||||
: _onlyNotAssigned = true,
|
||||
: _assignmentStatus = 1,
|
||||
_id = null;
|
||||
|
||||
const IdQueryParameter.anyAssigned()
|
||||
: _assignmentStatus = 0,
|
||||
_id = null;
|
||||
|
||||
const IdQueryParameter.fromId(int? id)
|
||||
: _onlyNotAssigned = false,
|
||||
: _assignmentStatus = null,
|
||||
_id = id;
|
||||
|
||||
const IdQueryParameter.unset() : this.fromId(null);
|
||||
|
||||
bool get isUnset => _id == null && _onlyNotAssigned == false;
|
||||
bool get isUnset => _id == null && _assignmentStatus == null;
|
||||
|
||||
bool get isSet => _id != null && _onlyNotAssigned == false;
|
||||
bool get isSet => _id != null && _assignmentStatus == null;
|
||||
|
||||
bool get onlyNotAssigned => _onlyNotAssigned;
|
||||
bool get onlyNotAssigned => _assignmentStatus == 1;
|
||||
|
||||
bool get onlyAssigned => _assignmentStatus == 0;
|
||||
|
||||
int? get id => _id;
|
||||
|
||||
@@ -27,13 +33,15 @@ abstract class IdQueryParameter extends Equatable {
|
||||
String get queryParameterKey;
|
||||
|
||||
String toQueryParameter() {
|
||||
if (onlyNotAssigned) {
|
||||
return "&${queryParameterKey}__isnull=1";
|
||||
if (onlyNotAssigned || onlyAssigned) {
|
||||
return "&${queryParameterKey}__isnull=$_assignmentStatus";
|
||||
}
|
||||
|
||||
return isUnset ? "" : "&${queryParameterKey}__id=$id";
|
||||
if (isSet) {
|
||||
return "${queryParameterKey}__id=$id";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [_onlyNotAssigned, _id];
|
||||
List<Object?> get props => [_assignmentStatus, _id];
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
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];
|
||||
}
|
||||
@@ -4,6 +4,7 @@ class StoragePathQuery extends IdQueryParameter {
|
||||
const StoragePathQuery.fromId(super.id) : super.fromId();
|
||||
const StoragePathQuery.unset() : super.unset();
|
||||
const StoragePathQuery.notAssigned() : super.notAssigned();
|
||||
const StoragePathQuery.anyAssigned() : super.anyAssigned();
|
||||
|
||||
@override
|
||||
String get queryParameterKey => 'storage_path';
|
||||
|
||||
@@ -1,15 +1,38 @@
|
||||
import 'package:flutter_paperless_mobile/features/documents/model/query_parameters/ids_query_parameter.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class TagsQuery extends IdsQueryParameter {
|
||||
const TagsQuery.fromIds(super.ids) : super.fromIds();
|
||||
const TagsQuery.unset() : super.unset();
|
||||
const TagsQuery.notAssigned() : super.notAssigned();
|
||||
class TagsQuery with EquatableMixin {
|
||||
final List<int> _ids;
|
||||
final bool? _isTagged;
|
||||
|
||||
const TagsQuery.fromIds(List<int> ids)
|
||||
: _isTagged = null,
|
||||
_ids = ids;
|
||||
|
||||
const TagsQuery.anyAssigned()
|
||||
: _isTagged = true,
|
||||
_ids = const [];
|
||||
|
||||
const TagsQuery.notAssigned()
|
||||
: _isTagged = false,
|
||||
_ids = const [];
|
||||
|
||||
const TagsQuery.unset() : this.fromIds(const []);
|
||||
|
||||
bool get onlyNotAssigned => _isTagged == false;
|
||||
bool get onlyAssigned => _isTagged == true;
|
||||
|
||||
bool get isUnset => _ids.isEmpty && _isTagged == null;
|
||||
bool get isSet => _ids.isNotEmpty && _isTagged == null;
|
||||
|
||||
List<int> get ids => _ids;
|
||||
|
||||
@override
|
||||
String toQueryParameter() {
|
||||
if (onlyNotAssigned) {
|
||||
return '&is_tagged=false';
|
||||
if (onlyNotAssigned || onlyAssigned) {
|
||||
return '&is_tagged=$_isTagged';
|
||||
}
|
||||
return isUnset ? "" : '&tags__id__all=${ids.join(',')}';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [_isTagged, _ids];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user