45 lines
1.0 KiB
Dart
45 lines
1.0 KiB
Dart
class ReportQuery {
|
|
const ReportQuery({
|
|
this.search = '',
|
|
this.topic,
|
|
this.institutionId,
|
|
this.hasAudio = false,
|
|
this.sort = ReportSort.latest,
|
|
});
|
|
|
|
final String search;
|
|
final String? topic;
|
|
final String? institutionId;
|
|
final bool hasAudio;
|
|
final ReportSort sort;
|
|
|
|
bool get hasActiveFilter =>
|
|
search.trim().isNotEmpty ||
|
|
topic != null ||
|
|
institutionId != null ||
|
|
hasAudio ||
|
|
sort != ReportSort.latest;
|
|
|
|
ReportQuery copyWith({
|
|
String? search,
|
|
Object? topic = _sentinel,
|
|
Object? institutionId = _sentinel,
|
|
bool? hasAudio,
|
|
ReportSort? sort,
|
|
}) {
|
|
return ReportQuery(
|
|
search: search ?? this.search,
|
|
topic: identical(topic, _sentinel) ? this.topic : topic as String?,
|
|
institutionId: identical(institutionId, _sentinel)
|
|
? this.institutionId
|
|
: institutionId as String?,
|
|
hasAudio: hasAudio ?? this.hasAudio,
|
|
sort: sort ?? this.sort,
|
|
);
|
|
}
|
|
}
|
|
|
|
enum ReportSort { latest, oldest }
|
|
|
|
const Object _sentinel = Object();
|