Skip to content

Commit

Permalink
feat: add switch type for theme settings. (halo-dev#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby authored Mar 29, 2020
1 parent c353411 commit b3dafa1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ private List<Item> handleItems(@Nullable Object items) {
item.setName(itemMap.get("name").toString());
item.setLabel(itemMap.getOrDefault("label", item.getName()).toString());
Object dataType = itemMap.getOrDefault("data-type", itemMap.get("dataType"));
item.setDataType(DataType.typeOf(dataType));
item.setType(InputType.typeOf(itemMap.get("type")));
item.setDataType(item.getType().equals(InputType.SWITCH) ? DataType.BOOL : DataType.typeOf(dataType));
item.setDefaultValue(itemMap.get("default"));
item.setPlaceholder(itemMap.getOrDefault("placeholder", "").toString());
item.setDescription(itemMap.getOrDefault("description", "").toString());
Expand All @@ -140,8 +140,8 @@ private List<Item> handleItems(@Nullable Object items) {
item.setName(key.toString());
item.setLabel(itemMap.getOrDefault("label", item.getName()).toString());
Object dataType = itemMap.getOrDefault("data-type", itemMap.get("dataType"));
item.setDataType(DataType.typeOf(dataType));
item.setType(InputType.typeOf(itemMap.get("type")));
item.setDataType(item.getType().equals(InputType.SWITCH) ? DataType.BOOL : DataType.typeOf(dataType));
item.setDefaultValue(itemMap.get("default"));
item.setPlaceholder(itemMap.getOrDefault("placeholder", "").toString());
item.setDescription(itemMap.getOrDefault("description", "").toString());
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/run/halo/app/model/enums/InputType.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ public enum InputType {
/**
* Attachment picker input type
*/
ATTACHMENT;
ATTACHMENT,

/**
* Switch input type, only true or false
*/
SWITCH;

/**
* Convert type to input type.
Expand Down

0 comments on commit b3dafa1

Please sign in to comment.