Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

mahatoankitkumar
Copy link
Collaborator

Problem

Better form fields

  • enum → Toggle
  • boolean → dropdown with true and false options

Copy link
Collaborator

@Datron Datron left a 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"
Copy link
Collaborator

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

Copy link
Collaborator Author

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())
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@ShubhranshuSanjeev ShubhranshuSanjeev added the priority Things that need immediate attention label Jun 20, 2024
Copy link
Collaborator

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-06-20 at 15 59 08 @mahatoankitkumar can you fix this override button it should be aligned with context button

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't get you

Copy link
Collaborator

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.

@mahatoankitkumar mahatoankitkumar force-pushed the fix/improve/form/inputs branch 2 times, most recently from 9c5b201 to 6b28ba0 Compare June 21, 2024 06:37
@Datron Datron self-requested a review June 21, 2024 12:33
@mahatoankitkumar mahatoankitkumar force-pushed the fix/improve/form/inputs branch from 05cd58b to bb8146e Compare June 24, 2024 08:54
@mahatoankitkumar mahatoankitkumar force-pushed the fix/improve/form/inputs branch from bb8146e to 43131f9 Compare June 25, 2024 06:11
@mahatoankitkumar mahatoankitkumar force-pushed the fix/improve/form/inputs branch 2 times, most recently from b155e44 to 029b79b Compare June 25, 2024 15:54
#[prop(default = String::new())] class: String,
#[prop(default = false)] disabled: bool,
) -> impl IntoView {
let mut enum_array: Vec<String> = vec![];
Copy link
Collaborator

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

@Datron Datron self-requested a review June 27, 2024 05:36
@mahatoankitkumar mahatoankitkumar force-pushed the fix/improve/form/inputs branch from 029b79b to 4afa622 Compare June 27, 2024 06:41
let schema: Map<String, Value> = serde_json::from_value(
dimensions_map.get(&dimension_label).unwrap().schema.clone(),
)
.unwrap();
Copy link
Collaborator

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));
Copy link
Collaborator

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));
Copy link
Collaborator

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")
Copy link
Collaborator

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)

@sauraww sauraww self-requested a review July 1, 2024 12:07
String::from("ENUM")
} else {
match schema.get("type").unwrap_or(&Value::Null) {
Value::String(str_) => str_.to_ascii_uppercase(),
Copy link
Collaborator

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(),

@sauraww sauraww self-requested a review July 3, 2024 07:14
@mahatoankitkumar mahatoankitkumar force-pushed the fix/improve/form/inputs branch from 4afa622 to 9417580 Compare July 3, 2024 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority Things that need immediate attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve form inputs based on json schema type
5 participants