Progress Logs: The model, thoughts and brainstorm, issues (incoherent) #12
Replies: 6 comments 1 reply
|
The current dependency look up: look for parent after reaching the element root parent it doesn't go down to look into siblings (not in the same path of the element), what i want to do regarding the look-up is implement something like Scope-based Dependency Lookup: Dependencies should follow a scoped lookup model, similar to variable scopes in programming languages, it starts by looking for the dependency in the local section, moves up to the parent, and finally checks global scope (siblings and root level). Currently, I construct the elements in a tree like abstracted from model, all form elements having a common element with different specialized concretes all can be consolidated into a single root, a unified processing, unified enhancement. structuring with all elements starting from a single root node and traversing the tree both upwards and downwards from any node.
|
|
quick Notes
Improvements/Next Steps, Potential Issues and Ideas:
void onDependencyChanged(String notifierName, dynamic value,
{bool notify = true}) {
///.. implementation
}
Dependencies/References:any other elements, libraries, or tools that this depends on or interacts with. |
|
Key Challenges:
Specific Issues:
strategies to optimize form element creation and rendering. |
|
New things I learned:
Ways to make form element creation and rendering better:
Dependencies/References:any other elements, libraries, or tools that this task depends on or interacts with. |
|
I need to centralize event registration, deregistration, and cleanup for my form elements while traversing the tree and managing dependencies. The challenge is ensuring that when an element depends on another by name, it registers and listens to the closest one within its scope—especially when there are multiple elements with the same name, taking Scoped Dependency lookup into account. I’m thinking about two approaches, but I’m not sure which is best:
I’m looking for fast-to-implement-and-expand-later ideas on how to best implement this while decoupling these mechanisms. Example: {
"form": "inventoryForm",
"fields": {
"name": "transactionInfo",
"type": "Section",
"fields": [
{
"name": "transaction",
"type": "SelectOne",
"listName": "transactionTypes"
},
{
"name": "supplier",
"type": "Text",
"rules": [
{
"expression": "#{transaction} == 'supply'",
"action": "Show"
}
]
}
]
}
}My current approach involves retrieving the dependencies at runtime using an extension on the FieldTemplate and the Rule: extension FieldTemplateDependencies on FieldTemplate {
List<String> get dependencies {
List<String> dependencySet = [];
for (final rule in rules) {
final ruleDependencies = rule.dependencies;
dependencySet.addAll(ruleDependencies);
}
return dependencySet.toSet().toList();
}
/// from the choiceFilter expression
List<String> get filterDependencies {
List<String> dependencyList = [];
final fieldPattern = RegExp(r'#\{(.*?)\}');
if (type.isSelectType) {
if (choiceFilter != null) {
final filterDependencies = fieldPattern
.allMatches(choiceFilter!)
.map((match) => match.group(1)!)
.toList();
dependencyList.addAll(filterDependencies);
}
return dependencyList.toSet().toList();
}
return [];
}
String? get evalChoiceFilterExpression =>
choiceFilter?.replaceAll("#{", "").replaceAll("}", "");
}
extension RuleDependencies on Rule {
List<String> get dependencies {
if (expression != null) {
final fieldPattern = RegExp(r'#\{(.*?)\}');
return fieldPattern
.allMatches(expression!)
.map((match) => match.group(1)!)
.toSet()
.toList();
}
return [];
}
String? get evalExpression =>
expression.replaceAll("#{", "").replaceAll("}", "");
}
|
Materialized Paths, for abstracting some of the complexities, if not all:🤔Due to the size of the project, sometimes I decide a goal and think of the details of achieving it, but while working towards that goal I get lost in the details and for a moment I forget the goal’s details I need to implement and end up working in a path that finishes far away from the goal Modeling the tree structure of elements differently might simplify things: **We can Model Tree Structures with** maintaining everything as tree with Child References as in the current model seems ideal, it naturally algins with the nested UI structures, makes each form element understands its hierarchy and dependencies clearly, and rule evaluation where parent-child relationships are involved is easier to implement. However, as I delved deeper into the code I realized that managing deeply nested trees can get complex, especially with rule evaluations that don’t involve child-parent relationship. I need balance…
Storing fully re-constructable relationships using Model Tree Structures with Materialized Paths, seems to suite my case the most, but I don’t know the complexities that may arise down the road, the goal is partly clear in my mind and I partly thought about the details I need to implement to reach it. Using materialized paths the previous example would become like: {
"form": "inventoryForm",
"name": "inventoryForm",
"fields": [
{
"name": "transactionInfo",
**"type": "Section",
"path": "transactionInfo",**
},
{
"name": "transaction",
"listName": "transactionTypes",
**"type": "SelectOne",
"path": "transactionInfo.transaction",**
},
{
"name": "supplier",
"rules": [
{
"expression": "#{transaction} == 'supply'",
"action": "Show"
}
],
**"type": "Text",**
**"path": "transactionInfo.supplier"**
}
]
}With a few tree-walking methods, this could abstract away many of the complexities i faced.. instead of tracking nested elements and parents as in the current model, it would flatten the tree's depth into fields and with the help of more about it later.... Dependencies/References: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Dependencies/References:
any other elements, libraries, or tools that this depends on or interacts with.
All reactions