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

Feat UI reborn #540

Merged
merged 9 commits into from
Sep 3, 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
17 changes: 17 additions & 0 deletions docs/docsrc/examples/examples_presets/listing.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ func PresetsKeywordSearchOff(b *presets.Builder, db *gorm.DB) (

// @snippet_begin(PresetsListingCustomizationFieldsSample)

func PresetsRowMenuAction(b *presets.Builder, db *gorm.DB) (
mb *presets.ModelBuilder,
cl *presets.ListingBuilder,
ce *presets.EditingBuilder,
dp *presets.DetailingBuilder,
) {
mb, cl, ce, dp = PresetsHelloWorld(b, db)
cl.KeywordSearchOff(true)
rmb := cl.RowMenu()

rmb.RowMenuItem("with-icon").Icon("mdi-close")
rmb.RowMenuItem("Delete").ComponentFunc(func(obj interface{}, id string, ctx *web.EventContext) h.HTMLComponent {
return nil
})
return
}

type Company struct {
ID int
Name string
Expand Down
24 changes: 24 additions & 0 deletions docs/docsrc/examples/examples_presets/listing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ func TestPresetsListingKeywordSearchOff(t *testing.T) {
}
}

func TestPresetsRowMenuIcon(t *testing.T) {

pb := presets.New().DataOperator(gorm2op.DataOperator(TestDB))
PresetsRowMenuAction(pb, TestDB)
TestDB.AutoMigrate(&CreditCard{})
cases := []multipartestutils.TestCase{
{
Name: "row menu with no icon",
Debug: true,
ReqFunc: func() *http.Request {
detailData.TruncatePut(SqlDB)
return httptest.NewRequest("GET", "/customers?__execute_event__=__reload__", nil)
},
ExpectPageBodyContainsInOrder: []string{`:icon='\"mdi-close\"'\u003e\u003c/v-icon\u003e\n\u003c/template\u003e\n\n\u003cv-list-item-title\u003ewith-icon\u003c/v-list-item-title\u003e`},
},
}

for _, c := range cases {
t.Run(c.Name, func(t *testing.T) {
multipartestutils.RunCase(t, c, pb)
})
}
}

func TestPresetsListingCustomizationFields(t *testing.T) {
pb := presets.New().DataOperator(gorm2op.DataOperator(TestDB))
PresetsListingCustomizationFields(pb, TestDB)
Expand Down
1 change: 1 addition & 0 deletions docs/docsrc/examples/examples_presets/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func SamplesHandler(mux examples.Muxer) {
db := docsexamples.ExampleDB()
addExample(mux, db, PresetsHelloWorld)
addExample(mux, db, PresetsKeywordSearchOff)
addExample(mux, db, PresetsRowMenuAction)
addExample(mux, db, PresetsListingCustomizationFields)
addExample(mux, db, PresetsListingCustomizationFilters)
addExample(mux, db, PresetsListingCustomizationTabs)
Expand Down
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.7
github.com/qor5/x/v3 v3.0.8
github.com/qor5/x/v3 v3.0.9-0.20240830095515-24fddd1fdf8f
github.com/samber/lo v1.47.0
github.com/shurcooL/sanitized_anchor_name v1.0.0
github.com/spf13/cast v1.6.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ github.com/qor5/web/v3 v3.0.7 h1:1+Ezbl+1m9oZ4S1kcFKybyi6at6qxoY7eJqjb3JETQQ=
github.com/qor5/web/v3 v3.0.7/go.mod h1:32vdHHcZb2JimlcaclW9hLUyimdXjrllZDHTh3rl6d0=
github.com/qor5/x/v3 v3.0.8 h1:orSn34zBSBlAvumWyvmPxjXb8blJ2qGKHZy+8x4Y0gQ=
github.com/qor5/x/v3 v3.0.8/go.mod h1:a+cSXd5UjIOgzhhpvfDxDUdjmKLKeDLeoubcQ9dkxtE=
github.com/qor5/x/v3 v3.0.9-0.20240830065723-63a1ee683f35 h1:S0PNHelYvywRb1gnytDIeU6ICHcpXGK2CYTHSk1HiIY=
github.com/qor5/x/v3 v3.0.9-0.20240830065723-63a1ee683f35/go.mod h1:a+cSXd5UjIOgzhhpvfDxDUdjmKLKeDLeoubcQ9dkxtE=
github.com/qor5/x/v3 v3.0.9-0.20240830095515-24fddd1fdf8f h1:tUAw2vElX+1hHdrzIu+P3H9+BAGnDbXBqI3gPgGNznE=
github.com/qor5/x/v3 v3.0.9-0.20240830095515-24fddd1fdf8f/go.mod h1:a+cSXd5UjIOgzhhpvfDxDUdjmKLKeDLeoubcQ9dkxtE=
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
2 changes: 1 addition & 1 deletion presets/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var Messages_en_US = &Messages{
EditingObjectTitleTemplate: "Editing {modelName} {id}",
ListingObjectTitleTemplate: "Listing {modelName}",
DetailingObjectTitleTemplate: "{modelName} {id}",
FiltersClear: "Clear Filters",
FiltersClear: "Reset",
FiltersAdd: "Add Filters",
FilterApply: "Apply",
FilterByTemplate: "Filter by {filter}",
Expand Down
5 changes: 1 addition & 4 deletions presets/row_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ func (b *RowMenuItemBuilder) getComponentFunc(_ *web.EventContext) vx.RowMenuIte
return nil
}
return VListItem(
web.Slot(
VIcon(b.icon),
).Name("prepend"),

h.If(b.icon != "", web.Slot(VIcon(b.icon)).Name("prepend")),
VListItemTitle(h.Text(i18n.PT(ctx.R, ModelsI18nModuleKey, strcase.ToCamel(b.rmb.mb.label+" RowMenuItem"), b.name))),
).Attr("@click", web.Plaid().
EventFunc(b.eventID).
Expand Down
Loading