-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Improve form inputs #129
Conversation
d6178fa
to
9d81ad6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking the input field should be made a component called DynamicInput that can change based on the JSON schema of an item. If that can be done in a follow up PR, I can go ahead and approve.
@@ -165,7 +165,7 @@ where | |||
<textarea | |||
type="text" | |||
placeholder="JSON schema" | |||
class="input input-bordered mt-5 rounded-md resize-y w-full max-w-md" | |||
class="input input-bordered mt-5 rounded-md resize-y w-full max-w-md pt-3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick
mt-3 would be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pt-3 is for the inner padding of the textarea
, So that it looks cleaner, there is already a mt
applied to it.
|
||
{config_value.get()} | ||
</textarea> | ||
let schema: Map<String, Value> = serde_json::from_value(config_schema_rs.get()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should deciding input field based on schema type be a component of it's own? It is used across 3 files and should behave the same for all of them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[prop(default = 0)] priority: u16,
can you change default to something else , since we do not support priority 0
better is to change it to option
and if someone dont provide number then you should not let it submit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't get you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mahatoankitkumar , we have similar fields for boolean and enum in both default_config and overrides form, can you make these a component and use them at both places, and also I think you should make similar changes for the context_form.
9c5b201
to
6b28ba0
Compare
05cd58b
to
bb8146e
Compare
bb8146e
to
43131f9
Compare
b155e44
to
029b79b
Compare
#[prop(default = String::new())] class: String, | ||
#[prop(default = false)] disabled: bool, | ||
) -> impl IntoView { | ||
let mut enum_array: Vec<String> = vec![]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mahatoankitkumar lets not assume enum array , as array of string only , it can be integer or decimal also
can we have that support , because if I am declaring enum of number in UI form dropdown shows nothing
029b79b
to
4afa622
Compare
let schema: Map<String, Value> = serde_json::from_value( | ||
dimensions_map.get(&dimension_label).unwrap().schema.clone(), | ||
) | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid doing plain unwrap here ?
class="input input-bordered w-full max-w-md" | ||
value=config_value.get() | ||
on:change=move |ev| { | ||
logging::log!("{:?}", event_target_value(& ev)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the description here ?
placeholder="Value" | ||
class="input input-bordered w-full max-w-md pt-3" | ||
on:change=move |ev| { | ||
logging::log!("{:?}", event_target_value(& ev)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well
.map(ConfigType::DefaultConfig) | ||
.collect::<Vec<_>>(), | ||
) | ||
.expect("can't parse default config key") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use unwrap_or instead and pass a json value having config_key_value :
unwrap_or(json!(config_key_value)
String::from("ENUM") | ||
} else { | ||
match schema.get("type").unwrap_or(&Value::Null) { | ||
Value::String(str_) => str_.to_ascii_uppercase(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Value::String(str) => str.to_ascii_uppercase(),
4afa622
to
9417580
Compare
2d3e17b
to
69d788b
Compare
Problem
Better form fields