fix(calendar): persist settings on PUT/POST
Accept calendar.settings (e.g. week_patterns) in validate_update and convert_field; apply on create like tags. Unblocks Front#42 pattern save which previously got 200 with empty settings.
This commit is contained in:
@@ -242,6 +242,14 @@ normalize_update({type, <<"personal">>}) -> {type, personal};
|
||||
normalize_update({type, <<"commercial">>}) -> {type, commercial};
|
||||
normalize_update({type, personal}) -> {type, personal};
|
||||
normalize_update({type, commercial}) -> {type, commercial};
|
||||
normalize_update({<<"settings">>, Value}) when is_map(Value) -> {settings, Value};
|
||||
normalize_update({<<"title">>, Value}) when is_binary(Value) -> {title, Value};
|
||||
normalize_update({<<"description">>, Value}) when is_binary(Value) -> {description, Value};
|
||||
normalize_update({<<"tags">>, Value}) when is_list(Value) -> {tags, Value};
|
||||
normalize_update({<<"short_name">>, Value}) when is_binary(Value) -> {short_name, Value};
|
||||
normalize_update({<<"category">>, Value}) when is_binary(Value) -> {category, Value};
|
||||
normalize_update({<<"color">>, Value}) when is_binary(Value) -> {color, Value};
|
||||
normalize_update({<<"image_url">>, Value}) when is_binary(Value) -> {image_url, Value};
|
||||
normalize_update(Other) -> Other.
|
||||
|
||||
validate_update({title, Value}) when is_binary(Value) -> true;
|
||||
@@ -249,6 +257,12 @@ validate_update({description, Value}) when is_binary(Value) -> true;
|
||||
validate_update({tags, Value}) when is_list(Value) -> true;
|
||||
validate_update({type, personal}) -> true;
|
||||
validate_update({type, commercial}) -> true;
|
||||
validate_update({short_name, Value}) when is_binary(Value) -> true;
|
||||
validate_update({category, Value}) when is_binary(Value) -> true;
|
||||
validate_update({color, Value}) when is_binary(Value) -> true;
|
||||
validate_update({image_url, Value}) when is_binary(Value) -> true;
|
||||
%% Opaque JSON object for client prefs (e.g. week_patterns for schedule fill).
|
||||
validate_update({settings, Value}) when is_map(Value) -> true;
|
||||
validate_update({confirmation, Value}) ->
|
||||
case Value of
|
||||
auto -> true;
|
||||
|
||||
Reference in New Issue
Block a user