Skip to content

Commit

Permalink
work_items: handle always required fields
Browse files Browse the repository at this point in the history
A field can be set to be always required,
meaning that it must always be filled independently
on the rules.
  • Loading branch information
sstasi95 committed Dec 14, 2023
1 parent ef9e2f0 commit 0e09670
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/src/models/work_item_fields.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 [],
Expand All @@ -43,7 +44,7 @@ class WorkItemField {
factory WorkItemField.fromJson(Map<String, dynamic> 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<dynamic>?)?.map((v) => v.toString()).toList() ?? [],
Expand All @@ -53,6 +54,7 @@ class WorkItemField {

final String referenceName;
final String name;
bool alwaysRequired;
bool required;
bool readOnly;
final String? defaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0e09670

Please sign in to comment.