forked from enviPath/enviPy
[Fix] UI Fixes (#266)
Rather than have a bunch of pull-requests that @jebus will have to merge shall we collect some of the fixes for the UI issues I found in here. - [x] #259 - [x] #260 - [x] #261 - [x] #262 - [x] #263 - [x] #264 - [x] #265 Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Reviewed-on: enviPath/enviPy#266 Co-authored-by: Liam Brydon <lbry121@aucklanduni.ac.nz> Co-committed-by: Liam Brydon <lbry121@aucklanduni.ac.nz>
This commit is contained in:
@ -61,7 +61,7 @@ class HTMLGenerator:
|
||||
else:
|
||||
clz_name = additional_information.__class__.__name__
|
||||
|
||||
widget = f"<h4>{clz_name}</h4>"
|
||||
widget = f'<h4 class="h4 font-semibold mt-2 mb-1">{clz_name}</h4>'
|
||||
|
||||
if hasattr(additional_information, "uuid"):
|
||||
uuid = additional_information.uuid
|
||||
@ -89,15 +89,21 @@ class HTMLGenerator:
|
||||
)
|
||||
|
||||
if is_interval_float:
|
||||
label_text_start = " ".join([x.capitalize() for x in name.split("_")]) + " Start"
|
||||
label_text_end = " ".join([x.capitalize() for x in name.split("_")]) + " End"
|
||||
widget += f"""
|
||||
<div class="form-group row">
|
||||
<div class="col-md-6">
|
||||
<label for="{full_name}__start">{" ".join([x.capitalize() for x in name.split("_")])} Start</label>
|
||||
<input type="number" class="form-control" id="{full_name}__start" name="{full_name}__start" value="{value.start if value else ""}">
|
||||
<div class="grid grid-cols-2 gap-4 mb-4">
|
||||
<div class="form-control">
|
||||
<label class="label" for="{full_name}__start">
|
||||
<span class="label-text">{label_text_start}</span>
|
||||
</label>
|
||||
<input type="number" class="input input-bordered w-full" id="{full_name}__start" name="{full_name}__start" value="{value.start if value else ""}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="{full_name}__end">{" ".join([x.capitalize() for x in name.split("_")])} End</label>
|
||||
<input type="number" class="form-control" id="{full_name}__end" name="{full_name}__end" value="{value.end if value else ""}">
|
||||
<div class="form-control">
|
||||
<label class="label" for="{full_name}__end">
|
||||
<span class="label-text">{label_text_end}</span>
|
||||
</label>
|
||||
<input type="number" class="input input-bordered w-full" id="{full_name}__end" name="{full_name}__end" value="{value.end if value else ""}">
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
@ -106,11 +112,14 @@ class HTMLGenerator:
|
||||
for e in field_type:
|
||||
options += f'<option value="{e.value}" {"selected" if e == value else ""}>{html.escape(e.name)}</option>'
|
||||
|
||||
label_text = " ".join([x.capitalize() for x in name.split("_")])
|
||||
widget += f"""
|
||||
<div class="form-group">
|
||||
<label for="{full_name}">{" ".join([x.capitalize() for x in name.split("_")])}</label>
|
||||
<select class="form-control" id="{full_name}" name="{full_name}">
|
||||
<option value="" disabled selected>Select {" ".join([x.capitalize() for x in name.split("_")])}</option>
|
||||
<div class="form-control mb-4">
|
||||
<label class="label" for="{full_name}">
|
||||
<span class="label-text">{label_text}</span>
|
||||
</label>
|
||||
<select class="select select-bordered w-full" id="{full_name}" name="{full_name}">
|
||||
<option value="" disabled selected>Select {label_text}</option>
|
||||
{options}
|
||||
</select>
|
||||
</div>
|
||||
@ -126,15 +135,28 @@ class HTMLGenerator:
|
||||
raise ValueError(f"Could not parse field type {field_type} for {name}")
|
||||
|
||||
value_to_use = value if value and field_type is not bool else ""
|
||||
label_text = " ".join([x.capitalize() for x in name.split("_")])
|
||||
|
||||
widget += f"""
|
||||
<div class="form-group">
|
||||
<label for="{full_name}">{" ".join([x.capitalize() for x in name.split("_")])}</label>
|
||||
<input type="{input_type}" class="form-control" id="{full_name}" name="{full_name}" value="{value_to_use}" {"checked" if value and field_type is bool else ""}>
|
||||
</div>
|
||||
"""
|
||||
if field_type is bool:
|
||||
widget += f"""
|
||||
<div class="form-control mb-4">
|
||||
<label class="label cursor-pointer">
|
||||
<span class="label-text">{label_text}</span>
|
||||
<input type="checkbox" class="checkbox" id="{full_name}" name="{full_name}" {"checked" if value else ""}>
|
||||
</label>
|
||||
</div>
|
||||
"""
|
||||
else:
|
||||
widget += f"""
|
||||
<div class="form-control mb-4">
|
||||
<label class="label" for="{full_name}">
|
||||
<span class="label-text">{label_text}</span>
|
||||
</label>
|
||||
<input type="{input_type}" class="input input-bordered w-full" id="{full_name}" name="{full_name}" value="{value_to_use}">
|
||||
</div>
|
||||
"""
|
||||
|
||||
return widget + "<hr>"
|
||||
return widget
|
||||
|
||||
@staticmethod
|
||||
def build_models(params) -> Dict[str, List["EnviPyModel"]]:
|
||||
|
||||
Reference in New Issue
Block a user