fix: Add owner to labels

This commit is contained in:
Anton Stubenbord
2023-05-11 16:23:15 +02:00
parent f388f77d63
commit fd1c0ced35
11 changed files with 155 additions and 226 deletions

View File

@@ -11,14 +11,16 @@ class Correspondent extends Label {
final DateTime? lastCorrespondence;
const Correspondent({
super.id,
this.lastCorrespondence,
required super.name,
super.id,
super.slug,
super.match,
super.matchingAlgorithm,
super.isInsensitive,
super.documentCount,
this.lastCorrespondence,
super.owner,
super.userCanChange,
});
factory Correspondent.fromJson(Map<String, dynamic> json) =>

View File

@@ -13,10 +13,11 @@ class DocumentType extends Label {
super.matchingAlgorithm,
super.isInsensitive,
super.documentCount,
super.owner,
super.userCanChange,
});
factory DocumentType.fromJson(Map<String, dynamic> json) =>
_$DocumentTypeFromJson(json);
factory DocumentType.fromJson(Map<String, dynamic> json) => _$DocumentTypeFromJson(json);
@override
String get queryEndpoint => 'document_types';

View File

@@ -19,6 +19,8 @@ abstract class Label extends Equatable implements Comparable {
final MatchingAlgorithm matchingAlgorithm;
final bool? isInsensitive;
final int? documentCount;
final int? owner;
final bool? userCanChange;
const Label({
this.id,
@@ -28,6 +30,8 @@ abstract class Label extends Equatable implements Comparable {
this.isInsensitive = true,
this.documentCount,
this.slug,
this.owner,
this.userCanChange,
});
Label copyWith({

View File

@@ -17,10 +17,11 @@ class StoragePath extends Label {
super.matchingAlgorithm,
super.isInsensitive,
super.documentCount,
super.owner,
super.userCanChange,
});
factory StoragePath.fromJson(Map<String, dynamic> json) =>
_$StoragePathFromJson(json);
factory StoragePath.fromJson(Map<String, dynamic> json) => _$StoragePathFromJson(json);
@override
String toString() {

View File

@@ -11,71 +11,33 @@ part 'tag_model.g.dart';
@HexColorJsonConverter()
@JsonSerializable(
fieldRename: FieldRename.snake, explicitToJson: true, constructor: "_")
fieldRename: FieldRename.snake,
explicitToJson: true,
)
class Tag extends Label {
static const colorKey = 'color';
static const isInboxTagKey = 'is_inbox_tag';
static const textColorKey = 'text_color';
static const legacyColourKey = 'colour';
final Color? textColor;
final Color? color;
final bool isInboxTag;
@protected
@JsonKey(name: colorKey)
Color? colorv2;
@protected
@Deprecated(
"Alias for the field color. Deprecated since Paperless API v2. Please use the color getter to access the background color of this tag.",
)
@JsonKey(name: legacyColourKey)
Color? colorv1;
Color? get color => colorv2 ?? colorv1;
/// Constructor to use for serialization.
Tag._({
Tag({
super.id,
required super.name,
super.documentCount,
super.isInsensitive = true,
super.isInsensitive,
super.match,
super.matchingAlgorithm,
super.matchingAlgorithm = MatchingAlgorithm.defaultValue,
super.slug,
this.colorv1,
this.colorv2,
this.color,
this.textColor,
this.isInboxTag = false,
}) {
colorv1 ??= colorv2;
colorv2 ??= colorv1;
}
Tag({
int? id,
required String name,
int? documentCount,
bool? isInsensitive,
String? match,
MatchingAlgorithm matchingAlgorithm = MatchingAlgorithm.defaultValue,
String? slug,
Color? color,
Color? textColor,
bool? isInboxTag,
}) : this._(
id: id,
name: name,
documentCount: documentCount,
isInsensitive: isInsensitive,
match: match,
matchingAlgorithm: matchingAlgorithm,
slug: slug,
textColor: textColor,
colorv1: color,
colorv2: color,
);
super.owner,
super.userCanChange,
});
@override
String toString() => name;