Style Dashboard by rules
This commit is contained in:
@@ -61,6 +61,7 @@ class Dashboard extends ChangeNotifier {
|
||||
double widthOffset = 0;
|
||||
double heightOffset = 0;
|
||||
List<bool Function(Dashboard)> saveRules = [];
|
||||
List<List<ArrowPainter> Function(Dashboard)> arrowStyleRules = [];
|
||||
|
||||
String? error;
|
||||
|
||||
@@ -152,7 +153,9 @@ class Dashboard extends ChangeNotifier {
|
||||
map['dashboardSizeWidth'] as double? ?? 0,
|
||||
map['dashboardSizeHeight'] as double? ?? 0,
|
||||
);
|
||||
|
||||
for (var f in d.arrowStyleRules) {
|
||||
d.arrows = f(d);
|
||||
}
|
||||
if (map['gridBackgroundParams'] != null) {
|
||||
d.gridBackgroundParams = GridBackgroundParams.fromMap(
|
||||
map['gridBackgroundParams'] as Map<String, dynamic>,
|
||||
@@ -179,6 +182,9 @@ class Dashboard extends ChangeNotifier {
|
||||
(x) => ArrowPainter.fromMap(x as Map<String, dynamic>),
|
||||
),
|
||||
);
|
||||
for (var f in arrowStyleRules) {
|
||||
arrows = f(this);
|
||||
}
|
||||
elements = List<FlowElement>.from(
|
||||
(map['elements'] as List<dynamic>).map<FlowElement>(
|
||||
(x) => FlowElement.fromMap(this, x as Map<String, dynamic>),
|
||||
@@ -244,6 +250,9 @@ class Dashboard extends ChangeNotifier {
|
||||
for(var el in elements) {
|
||||
graph['elements'][el.id] = el.serialize();
|
||||
}
|
||||
for (var f in arrowStyleRules) {
|
||||
arrows = f(this);
|
||||
}
|
||||
graph['arrows'] = arrows.map((e) => e.serialize()).toList();
|
||||
d["id"]=id;
|
||||
d["name"]=name;
|
||||
@@ -322,12 +331,18 @@ class Dashboard extends ChangeNotifier {
|
||||
|
||||
void addArrows(ArrowPainter f) {
|
||||
arrows.add(f);
|
||||
for (var f in arrowStyleRules) {
|
||||
arrows = f(this);
|
||||
}
|
||||
addChange = true;
|
||||
saveDash(id);
|
||||
}
|
||||
|
||||
void removeArrows(bool Function(ArrowPainter) f) {
|
||||
arrows.removeWhere((element) => f(element));
|
||||
for (var f in arrowStyleRules) {
|
||||
arrows = f(this);
|
||||
}
|
||||
saveDash(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ class DrawArrowState extends State<DrawArrow> {
|
||||
if ( widget.flow.widget.dashboard.arrows.where(
|
||||
(element) => element.fromID == "${widget.srcElement.id}_${widget.index}").isEmpty) {
|
||||
widget.flow.widget.dashboard.addArrows(painter);
|
||||
widget.flow.widget.dashboard.save!(widget.flow.widget.dashboard.id);
|
||||
widget.flow.widget.dashboard.saveDash(widget.flow.widget.dashboard.id);
|
||||
} else {
|
||||
var i = widget.flow.widget.dashboard.arrows.indexWhere(
|
||||
(element) => element.fromID == "${widget.srcElement.id}_${widget.index}");
|
||||
|
||||
Reference in New Issue
Block a user