Skip to content

Commit 6eb4398

Browse files
committed
Miscellaneous updates
- Implement filters and sort for load from cloud database action. - Make document ID optional for load from cloud database action. - Improve UI of list view settings panel. - Dismiss filters dialog on save. - Implement collection streaming for cloud database. - Add limit option in list view settings panel. - Add limit option for load from cloud database action.
1 parent fd86450 commit 6eb4398

File tree

4 files changed

+63
-8
lines changed

4 files changed

+63
-8
lines changed

lib/src/api/mixins.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ mixin ConditionsMixin {
11261126

11271127
/// A mixin that adds the ability to filter a collection of data
11281128
/// on a node.
1129-
mixin QueryableMixin on BaseNode {
1129+
mixin QueryableMixin {
11301130
/// List of where() operations to be applied to the query.
11311131
List<WhereQueryFilter> whereFilters = [];
11321132

@@ -1148,13 +1148,13 @@ mixin QueryableMixin on BaseNode {
11481148

11491149
/// Sets the properties of this mixin.
11501150
void setQueryableMixin({
1151-
required List<WhereQueryFilter> whereOperations,
1151+
required List<WhereQueryFilter> whereFilters,
11521152
required List<OrderByQueryFilter> orderByOperations,
11531153
required bool useCloudDatabase,
11541154
required String? collectionPath,
11551155
required int limit,
11561156
}) {
1157-
this.whereFilters = whereOperations;
1157+
this.whereFilters = whereFilters;
11581158
this.orderByOperations = orderByOperations;
11591159
this.useCloudDatabase = useCloudDatabase;
11601160
this.collectionPath = collectionPath;

lib/src/api/models/action/load_from_cloud_storage_action.dart

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ part 'load_from_cloud_storage_action.g.dart';
1414
/// load data from Firestore on canvas load.
1515
@JsonSerializable()
1616
class LoadFromCloudStorageAction extends ActionModel
17-
with EquatableMixin, SerializableMixin {
17+
with EquatableMixin, SerializableMixin, QueryableMixin {
1818
/// Path to the collection to load data from.
1919
///
2020
/// A string that represents the path to the document excluding the document
@@ -33,29 +33,62 @@ class LoadFromCloudStorageAction extends ActionModel
3333
/// whenever the data on cloud storage changes.
3434
final VariableData? variable;
3535

36+
/// Whether to load a single document or all documents in the collection.
37+
final bool loadSingleDocument;
38+
3639
/// Creates a new [LoadFromCloudStorageAction].
3740
LoadFromCloudStorageAction({
3841
this.path = '',
3942
this.documentId = '',
4043
this.variable,
44+
this.loadSingleDocument = true,
4145
super.nonBlocking,
4246
super.enabled,
43-
}) : super(type: ActionType.loadFromCloudStorage);
47+
List<WhereQueryFilter>? whereFilters,
48+
List<OrderByQueryFilter>? orderByOperations,
49+
int? limit,
50+
}) : super(type: ActionType.loadFromCloudStorage) {
51+
setQueryableMixin(
52+
collectionPath: path,
53+
limit: limit ?? -1,
54+
whereFilters: whereFilters ?? [],
55+
orderByOperations: orderByOperations ?? [],
56+
useCloudDatabase: false,
57+
);
58+
}
4459

4560
/// Duplicates this [LoadFromCloudStorageAction] with given data overrides.
4661
LoadFromCloudStorageAction copyWith({
4762
String? path,
4863
String? documentId,
4964
VariableData? variable,
65+
bool? loadSingleDocument,
66+
List<WhereQueryFilter>? whereFilters,
67+
List<OrderByQueryFilter>? orderByOperations,
68+
int? limit,
5069
}) =>
5170
LoadFromCloudStorageAction(
5271
path: path ?? this.path,
5372
documentId: documentId ?? this.documentId,
5473
variable: variable ?? this.variable,
74+
loadSingleDocument: loadSingleDocument ?? this.loadSingleDocument,
75+
whereFilters: whereFilters ?? this.whereFilters,
76+
orderByOperations: orderByOperations ?? this.orderByOperations,
77+
limit: limit ?? this.limit,
5578
);
5679

5780
@override
58-
List<Object?> get props => [path, documentId, variable];
81+
List<Object?> get props => [
82+
path,
83+
documentId,
84+
variable,
85+
loadSingleDocument,
86+
whereFilters,
87+
orderByOperations,
88+
limit,
89+
useCloudDatabase,
90+
collectionPath,
91+
];
5992

6093
/// Creates a new [LoadFromCloudStorageAction] instance from a JSON data.
6194
factory LoadFromCloudStorageAction.fromJson(Map json) =>

lib/src/api/models/action/load_from_cloud_storage_action.g.dart

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/list_view_node.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class ListViewNode extends SinglePlaceholderNode
100100
useCloudDatabase: useCloudDatabase,
101101
collectionPath: collectionPath,
102102
limit: limit,
103-
whereOperations: whereOperations ?? [],
103+
whereFilters: whereOperations ?? [],
104104
orderByOperations: orderByOperations ?? [],
105105
);
106106
}

0 commit comments

Comments
 (0)