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 keyword missed unescape && revert to page 0 after state changed #349

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/docsrc/examples/examples_presets/listing.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,17 @@ func PresetsListingCustomizationFields(b *presets.Builder, db *gorm.DB) (
mb, cl, ce, dp = PresetsHelloWorld(b, db)

cl = mb.Listing("ID", "Name", "Company", "Email").
SearchColumns("name", "email").SelectableColumns(true)
SearchColumns("name", "email").SelectableColumns(true).
OrderableFields([]*presets.OrderableField{
{
FieldName: "ID",
DBColumn: "id",
},
{
FieldName: "Name",
DBColumn: "name",
},
})
cl.Field("Company").ComponentFunc(func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) h.HTMLComponent {
c := obj.(*Customer)
var comp Company
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ require (
github.com/pkg/errors v0.9.1
github.com/pquerna/otp v1.4.0
github.com/qor/oss v0.0.0-20230717083721-c04686f83630
github.com/qor5/web/v3 v3.0.5-0.20240717040023-4b80a69c031d
github.com/qor5/web/v3 v3.0.5-0.20240723094007-d24081129126
github.com/qor5/x/v3 v3.0.6-0.20240723060143-cae2d56f60a2
github.com/samber/lo v1.46.0
github.com/shurcooL/sanitized_anchor_name v1.0.0
github.com/spf13/cast v1.6.0
github.com/stretchr/testify v1.9.0
github.com/sunfmin/reflectutils v1.0.5
github.com/sunfmin/reflectutils v1.0.6-0.20240723093451-ac287aca03a9
github.com/sunfmin/snippetgo v0.0.3
github.com/theplant/bimg v1.1.1
github.com/theplant/docgo v0.0.16
Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,8 @@ github.com/qor/oss v0.0.0-20230717083721-c04686f83630 h1:CRi4xF7B8aGX/y48NCjarNd
github.com/qor/oss v0.0.0-20230717083721-c04686f83630/go.mod h1:FDxJAVwmZ1j8ITcKJExFlzkTYuUor1dBKZgNVWqEqlM=
github.com/qor5/web v1.3.2 h1:zw796YJeDLe8vRwGR1cM+uS1ZuSkPutchBEXv2GgOhI=
github.com/qor5/web v1.3.2/go.mod h1:LszskQJbFQDJwOeZC6j6afOiHxxyjrzz8B3zuBwfgKQ=
github.com/qor5/web/v3 v3.0.5-0.20240717040023-4b80a69c031d h1:IKW0l0FZAmczHynvBOH6MQjfqpL5v9pSf094uO7U9io=
github.com/qor5/web/v3 v3.0.5-0.20240717040023-4b80a69c031d/go.mod h1:RPLKS/poCC6yN+CKPQB1iS7g2V0iz7vIsJSY6v/8zY0=
github.com/qor5/x/v3 v3.0.6-0.20240716033136-45995deaaeb2 h1:+PKEd+OBDnJj6OVz4I+GubbiUmzMXsOiR/tOk7paidY=
github.com/qor5/x/v3 v3.0.6-0.20240716033136-45995deaaeb2/go.mod h1:85rLAySzyq7L0dWXzICMnBVULCv53AtYmx3x1qeCDx0=
github.com/qor5/x/v3 v3.0.6-0.20240723021616-8a45a777a11c h1:u4M7e7HWl/t3HQPuj3zOp/PuAxqOn9o0ejOMHfeQvwQ=
github.com/qor5/x/v3 v3.0.6-0.20240723021616-8a45a777a11c/go.mod h1:85rLAySzyq7L0dWXzICMnBVULCv53AtYmx3x1qeCDx0=
github.com/qor5/web/v3 v3.0.5-0.20240723094007-d24081129126 h1:LfWbM+CBJbgDqKDyRk8GeYYOoZ8UgQG17t5DwoYUX9o=
github.com/qor5/web/v3 v3.0.5-0.20240723094007-d24081129126/go.mod h1:32vdHHcZb2JimlcaclW9hLUyimdXjrllZDHTh3rl6d0=
github.com/qor5/x/v3 v3.0.6-0.20240723060143-cae2d56f60a2 h1:Ed4WRJS9uNomilDEgd6MA/YqrdeGu/0rl2q627hkXmA=
github.com/qor5/x/v3 v3.0.6-0.20240723060143-cae2d56f60a2/go.mod h1:85rLAySzyq7L0dWXzICMnBVULCv53AtYmx3x1qeCDx0=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
Expand Down Expand Up @@ -379,8 +375,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/sunfmin/reflectutils v1.0.5 h1:izu+W1FasRz0KXUqFo/h4GKsXveDiUt3SwVvFs6w0wU=
github.com/sunfmin/reflectutils v1.0.5/go.mod h1:ao2bbF4RZrTe2PboJKdZoC3BA71gdU6rFkCuUjoeqMw=
github.com/sunfmin/reflectutils v1.0.6-0.20240723093451-ac287aca03a9 h1:uGwnYgklZ5WLaQO8GKg4vGP2kykhrQztoAZ5/huKnG0=
github.com/sunfmin/reflectutils v1.0.6-0.20240723093451-ac287aca03a9/go.mod h1:ao2bbF4RZrTe2PboJKdZoC3BA71gdU6rFkCuUjoeqMw=
github.com/sunfmin/snippetgo v0.0.3 h1:pMCpFCyW2fYHhfLp4tb5ccvTCpIuSNFomtDCr9duUaE=
github.com/sunfmin/snippetgo v0.0.3/go.mod h1:Ue+VuRdcJfuRkdxawPJOYYqKw1MgeJNwAz1qCc1pazQ=
github.com/testcontainers/testcontainers-go v0.31.0 h1:W0VwIhcEVhRflwL9as3dhY6jXjVCA27AkmbnZ+UTh3U=
Expand Down
17 changes: 14 additions & 3 deletions presets/listing_compo.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
tabs.AppendChildren(
VTab().
Attr("@click", stateful.ReloadAction(ctx, c, func(target *ListingCompo) {
target.Page = 0
target.ActiveFilterTab = ft.ID
target.FilterQuery = encodedQuery
}).Go()).
Expand All @@ -182,7 +183,10 @@
return nil
}
_, msgr := c.MustGetEventContext(ctx)
reloadAction := stateful.ReloadAction(ctx, c, nil,
reloadAction := stateful.ReloadAction(ctx, c,
func(target *ListingCompo) {
target.Page = 0
},
stateful.WithAppendFix(`v.compo.keyword = xlocals.keyword`),
).Go()
return web.Scope().VSlot("{ locals: xlocals }").Init(fmt.Sprintf("{ keyword: %q }", c.Keyword)).Children(
Expand All @@ -199,6 +203,7 @@
Attr("v-model", "xlocals.keyword").
Attr("@keyup.enter", reloadAction).
Attr("@click:clear", stateful.ReloadAction(ctx, c, func(target *ListingCompo) {
target.Page = 0
target.Keyword = ""
}).Go()).
Children(
Expand Down Expand Up @@ -287,7 +292,9 @@
}`))
return web.Scope().VSlot("{locals:xlocals}").Init("{textFieldSearchElem: null}").Children(
vx.VXFilter(fd).Translations(ft).
UpdateModelValue(stateful.ReloadAction(ctx, c, nil, opts...).Go()).
UpdateModelValue(stateful.ReloadAction(ctx, c, func(target *ListingCompo) {
target.Page = 0
}, opts...).Go()).

Check warning on line 297 in presets/listing_compo.go

View check run for this annotation

Codecov / codecov/patch

presets/listing_compo.go#L295-L297

Added lines #L295 - L297 were not covered by tests
Attr("v-run", fmt.Sprintf(`(el) => {
xlocals.textFieldSearchElem = el.ownerDocument.getElementById(%q);
}`, c.textFieldSearchID())),
Expand Down Expand Up @@ -440,6 +447,7 @@
}
return h.Th("").Style("cursor: pointer; white-space: nowrap;").
Attr("@click.stop", stateful.ReloadAction(ctx, c, func(target *ListingCompo) {
target.Page = 0

Check warning on line 450 in presets/listing_compo.go

View check run for this annotation

Codecov / codecov/patch

presets/listing_compo.go#L450

Added line #L450 was not covered by tests
if orderBy.OrderBy == OrderByASC {
orderBy.OrderBy = OrderByDESC
} else {
Expand Down Expand Up @@ -513,7 +521,10 @@
PerPage(searchParams.PerPage).
CustomPerPages([]int64{c.lb.perPage}).
PerPageText(msgr.PaginationRowsPerPage).
OnSelectPerPage(stateful.ReloadAction(ctx, c, nil,
OnSelectPerPage(stateful.ReloadAction(ctx, c,
func(target *ListingCompo) {
target.Page = 0
},
stateful.WithAppendFix(`v.compo.per_page = parseInt($event, 10)`),
).Go()).
OnPrevPage(stateful.ReloadAction(ctx, c, func(target *ListingCompo) {
Expand Down
2 changes: 1 addition & 1 deletion utils/testflow/gentool/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/gobuffalo/flect v1.0.2
github.com/pkg/errors v0.9.1
github.com/qor5/admin/v3 v3.0.1-0.20240424102851-d75759576158
github.com/qor5/web/v3 v3.0.5-0.20240717040023-4b80a69c031d
github.com/qor5/web/v3 v3.0.5-0.20240723094007-d24081129126
github.com/sergi/go-diff v1.3.1
mvdan.cc/gofumpt v0.6.0
)
Expand Down
4 changes: 2 additions & 2 deletions utils/testflow/gentool/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qor5/web/v3 v3.0.5-0.20240717040023-4b80a69c031d h1:IKW0l0FZAmczHynvBOH6MQjfqpL5v9pSf094uO7U9io=
github.com/qor5/web/v3 v3.0.5-0.20240717040023-4b80a69c031d/go.mod h1:RPLKS/poCC6yN+CKPQB1iS7g2V0iz7vIsJSY6v/8zY0=
github.com/qor5/web/v3 v3.0.5-0.20240723094007-d24081129126 h1:LfWbM+CBJbgDqKDyRk8GeYYOoZ8UgQG17t5DwoYUX9o=
github.com/qor5/web/v3 v3.0.5-0.20240723094007-d24081129126/go.mod h1:32vdHHcZb2JimlcaclW9hLUyimdXjrllZDHTh3rl6d0=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
Expand Down
Loading