Skip to content

Commit

Permalink
Merge pull request #53 from wwt/Issue52
Browse files Browse the repository at this point in the history
Fixed Issue #52: add `showOtherItem` and `showNoneItem` support to `Dropdown`
  • Loading branch information
goxiaoy committed Apr 23, 2023
2 parents 6fc2315 + 2024103 commit 58ceacf
Show file tree
Hide file tree
Showing 14 changed files with 485 additions and 42 deletions.
4 changes: 3 additions & 1 deletion example/assets/complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"name": "dropdown_question",
"choices": [
"item1"
]
],
"showOtherItem": true,
"showNoneItem": true
},
{
"type": "comment",
Expand Down
6 changes: 5 additions & 1 deletion example/assets/single_page.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"name": "dropdown_question",
"choices": [
"item1"
]
],
"showOtherItem": true,
"showNoneItem": true,
"otherText": "Other (Feedback)",
"noneText": "Nothing"
},
{
"type": "comment",
Expand Down
3 changes: 3 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class MessageLookup extends MessageLookupByLibrary {
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"add": MessageLookupByLibrary.simpleMessage("Add"),
"nextPage": MessageLookupByLibrary.simpleMessage("Next Page"),
"noneItemText": MessageLookupByLibrary.simpleMessage("None"),
"otherItemText":
MessageLookupByLibrary.simpleMessage("Other (describe)"),
"placeholder": MessageLookupByLibrary.simpleMessage("Select..."),
"previousPage": MessageLookupByLibrary.simpleMessage("PreviousPage"),
"remove": MessageLookupByLibrary.simpleMessage("Remove"),
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class MessageLookup extends MessageLookupByLibrary {
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"add": MessageLookupByLibrary.simpleMessage("添加"),
"nextPage": MessageLookupByLibrary.simpleMessage("下一页"),
"noneItemText": MessageLookupByLibrary.simpleMessage("无"),
"otherItemText": MessageLookupByLibrary.simpleMessage("填写其他答案"),
"placeholder": MessageLookupByLibrary.simpleMessage("请选择..."),
"previousPage": MessageLookupByLibrary.simpleMessage("上一页"),
"remove": MessageLookupByLibrary.simpleMessage("删除"),
Expand Down
20 changes: 20 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"submitSurvey": "Submit",
"add": "Add",
"remove": "Remove",
"placeholder": "Select..."
"placeholder": "Select...",
"otherItemText": "Other (describe)",
"noneItemText": "None"
}
4 changes: 3 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"submitSurvey": "提交",
"add": "添加",
"remove": "删除",
"placeholder": "请选择..."
"placeholder": "请选择...",
"otherItemText": "填写其他答案",
"noneItemText": "无"
}
2 changes: 0 additions & 2 deletions lib/model/matrix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ abstract class MatrixDropdownBase extends MatrixBase {
String? detailPanelMode;
bool? horizontalScroll;
String? optionsCaption;

@JsonKey(fromJson: ItemValue.fromListJson)
List<ItemValue>? choices;

String? keyDuplicationError;
//"dropdown","checkbox","radiogroup","text","comment","boolean","expression", "rating"
String? cellType;
Expand Down
2 changes: 1 addition & 1 deletion lib/model/select_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class SelectBase<T extends ItemValue> extends Question {
String? choicesEnableIf;
bool? hasOther;
bool? hasNone;
String? otherPlaceHolder;
String? otherPlaceholder;
String? noneText;
String? otherText;
String? otherErrorText;
Expand Down
5 changes: 5 additions & 0 deletions lib/model/survey.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,12 @@ class Dropdown extends SelectBase {
num? choicesMax;
num? choicesStep;
String? autoComplete;

String? placeholder;

bool? showOtherItem;
bool? showNoneItem;

Dropdown();
factory Dropdown.fromJson(Map<String, dynamic> json) =>
_$DropdownFromJson(json);
Expand Down
30 changes: 17 additions & 13 deletions lib/model/survey.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 58ceacf

Please sign in to comment.