From 008f26e9c14a4a0355216f852da61c9db195ef8d Mon Sep 17 00:00:00 2001 From: roberto Date: Tue, 4 Feb 2025 18:03:31 +0100 Subject: [PATCH] Code style cleanup --- assets/templates/items/add_relation.tmpl | 14 +- assets/templates/items/all_list_rows.tmpl | 10 +- assets/templates/items/fields.tmpl | 20 +- assets/templates/items/form.tmpl | 8 +- .../templates/items/list_for_relations.tmpl | 6 +- assets/templates/items/list_rows.tmpl | 4 +- assets/templates/items/update_title.tmpl | 2 +- assets/templates/items/view.tmpl | 10 +- assets/templates/pages/home_items.tmpl | 4 +- assets/templates/quickbox/add.tmpl | 2 +- assets/templates/quickbox/list.tmpl | 2 +- assets/templates/types/fields.tmpl | 26 +-- assets/templates/types/form.tmpl | 4 +- cmd/web/categories_handler.go | 24 +- cmd/web/handlers.go | 22 +- cmd/web/helpers.go | 6 +- cmd/web/items_handlers.go | 214 +++++++++--------- cmd/web/notebooks_handlers.go | 24 +- cmd/web/quickbox_handlers.go | 88 +++---- cmd/web/types_handlers.go | 168 +++++++------- models/category.go | 8 +- models/field.go | 88 +++---- models/item.go | 2 +- models/type.go | 40 ++-- 24 files changed, 398 insertions(+), 398 deletions(-) diff --git a/assets/templates/items/add_relation.tmpl b/assets/templates/items/add_relation.tmpl index d18734c..08deb32 100644 --- a/assets/templates/items/add_relation.tmpl +++ b/assets/templates/items/add_relation.tmpl @@ -1,16 +1,16 @@ {{define "item:add_relation"}} -{{ $relation_name := printf "%s%v" "ItemRelation-New-" .relatedItem.Id }} - - {{.relatedItem.Type_title}} : +{{ $relationName := printf "%s%v" "ItemRelation-New-" .relatedItem.Id }} + + {{.relatedItem.TypeTitle}} : {{.relatedItem.Title}} {{ if gt (len .relatedItem.Categories) 0 }} {{ range (stringToArray .relatedItem.Categories "|")}} - {{ $category_name := index $.categoriesMap .}} + {{ $categoryName := index $.categoriesMap .}}
- {{ $category_name }} + {{ $categoryName }}
{{ end }} {{ end }} @@ -25,9 +25,9 @@ {{ end }} {{ end }} - {{ widget_relation_type $relation_name "Link" `id="$relation_name"` }} + {{ widget_relation_type $relationName "Link" `id="$relationName"` }} - Remove + Remove {{ end }} diff --git a/assets/templates/items/all_list_rows.tmpl b/assets/templates/items/all_list_rows.tmpl index 98d7a81..cd629c8 100644 --- a/assets/templates/items/all_list_rows.tmpl +++ b/assets/templates/items/all_list_rows.tmpl @@ -14,15 +14,15 @@ > {{.Title}} - {{.Title}} + {{.Title}} - {{.Type_title}} + {{.TypeTitle}} {{ if gt (len .Categories) 0 }} {{ range (stringToArray .Categories "|")}} - {{ $category_id := index $.categoriesMap .}} - {{ $category_id }} + {{ $categoryId := index $.categoriesMap .}} + {{ $categoryId }} {{ end }} {{ end }} @@ -36,7 +36,7 @@ - {{ if eq .On_dashboard 1}} + {{ if eq .OnDashboard 1}} {{ template "item:remove_from_dashboard" .Id }} {{ else }} {{ template "item:add_to_dashboard" .Id }} diff --git a/assets/templates/items/fields.tmpl b/assets/templates/items/fields.tmpl index aa6d954..ba253eb 100644 --- a/assets/templates/items/fields.tmpl +++ b/assets/templates/items/fields.tmpl @@ -2,28 +2,28 @@ {{ range (index .FieldsSection .uisection) }} {{ $field := .}} -{{ $values := (index $.FieldsValues .Type_field_id)}} +{{ $values := (index $.FieldsValues .TypeFieldId)}} -{{ if eq .Is_multiple 1}} +{{ if eq .IsMultiple 1}}
-
+
{{ $g_counter := 0 }} {{ range $counter, $value := $values}} - +
-
{{ field_widget $field.Widget $field.Type_field_id $counter "" $value $field.Valid_values ""}}
+
{{ field_widget $field.Widget $field.TypeFieldId $counter "" $value $field.Valid_values ""}}
- - + +
{{ $g_counter = $counter}} {{ end }}
- {{incr $g_counter }} - + {{incr $g_counter }} +
{{ else }}

@@ -31,7 +31,7 @@ {{ if gt (len $values) 0 }} {{ $value = index $values 0 }} {{ end }} - {{ field_widget .Widget .Type_field_id 0 .Title $value .Valid_values ""}} + {{ field_widget .Widget .TypeFieldId 0 .Title $value .Valid_values ""}}

{{ end }} {{ end }} diff --git a/assets/templates/items/form.tmpl b/assets/templates/items/form.tmpl index c791662..a405d18 100644 --- a/assets/templates/items/form.tmpl +++ b/assets/templates/items/form.tmpl @@ -31,7 +31,7 @@

- {{ widget_select "Type_id" "Type" .item.Type_id .types `style="width: 100%"` }} + {{ widget_select "Type_id" "Type" .item.TypeId .types `style="width: 100%"` }}

@@ -45,14 +45,14 @@ {{ template "items:fields" (map "FieldsSection" .item.FieldsSection "FieldsValues" .item.FieldsValues "uisection" "general")}}
- {{ if eq .item.Type_show_summary 1}} + {{ if eq .item.TypeShowSummary 1}}

{{ end }} - {{ if eq .item.Type_show_description 1}} + {{ if eq .item.TypeShowDescription 1}}

@@ -73,7 +73,7 @@

- {{ widget_checkbox "On_dashboard" "On dashboard" "1" .item.On_dashboard }} + {{ widget_checkbox "On_dashboard" "On dashboard" "1" .item.OnDashboard }}

diff --git a/assets/templates/items/list_for_relations.tmpl b/assets/templates/items/list_for_relations.tmpl index 88e60d0..264e1a0 100644 --- a/assets/templates/items/list_for_relations.tmpl +++ b/assets/templates/items/list_for_relations.tmpl @@ -17,16 +17,16 @@ href="/item/view/{{.Id}}" hx-get="/item/view/{{.Id}}" hx-target="#modal-container" - > {{.Title}} {{.Title}} {{ if gt (len .Categories) 0 }} {{ range (stringToArray .Categories "|")}} - {{ $category_name := index $.categoriesMap .}} + {{ $categoryName := index $.categoriesMap .}}
- {{ $category_name }} + {{ $categoryName }}
{{ end }} {{ end }} diff --git a/assets/templates/items/list_rows.tmpl b/assets/templates/items/list_rows.tmpl index bcd2c4f..5b4a3f1 100644 --- a/assets/templates/items/list_rows.tmpl +++ b/assets/templates/items/list_rows.tmpl @@ -36,7 +36,7 @@ {{ $fieldsValuesMap := .FieldsValuesMap}} {{ range $.Fields}} - {{ $values_str := renderFieldValues (index $fieldsValuesMap .Type_field_id) .Widget }} + {{ $values_str := renderFieldValues (index $fieldsValuesMap .TypeFieldId) .Widget }} {{ if gt (len $values_str) 0 }} {{.Title}} : {{ $values_str }} {{ end }} @@ -44,7 +44,7 @@ {{end}} - {{ if eq .On_dashboard 1}} + {{ if eq .OnDashboard 1}} {{ template "item:remove_from_dashboard" .Id }} {{ else }} {{ template "item:add_to_dashboard" .Id }} diff --git a/assets/templates/items/update_title.tmpl b/assets/templates/items/update_title.tmpl index 2572baa..45f334d 100644 --- a/assets/templates/items/update_title.tmpl +++ b/assets/templates/items/update_title.tmpl @@ -1,5 +1,5 @@ {{define "page:title"}} -
Edit {{.item.Type_title}}
+
Edit {{.item.TypeTitle}}
diff --git a/assets/templates/items/view.tmpl b/assets/templates/items/view.tmpl index 9d2cce8..205b9e2 100644 --- a/assets/templates/items/view.tmpl +++ b/assets/templates/items/view.tmpl @@ -1,18 +1,18 @@ {{define "page:content"}}
-
{{.item.Type_title}} : {{.item.Title}}
+
{{.item.TypeTitle}} : {{.item.Title}}
{{ if gt (len .item.Summary) 0}} Summary
- {{.item.Summary_rendered | safeHTML}} + {{.item.SummaryRendered | safeHTML}}
{{ end }} - {{.item.Description_rendered | safeHTML}} + {{.item.DescriptionRendered | safeHTML}} {{ if gt (len .fields) 0}}
    @@ -28,9 +28,9 @@
    Categories {{ range (stringToArray .item.Categories "|")}} - {{ $category_name := index $.categoriesMap .}} + {{ $categoryName := index $.categoriesMap .}} {{ end }}
    diff --git a/assets/templates/pages/home_items.tmpl b/assets/templates/pages/home_items.tmpl index a218fa5..0cbb410 100644 --- a/assets/templates/pages/home_items.tmpl +++ b/assets/templates/pages/home_items.tmpl @@ -16,8 +16,8 @@
    - {{.Title}} - {{.Title}} + {{.Title}} + {{.Title}}
    {{.Summary | markdownfy | safeHTML}}
    diff --git a/assets/templates/quickbox/add.tmpl b/assets/templates/quickbox/add.tmpl index 9d5c0e7..5df8a3a 100644 --- a/assets/templates/quickbox/add.tmpl +++ b/assets/templates/quickbox/add.tmpl @@ -4,6 +4,6 @@
    -
    {{.quicknote.Note_rendered | safeHTML}}
    +
    {{.quicknote.NoteRendered | safeHTML}}
{{end}} \ No newline at end of file diff --git a/assets/templates/quickbox/list.tmpl b/assets/templates/quickbox/list.tmpl index e165fb1..4f37b33 100644 --- a/assets/templates/quickbox/list.tmpl +++ b/assets/templates/quickbox/list.tmpl @@ -13,7 +13,7 @@ hx-get="/quickbox/all?offset={{ $offset }}" hx-trigger="intersect once" hx-swap= -
{{.Note_rendered | safeHTML}}
+
{{.NoteRendered | safeHTML}}
{{ end }} {{ end }} \ No newline at end of file diff --git a/assets/templates/types/fields.tmpl b/assets/templates/types/fields.tmpl index 0a45947..e5f52f5 100644 --- a/assets/templates/types/fields.tmpl +++ b/assets/templates/types/fields.tmpl @@ -1,36 +1,36 @@ {{define "types:fields"}} {{ range .fields }}
-
+
- {{ widget_select (print "Fields-" .Type_field_id "-Widget_id") "Widget" .Widget_id $.widgets `` }} + {{ widget_select (print "Fields-" .TypeFieldId "-Widget_id") "Widget" .WidgetId $.widgets `` }}
- - + +
- - + +
- {{ widget_select (print "Fields-" .Type_field_id "-Ui_section") "Section" .Ui_section $.uisections `` }} + {{ widget_select (print "Fields-" .TypeFieldId "-Ui_section") "Section" .UiSection $.uisections `` }}
-

{{ widget_checkbox (print "Fields-" .Type_field_id "-Show_on_list") "Show on list" "1" .Show_on_list }}

-

{{ widget_checkbox (print "Fields-" .Type_field_id "-Show_on_view") "Show on view" "1" .Show_on_view }}

-

{{ widget_checkbox (print "Fields-" .Type_field_id "-Is_multiple") "Multiple" "1" .Is_multiple }}

+

{{ widget_checkbox (print "Fields-" .TypeFieldId "-Show_on_list") "Show on list" "1" .ShowOnList }}

+

{{ widget_checkbox (print "Fields-" .TypeFieldId "-Show_on_view") "Show on view" "1" .ShowOnView }}

+

{{ widget_checkbox (print "Fields-" .TypeFieldId "-Is_multiple") "Multiple" "1" .IsMultiple }}

- +
- - + +
{{ end }} diff --git a/assets/templates/types/form.tmpl b/assets/templates/types/form.tmpl index 5438927..55b6159 100644 --- a/assets/templates/types/form.tmpl +++ b/assets/templates/types/form.tmpl @@ -28,9 +28,9 @@

-

{{ widget_checkbox "Show_summary" "Show summary" "1" .type.Show_summary }}

+

{{ widget_checkbox "Show_summary" "Show summary" "1" .type.ShowSummary }}

-

{{ widget_checkbox "Show_description" "Show description" "1" .type.Show_description }}

+

{{ widget_checkbox "Show_description" "Show description" "1" .type.ShowDescription }}