Skip to content

Commit

Permalink
UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleu committed Oct 12, 2024
1 parent 5eb6464 commit 19731f9
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 223 deletions.
50 changes: 31 additions & 19 deletions views/components/edit/TableEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@
{% endfunc %}

{% func TableEditorNoForm(key string, columns []*util.FieldDesc, values util.ValueMap, name string, value string, title string) %}
<table class="mt expanded">
<tbody>
{%- for _, arg := range columns -%}
{%- switch arg.Type -%}
{%- case "bool" -%}
{%= BoolTable(arg.Key, arg.Title, values.GetBoolOpt(arg.Key), 3, arg.Description) %}
{%- default -%}
{%= StringTable(arg.Key, key + "-" + arg.Key, arg.Title, values.GetStringOpt(arg.Key), 3, arg.Description) %}
{%- endswitch -%}
{%- endfor -%}
<tr>
{%- if name == "" -%}
<td colspan="2"><button type="submit">{%s title %}</button></td>
{%- else -%}
<td colspan="2"><button name="{%s name %}" value="{%s value %}" type="submit">{%s title %}</button></td>
{%- endif -%}
</tr>
</tbody>
</table>
<div class="overflow full-width">
<table class="mt min-200 expanded">
<tbody>
{%= TableEditorNoTable(key, columns, values) %}
<tr>
{%- if name == "" -%}
<td colspan="2"><button type="submit">{%s title %}</button></td>
{%- else -%}
<td colspan="2"><button name="{%s name %}" value="{%s value %}" type="submit">{%s title %}</button></td>
{%- endif -%}
</tr>
</tbody>
</table>
</div>
{% endfunc %}

{% func TableEditorNoTable(key string, columns []*util.FieldDesc, values util.ValueMap) %}{% stripspace %}
{%- for _, arg := range columns -%}
{%- switch arg.Type -%}
{%- case "bool" -%}
{%= BoolTable(arg.Key, arg.Title, values.GetBoolOpt(arg.Key), 3, arg.Description) %}
{%- case "textarea" -%}
{%= TextareaTable(arg.Key, "", arg.Title, 12, values.GetStringOpt(arg.Key), 3, arg.Description) %}
{%- case "number", "int" -%}
{%= IntTable(arg.Key, "", arg.Title, values.GetIntOpt(arg.Key), 3, arg.Description) %}
{%- case "float" -%}
{%= FloatTable(arg.Key, "", arg.Title, values.GetFloatOpt(arg.Key), 3, arg.Description) %}
{%- default -%}
{%= DatalistTable(arg.Key, "", arg.Title, values.GetStringOpt(arg.Key), arg.Choices, nil, 3, arg.Description) %}
{%- endswitch -%}
{%- endfor -%}
{% endstripspace %}{% endfunc %}
158 changes: 98 additions & 60 deletions views/components/edit/TableEdit.html.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 1 addition & 31 deletions views/vpage/Args.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% import (
"fmt"
"strconv"
"strings"

"github.com/kyleu/rituals/app"
Expand Down Expand Up @@ -32,36 +31,7 @@ <h3>{% if p.Directions == "" %}Enter Data{% else %}{%s p.Directions %}{% endif %
{%- for k, v := range p.Hidden -%}
<input type="hidden" name="{%s k %}" value="{%s v %}" />
{%- endfor -%}
<div class="overflow full-width">
<table class="mt min-200 expanded">
<tbody>
{%- for _, arg := range p.Results.FieldDescs -%}
{%- code
v := util.OrDefault(p.Results.Values.GetStringOpt(arg.Key), arg.Default)
title := arg.Title
if len(title) > 50 {
title = title[:50] + "..."
}
-%}
{%- switch arg.Type -%}
{%- case "bool" -%}
{%= edit.BoolTable(arg.Key, title, v == "true", 5, arg.Description) %}
{%- case "textarea" -%}
{%= edit.TextareaTable(arg.Key, "", title, 12, v, 5, arg.Description) %}
{%- case "number", "int" -%}
{%- code i, _ := strconv.ParseInt(v, 10, 32) -%}
{%= edit.IntTable(arg.Key, "", title, int(i), 5, arg.Description) %}
{%- case "float" -%}
{%- code f, _ := strconv.ParseFloat(v, 64) -%}
{%= edit.FloatTable(arg.Key, "", title, f, 5, arg.Description) %}
{%- default -%}
{%= edit.DatalistTable(arg.Key, "", title, v, arg.Choices, nil, 5, arg.Description) %}
{%- endswitch -%}
{%- endfor -%}
</tbody>
</table>
</div>
<button class="mt" type="submit">Submit</button>
{%= edit.TableEditorNoForm("args", p.Results.FieldDescs, p.Results.Values, "", "", "Submit") %}
</form>
</div>
{% endfunc %}
Loading

0 comments on commit 19731f9

Please sign in to comment.