Skip to content

Commit 8e05416

Browse files
committed
Use PrivacyBase for variables and conditions.
1 parent 10a03ae commit 8e05416

File tree

2 files changed

+4
-97
lines changed

2 files changed

+4
-97
lines changed

lib/src/api/models/condition.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class CanvasConditions with EquatableMixin {
602602
@JsonKey(name: 'project')
603603
final String projectId;
604604

605-
/// Creates a new [CanvasVariables].
605+
/// Creates a new [CanvasConditions].
606606
CanvasConditions({
607607
required this.id,
608608
required this.conditions,
@@ -611,7 +611,7 @@ class CanvasConditions with EquatableMixin {
611611
required this.owner,
612612
}) : lastUpdated = lastUpdated ?? DateTime.now();
613613

614-
/// Duplicate a [CanvasVariables] with the given parameters.
614+
/// Duplicate a [CanvasConditions] with the given parameters.
615615
CanvasConditions copyWith({
616616
String? id,
617617
Map<String, BaseCondition>? conditions,
@@ -629,11 +629,11 @@ class CanvasConditions with EquatableMixin {
629629
@override
630630
List<Object?> get props => [id, conditions];
631631

632-
/// Creates a new [CanvasVariables] from a JSON map.
632+
/// Creates a new [CanvasConditions] from a JSON map.
633633
factory CanvasConditions.fromJson(Map<String, dynamic> json) =>
634634
_$CanvasConditionsFromJson(json);
635635

636-
/// Converts this [CanvasVariables] into a JSON map.
636+
/// Converts this [CanvasConditions] into a JSON map.
637637
Map<String, dynamic> toJson() => _$CanvasConditionsToJson(this)..remove('id');
638638

639639
/// Allows to access canvas variables by variable id.

lib/src/api/models/variables_model.dart

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -207,82 +207,6 @@ String? sanitizeValueForVariableType(Object? value, VariableType type) {
207207
}
208208
}
209209

210-
/// Contains all the variables associated with a canvas inside a page.
211-
@JsonSerializable()
212-
class CanvasVariables with EquatableMixin {
213-
/// Unique ID of the canvas.
214-
final String id;
215-
216-
/// Variables associated with this canvas.
217-
final Map<String, CanvasVariableData> variables;
218-
219-
/// Last updated time of this canvas.
220-
@DateTimeConverter()
221-
final DateTime lastUpdated;
222-
223-
/// ID of the project this canvas belongs to.
224-
final String owner;
225-
226-
/// ID of the project this canvas belongs to.
227-
@JsonKey(name: 'project')
228-
final String projectId;
229-
230-
/// Creates a new [CanvasVariables].
231-
CanvasVariables({
232-
required this.id,
233-
required this.variables,
234-
DateTime? lastUpdated,
235-
required this.projectId,
236-
required this.owner,
237-
}) : lastUpdated = lastUpdated ?? DateTime.now();
238-
239-
/// Duplicate a [CanvasVariables] with the given parameters.
240-
CanvasVariables copyWith({
241-
String? id,
242-
Map<String, CanvasVariableData>? variables,
243-
String? projectId,
244-
String? owner,
245-
}) =>
246-
CanvasVariables(
247-
id: id ?? this.id,
248-
variables: variables ?? this.variables,
249-
lastUpdated: DateTime.now(),
250-
projectId: projectId ?? this.projectId,
251-
owner: owner ?? this.owner,
252-
);
253-
254-
@override
255-
List<Object?> get props => [id, variables];
256-
257-
/// Creates a new [CanvasVariables] from a JSON map.
258-
factory CanvasVariables.fromJson(Map<String, dynamic> json) {
259-
final Map<String, dynamic> updated = {
260-
...json,
261-
'variables': <String, dynamic>{
262-
for (final entry in json['variables'].values)
263-
entry['id']: {
264-
'canvasId': json['id'],
265-
...entry,
266-
},
267-
},
268-
};
269-
return _$CanvasVariablesFromJson(updated);
270-
}
271-
272-
/// Converts this [CanvasVariables] into a JSON map.
273-
Map<String, dynamic> toJson() => _$CanvasVariablesToJson(this)..remove('id');
274-
275-
/// Allows to access canvas variables by variable id.
276-
VariableData? operator [](String variableId) {
277-
return variables[variableId];
278-
}
279-
280-
/// Allows to assign canvas variables by variable id.
281-
void operator []=(String variableId, CanvasVariableData value) {
282-
variables[variableId] = value;
283-
}
284-
}
285-
286210
/// A variable that is scoped to a canvas.
287211
@JsonSerializable()
288212
class CanvasVariableData extends VariableData {
@@ -332,23 +256,6 @@ class CanvasVariableData extends VariableData {
332256
_$CanvasVariableDataToJson(this)..remove('canvasId');
333257
}
334258

335-
/// Serializer for [CanvasVariables].
336-
Map<String, dynamic> canvasVariablesToJson(List<CanvasVariables> variables) {
337-
return {
338-
for (final variable in variables)
339-
variable.id:
340-
variable.variables.map((key, value) => MapEntry(key, value.toJson()))
341-
};
342-
}
343-
344-
/// Deserializer for [CanvasVariables].
345-
List<CanvasVariables> canvasVariablesFromJson(Map<String, dynamic> json) {
346-
return [
347-
for (final entry in json.entries)
348-
CanvasVariables.fromJson({'id': entry.key, 'variables': entry.value}),
349-
];
350-
}
351-
352259
/// A variable class that represents creation of a variable from given name.
353260
class PredefinedVariableData extends VariableData {
354261
/// Creates a new [PredefinedVariableData].

0 commit comments

Comments
 (0)