Skip to content

Commit

Permalink
Suport 'DATE_PICKER' custom type (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaSedyx authored and alekGbuz committed Apr 5, 2024
1 parent bd61557 commit 8e3a4f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

public enum CustomFieldTypes {

DATE_PICKER("DATE_PICKER"),
RADIO_BUTTON("RADIO_BUTTON"),
SINGLE_CHECKBOX("SINGLE_CHECKBOX"),
SINGLE_SELECT_DROPDOWN("SINGLE_SELECT_DROPDOWN"),
Expand Down Expand Up @@ -38,4 +39,3 @@ public static CustomFieldTypes fromValue(String value) {
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private Pair<String, Object> restoreCustomFieldFromString(String s) {
var customField = UserReferenceHelper.service().getCustomFieldByName(name);
if (ObjectUtils.isNotEmpty(customField) && ObjectUtils.isNotEmpty(customField.getType())) {
return switch (customField.getType()) {
case DATE_PICKER -> Pair.of(customField.getRefId(), value);
case SINGLE_CHECKBOX -> Pair.of(customField.getRefId(), Boolean.parseBoolean(value));
case TEXTBOX_LONG, TEXTBOX_SHORT ->
Pair.of(customField.getRefId(), value.replace(LINE_BREAK_REPLACEMENT, LINE_BREAK));
Expand Down Expand Up @@ -104,7 +105,7 @@ private String convertCustomFieldsToString(Map<String, Object> map) {
private String customFieldToString(Map.Entry<String, Object> entry) {
var customField = UserReferenceHelper.service().getCustomFieldByRefId(entry.getKey());
return switch (customField.getType()) {
case TEXTBOX_LONG, TEXTBOX_SHORT, SINGLE_CHECKBOX ->
case DATE_PICKER, TEXTBOX_LONG, TEXTBOX_SHORT, SINGLE_CHECKBOX ->
customField.getName() + KEY_VALUE_DELIMITER + (isNull(entry.getValue()) ? EMPTY : entry.getValue().toString());
case SINGLE_SELECT_DROPDOWN, RADIO_BUTTON ->
customField.getName() + KEY_VALUE_DELIMITER + (isNull(entry.getValue()) ? EMPTY : extractValueById(customField, entry.getValue().toString()));
Expand Down

0 comments on commit 8e3a4f5

Please sign in to comment.