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 selectItem; #458

Merged
merged 2 commits into from
Aug 9, 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
16 changes: 14 additions & 2 deletions docs/docsrc/examples/examples_admin/autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,22 @@ func AutoCompleteBasicFilterExample(b *presets.Builder, ab *autocomplete.Builder
bodyConfig.IsPaging = false
bodyConfig.ItemTitle = "body"
return []*vuetifyx.FilterItem{
{
Key: "select",
Label: "ID",
ItemType: vuetifyx.ItemTypeSelect,
// %s is the condition. e.g. >, >=, =, <, <=, like,
// ? is the value of selected option
SQLCondition: `id %s ?`,
Options: []*vuetifyx.SelectItem{
{Text: "test001", Value: "1"},
{Text: "test002", Value: "2"},
},
},
{
Key: "title",
Label: "Title",
ItemType: vuetifyx.ItemTypeSelect,
ItemType: vuetifyx.AutoCompleteTypeSelect,
// %s is the condition. e.g. >, >=, =, <, <=, like,
// ? is the value of selected option
SQLCondition: `title ilike ?`,
Expand All @@ -58,7 +70,7 @@ func AutoCompleteBasicFilterExample(b *presets.Builder, ab *autocomplete.Builder
{
Key: "body",
Label: "Body",
ItemType: vuetifyx.ItemTypeSelect,
ItemType: vuetifyx.AutoCompleteTypeSelect,
// %s is the condition. e.g. >, >=, =, <, <=, like,
// ? is the value of selected option
SQLCondition: `body ilike ?`,
Expand Down
43 changes: 43 additions & 0 deletions docs/docsrc/examples/examples_admin/autocomplete_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package examples_admin

import (
"github.com/qor5/admin/v3/autocomplete"
"github.com/theplant/gofixtures"
"net/http"
"net/http/httptest"
"testing"

"github.com/qor5/admin/v3/presets"
. "github.com/qor5/web/v3/multipartestutils"
)

var autocompleteData = gofixtures.Data(gofixtures.Sql(`
INSERT INTO public.auto_complete_posts (id, created_at, updated_at, deleted_at, title, body, status) VALUES (1, '2024-08-06 10:06:17.193170 +00:00', '2024-08-08 02:09:24.689204 +00:00', null, 'testname', 'test.body', '123131231');

`, []string{"auto_complete_posts"}))

func TestAutoComplete(t *testing.T) {
pb := presets.New()

ab := autocomplete.New().Prefix("/complete")
b := AutoCompleteBasicFilterExample(pb, ab, TestDB)

dbr, _ := TestDB.DB()

cases := []TestCase{
{
Name: "Index AutoCompletePost",
Debug: true,
ReqFunc: func() *http.Request {
autocompleteData.TruncatePut(dbr)
return httptest.NewRequest("GET", "/auto-complete-posts", nil)
},
ExpectPageBodyContainsInOrder: []string{"testname", "test.body"},
},
}
for _, c := range cases {
t.Run(c.Name, func(t *testing.T) {
RunCase(t, c, b)
})
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/pquerna/otp v1.4.0
github.com/qor/oss v0.0.0-20240729105053-88484a799a79
github.com/qor5/web/v3 v3.0.6-0.20240808073627-bd2003d12e2c
github.com/qor5/x/v3 v3.0.7-0.20240808103450-13664afa0ba5
github.com/qor5/x/v3 v3.0.7-0.20240809065519-d95284b78343
github.com/samber/lo v1.46.0
github.com/shurcooL/sanitized_anchor_name v1.0.0
github.com/spf13/cast v1.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ github.com/qor5/x/v3 v3.0.7-0.20240808085055-02376b65a3f9 h1:fuCaJ519NO5SL2LryGK
github.com/qor5/x/v3 v3.0.7-0.20240808085055-02376b65a3f9/go.mod h1:p8LBZGmJ9pozop2jMACV5tN/1gkpAskteOhlwcfFxpw=
github.com/qor5/x/v3 v3.0.7-0.20240808103450-13664afa0ba5 h1:GIIq/qk4VzVYHQMDJ++lHwa6L6y1O2yCWzXUX/p6CQw=
github.com/qor5/x/v3 v3.0.7-0.20240808103450-13664afa0ba5/go.mod h1:p8LBZGmJ9pozop2jMACV5tN/1gkpAskteOhlwcfFxpw=
github.com/qor5/x/v3 v3.0.7-0.20240809065519-d95284b78343 h1:teAzU+82V7wEje9accu0ulvtidOr5+cgCZFUAO5JmJE=
github.com/qor5/x/v3 v3.0.7-0.20240809065519-d95284b78343/go.mod h1:p8LBZGmJ9pozop2jMACV5tN/1gkpAskteOhlwcfFxpw=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
Expand Down
Loading