diff --git a/internal/router/frontend.go b/internal/router/frontend.go index 04f0ce4a..c78bf54b 100644 --- a/internal/router/frontend.go +++ b/internal/router/frontend.go @@ -722,7 +722,11 @@ func registerFrontendRoutes(cfg *Config) { } } } - fieldsJSON := templates.JSONArg(services.FilterFieldsPayload(scope)) + fieldsPayload, merr := json.Marshal(services.FilterFieldsPayload(scope)) + if merr != nil { + fieldsPayload = []byte("[]") + } + fieldsJSON := string(fieldsPayload) colData := templates.CollectionData{ ID: collectionID, diff --git a/templates/bookshelf.templ b/templates/bookshelf.templ index 64b3948b..e224aeea 100644 --- a/templates/bookshelf.templ +++ b/templates/bookshelf.templ @@ -180,7 +180,7 @@ templ BookShelf( data-filter-fields={ JSONArg(services.FilterFieldsPayload("books")) } x-effect="filtersOpen === true && ensureReadyRule()" > - @FilterBuilderRows("books") + @FilterBuilderRows("book")
diff --git a/templates/bookshelf_templ.go b/templates/bookshelf_templ.go index 4e5a59ce..1e116d17 100644 --- a/templates/bookshelf_templ.go +++ b/templates/bookshelf_templ.go @@ -424,7 +424,7 @@ func BookShelf( if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = FilterBuilderRows("books").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FilterBuilderRows("book").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/templates/collection_rules.templ b/templates/collection_rules.templ index 0f9ee43d..73d9a65c 100644 --- a/templates/collection_rules.templ +++ b/templates/collection_rules.templ @@ -21,7 +21,7 @@ templ CollectionRules(user User, collection CollectionData, fieldsJSON string, t class={ "theme-" + user.Theme } x-data="collectionRules" data-collection-name={ collection.Name } - x-init={ "initCollectionRules('" + collection.ID + "', '" + scope + "', " + JSONArg(treeJSON) + ")" } + x-init={ "initCollectionRules('" + collection.ID + "', '" + scope + "')" } > @Header(user, "/collections")
@@ -52,15 +52,15 @@ templ CollectionRules(user User, collection CollectionData, fieldsJSON string, t root mode IS the collection's match semantics. -->

Filter tree

- @FilterBuilderRows("items") + @FilterBuilderRows("item")
diff --git a/templates/collection_rules_templ.go b/templates/collection_rules_templ.go index 2b2fc3fe..7135cf8e 100644 --- a/templates/collection_rules_templ.go +++ b/templates/collection_rules_templ.go @@ -89,9 +89,9 @@ func CollectionRules(user User, collection CollectionData, fieldsJSON string, tr return templ_7745c5c3_Err } var templ_7745c5c3_Var6 string - templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.ResolveAttributeValue("initCollectionRules('" + collection.ID + "', '" + scope + "', " + JSONArg(treeJSON) + ")") + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.ResolveAttributeValue("initCollectionRules('" + collection.ID + "', '" + scope + "')") if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collection_rules.templ`, Line: 24, Col: 102} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collection_rules.templ`, Line: 24, Col: 75} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6) if templ_7745c5c3_Err != nil { @@ -172,9 +172,9 @@ func CollectionRules(user User, collection CollectionData, fieldsJSON string, tr return templ_7745c5c3_Err } var templ_7745c5c3_Var10 string - templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.ResolveAttributeValue(JSONArg(fieldsJSON)) + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.ResolveAttributeValue(fieldsJSON) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collection_rules.templ`, Line: 55, Col: 45} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collection_rules.templ`, Line: 55, Col: 36} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10) if templ_7745c5c3_Err != nil { @@ -187,7 +187,7 @@ func CollectionRules(user User, collection CollectionData, fieldsJSON string, tr var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.ResolveAttributeValue(scope) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collection_rules.templ`, Line: 56, Col: 24} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collection_rules.templ`, Line: 56, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11) if templ_7745c5c3_Err != nil { @@ -198,9 +198,9 @@ func CollectionRules(user User, collection CollectionData, fieldsJSON string, tr return templ_7745c5c3_Err } var templ_7745c5c3_Var12 string - templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.ResolveAttributeValue(JSONArg(treeJSON)) + templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.ResolveAttributeValue(treeJSON) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collection_rules.templ`, Line: 57, Col: 34} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/collection_rules.templ`, Line: 57, Col: 25} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12) if templ_7745c5c3_Err != nil { @@ -210,7 +210,7 @@ func CollectionRules(user User, collection CollectionData, fieldsJSON string, tr if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = FilterBuilderRows("items").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = FilterBuilderRows("item").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/templates/filter_builder.templ b/templates/filter_builder.templ index 498dd714..c8385dd2 100644 --- a/templates/filter_builder.templ +++ b/templates/filter_builder.templ @@ -10,7 +10,7 @@ templ FilterBuilderRows(countNoun string) {