Skip to content

Commit

Permalink
Fix complex blueprint serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Nov 10, 2024
1 parent bdde68d commit fc19155
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 41 deletions.
23 changes: 23 additions & 0 deletions app/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
targets:
$default:
builders:
json_serializable:
options:
# Options configure how source code is generated for every
# `@JsonSerializable`-annotated class in the package.
#
# The default value for each is listed.
any_map: false
checked: false
constructor: ""
create_factory: true
create_field_map: false
create_json_keys: false
create_per_field_to_json: false
create_to_json: true
disallow_unrecognized_keys: false
explicit_to_json: true
field_rename: none
generic_argument_factories: false
ignore_unannotated: false
include_if_null: true
3 changes: 2 additions & 1 deletion app/lib/models/entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Entry {
: "Blueprint is not generic but a generic blueprint was provided",
),
assert(
!blueprint.isGeneric || blueprint.allowsGeneric(genericBlueprint),
blueprint.allowsGeneric(genericBlueprint),
"Generic blueprint given is not allowed for this blueprint, blueprint: ${blueprint.id}, allowed: ${blueprint.genericConstraints}, genericBlueprint: $genericBlueprint",
),
data = {
Expand Down Expand Up @@ -120,6 +120,7 @@ class Entry {
DataBlueprint? get genericBlueprint {
if (_genericBlueprint != null) return _genericBlueprint;
final genericBlueprint = data["_genericBlueprint"];
print("Generic blueprint: $genericBlueprint");
if (genericBlueprint == null) return null;

if (genericBlueprint is! Map<String, dynamic>) {
Expand Down
4 changes: 2 additions & 2 deletions app/lib/models/entry_blueprint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ extension EntryBlueprintExt on EntryBlueprint {
bool get isGeneric => genericConstraints != null;

bool allowsGeneric(DataBlueprint? genericBlueprint) {
if (genericBlueprint == null) return false;
final blueprints = genericConstraints;
if (blueprints == null) return false;
if (blueprints == null) return true;
if (genericBlueprint == null) return false;
// If the blueprints is empty, all blueprints are allowed.
if (blueprints.isEmpty) return true;
return blueprints.contains(genericBlueprint);
Expand Down
35 changes: 18 additions & 17 deletions app/lib/models/entry_blueprint.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/lib/models/extension.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/lib/models/page.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions app/lib/widgets/components/app/entry_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/lib/widgets/components/app/entry_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class GenericEntryFilter extends SearchFilter {
@override
bool filter(SearchElement action) {
if (action is EntrySearchElement) {
if (action.entry.genericBlueprint == null) return true;
return action.entry.genericBlueprint == blueprint;
}
if (action is AddEntrySearchElement) {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/widgets/components/app/entry_search.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/lib/widgets/components/app/static_entries_list.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/lib/widgets/inspector/editors.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/lib/widgets/inspector/editors/generic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class GenericEditor extends HookConsumerWidget {
blueprint = generic.dataBlueprint;
}

print("Generic blueprint: $blueprint");

return FieldEditor(path: path, dataBlueprint: blueprint);
}

Expand Down
5 changes: 3 additions & 2 deletions app/lib/widgets/inspector/editors/variable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class VariableEditor extends HookConsumerWidget {
],
),
),
const SizedBox(height: 8),
if (variableDataBlueprint != null)
if (variableDataBlueprint != null) ...[
const SizedBox(height: 8),
Header(
expanded: ValueNotifier(true),
canExpand: false,
Expand All @@ -130,6 +130,7 @@ class VariableEditor extends HookConsumerWidget {
dataBlueprint: variableDataBlueprint,
),
),
],
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/widgets/inspector/header.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/lib/widgets/inspector/headers/variable_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class VariableHeaderAction extends HookConsumerWidget {
)
..fetchEntry(onSelect: (entry) => _update(ref, entry))
..genericEntry(customBlueprint.shape)
..tag("variable", canRemove: false)
..open();
}

Expand Down
10 changes: 5 additions & 5 deletions app/lib/widgets/inspector/heading.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fc19155

Please sign in to comment.