From 0e09670791734088da7176ca7d47be5a94773b68 Mon Sep 17 00:00:00 2001 From: Simone Stasi Date: Thu, 14 Dec 2023 16:37:01 +0100 Subject: [PATCH] work_items: handle always required fields A field can be set to be always required, meaning that it must always be filled independently on the rules. --- lib/src/models/work_item_fields.dart | 4 +++- .../controller_create_or_edit_work_item.dart | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/models/work_item_fields.dart b/lib/src/models/work_item_fields.dart index d2336dc3..d90204a1 100644 --- a/lib/src/models/work_item_fields.dart +++ b/lib/src/models/work_item_fields.dart @@ -33,6 +33,7 @@ class WorkItemField { required this.referenceName, required this.name, this.required = false, + this.alwaysRequired = false, this.readOnly = false, this.defaultValue, this.allowedValues = const [], @@ -43,7 +44,7 @@ class WorkItemField { factory WorkItemField.fromJson(Map json) => WorkItemField( referenceName: json['referenceName'] as String, name: json['name'] as String, - required: json['alwaysRequired'] as bool? ?? false, + alwaysRequired: json['alwaysRequired'] as bool? ?? false, readOnly: json['readOnly'] as bool? ?? false, defaultValue: json['defaultValue'] as String?, allowedValues: (json['allowedValues'] as List?)?.map((v) => v.toString()).toList() ?? [], @@ -53,6 +54,7 @@ class WorkItemField { final String referenceName; final String name; + bool alwaysRequired; bool required; bool readOnly; final String? defaultValue; diff --git a/lib/src/screens/create_or_edit_work_item/controller_create_or_edit_work_item.dart b/lib/src/screens/create_or_edit_work_item/controller_create_or_edit_work_item.dart index 7393040d..a288b05e 100644 --- a/lib/src/screens/create_or_edit_work_item/controller_create_or_edit_work_item.dart +++ b/lib/src/screens/create_or_edit_work_item/controller_create_or_edit_work_item.dart @@ -504,7 +504,7 @@ class _CreateOrEditWorkItemController with FilterMixin, AppLogger { final rules = checker.checkRules(field); field ..readOnly = rules.readOnly || rules.makeEmpty - ..required = rules.required; + ..required = field.alwaysRequired || rules.required; final refName = field.referenceName;