This commit is contained in:
2025-04-08 16:31:35 +02:00
parent eb2df1550e
commit 4ca0272d1e

View File

@@ -196,10 +196,22 @@ class AstromicFormController extends FormController {
}
int getInstanceCount(String targetGroupID) {
String? p = getFullPathOfGroup(targetGroupID);
if (p != null && p.split('->').length > 1 && p.split('->').indexOf(targetGroupID) != 0) {
// This is a subgroup
}
FormGroupStructure? structure = getGroupStructure(targetGroupID);
if (structure != null) {
String firstField = structure.fields.first;
return controllers.keys.where((String c) => RegExp(standeredGroupFormat(targetGroupID, r'[\d+]', firstField)).hasMatch(c)).nonNulls.toList().length;
// return controllers.keys.where((String c) => RegExp(standeredGroupFormat(targetGroupID, r'[\d+]', firstField)).hasMatch(c)).nonNulls.toList().length;
return controllers.keys
.where((String c) {
// Match the specific group ID and field name within the group
final RegExp pattern = RegExp(r'^' + RegExp.escape(standeredGroupFormat(targetGroupID, r'[\d+]', firstField)) + r'(-#\d+)?$');
return pattern.hasMatch(c);
})
.nonNulls
.toList().length;
}
return 0;
}