8000 fix detailing plaid by molon · Pull Request #315 · qor5/admin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix detailing plaid #315

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

Merged
merged 3 commits into from
Jul 12, 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: 6 additions & 6 deletions presets/detailing.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
sidePanel: b.sidePanel,
}, obj, ctx)

actionButtons := h.Components()
actionButtons := []h.HTMLComponent{}
for _, ba := range b.actions {
if b.mb.Info().Verifier().SnakeDo(permActions, ba.name).WithReq(ctx.R).IsAllowed() != nil {
continue
Expand All @@ -183,7 +183,7 @@
}

actionButtons = append(actionButtons, VBtn(b.mb.getLabel(ba.NameLabel)).
Color(cmp.Or(ba.buttonColor, ColorPrimary)).Variant(VariantFlat).Class("ml-2").
Color(cmp.Or(ba.buttonColor, ColorPrimary)).Variant(VariantFlat).
Attr("@click", web.Plaid().
EventFunc(actions.Action).
Query(ParamID, id).
Expand Down Expand Up @@ -223,7 +223,7 @@
overlayType := ctx.R.FormValue(ParamOverlay)
closeBtnVarScript := CloseRightDrawerVarScript
if overlayType == actions.Dialog {
closeBtnVarScript = closeDialogVarScript
closeBtnVarScript = CloseDialogVarScript

Check warning on line 226 in presets/detailing.go

View check run for this annotation

Codecov / codecov/patch

presets/detailing.go#L226

Added line #L226 was not covered by tests
}

title := h.Div(h.Text(pr.PageTitle)).Class("d-flex")
Expand Down Expand Up @@ -276,17 +276,17 @@
})
return r, nil
}
web.AppendRunScripts(&r, CloseRightDrawerVarScript)
web.AppendRunScripts(&r, CloseDialogVarScript)
return
}

func (b *DetailingBuilder) formDrawerAction(ctx *web.EventContext) (r web.EventResponse, err error) {
func (b *DetailingBuilder) openActionDialog(ctx *web.EventContext) (r web.EventResponse, err error) {
action := getAction(b.actions, ctx.R.FormValue(ParamAction))
if action == nil {
panic("action required")
}

b.mb.p.rightDrawer(&r, b.actionForm(action, ctx), "")
b.mb.p.dialog(&r, b.actionForm(action, ctx), "")
return
}

Expand Down
4 changes: 2 additions & 2 deletions presets/editing.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@

closeBtnVarScript := CloseRightDrawerVarScript
if overlayType == actions.Dialog {
closeBtnVarScript = closeDialogVarScript
closeBtnVarScript = CloseDialogVarScript

Check warning on line 340 in presets/editing.go

View check run for this annotation

Codecov / codecov/patch

presets/editing.go#L340

Added line #L340 was not covered by tests
}
scope := web.Scope(
notice,
Expand Down Expand Up @@ -472,7 +472,7 @@
overlayType := ctx.R.FormValue(ParamOverlay)
script := CloseRightDrawerVarScript
if overlayType == actions.Dialog {
script = closeDialogVarScript
script = CloseDialogVarScript

Check warning on line 475 in presets/editing.go

View check run for this annotation

Codecov / codecov/patch

presets/editing.go#L475

Added line #L475 was not covered by tests
}
if silent {
script = ""
Expand Down
2 changes: 1 addition & 1 deletion presets/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (mb *ModelBuilder) registerDefaultEventFuncs() {
mb.RegisterEventFunc(actions.Update, mb.editing.defaultUpdate)
mb.RegisterEventFunc(actions.DoDelete, mb.editing.doDelete)

mb.RegisterEventFunc(actions.Action, mb.detailing.formDrawerAction)
mb.RegisterEventFunc(actions.Action, mb.detailing.openActionDialog)
mb.RegisterEventFunc(actions.DoAction, mb.detailing.doAction)
mb.RegisterEventFunc(actions.DetailingDrawer, mb.detailing.showInDrawer)
mb.RegisterEventFunc(actions.DoSaveDetailingField, mb.detailing.SaveDetailField)
Expand Down
2 changes: 1 addition & 1 deletion presets/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ const (

const (
CloseRightDrawerVarScript = "vars.presetsRightDrawer = false"
closeDialogVarScript = "vars.presetsDialog = false"
CloseDialogVarScript = "vars.presetsDialog = false"
CloseListingDialogVarScript = "vars.presetsListingDialog = false"
)

Expand Down
36 changes: 24 additions & 12 deletions presets/section.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (b *SectionBuilder) ListFieldPrefix(index int) string {
}

func (b *SectionBuilder) viewComponent(obj interface{}, field *FieldContext, ctx *web.EventContext) h.HTMLComponent {
id := ctx.Queries().Get(ParamID)
id := ctx.Param(ParamID)
if id == "" {
if slugIf, ok := obj.(SlugEncoder); ok {
id = slugIf.PrimarySlug()
Expand All @@ -383,7 +383,9 @@ func (b *SectionBuilder) viewComponent(obj interface{}, field *FieldContext, ctx
Rounded("0").
Icon("mdi-square-edit-outline").
Attr("v-show", fmt.Sprintf("isHovering&&%t", b.componentEditBtnFunc(obj, ctx))).
Attr("@click", web.Plaid().EventFunc(actions.DoEditDetailingField).
Attr("@click", web.Plaid().
URL(ctx.R.URL.Path).
EventFunc(actions.DoEditDetailingField).
Query(SectionFieldName, b.name).
Query(ParamID, id).
Go())
Expand Down Expand Up @@ -433,15 +435,17 @@ func (b *SectionBuilder) viewComponent(obj interface{}, field *FieldContext, ctx
}

func (b *SectionBuilder) editComponent(obj interface{}, field *FieldContext, ctx *web.EventContext) h.HTMLComponent {
id := ctx.Queries().Get(ParamID)
id := ctx.Param(ParamID)
if id == "" {
if slugIf, ok := obj.(SlugEncoder); ok {
id = slugIf.PrimarySlug()
}
}
btn := VBtn("Save").Size(SizeSmall).Variant(VariantFlat).Color(ColorSecondaryDarken2).
Attr("style", "text-transform: none;").
Attr("@click", web.Plaid().EventFunc(actions.DoSaveDetailingField).
Attr("@click", web.Plaid().
URL(ctx.R.URL.Path).
EventFunc(actions.DoSaveDetailingField).
Query(SectionFieldName, b.name).
Query(ParamID, id).
Go())
Expand Down Expand Up @@ -542,7 +546,7 @@ func (b *SectionBuilder) listComponent(obj interface{}, _ *FieldContext, ctx *we
b.elementEditBtn = b.elementEditBtnFunc(obj, ctx)
}

id := ctx.Queries().Get(ParamID)
id := ctx.Param(ParamID)
if id == "" {
if slugIf, ok := obj.(SlugEncoder); ok {
id = slugIf.PrimarySlug()
Expand Down Expand Up @@ -605,7 +609,9 @@ func (b *SectionBuilder) listComponent(obj interface{}, _ *FieldContext, ctx *we
if !b.disableElementCreateBtn {
addBtn := VBtn("Add Row").PrependIcon("mdi-plus-circle").Color("primary").Variant(VariantText).
Class("mb-2").
Attr("@click", web.Plaid().EventFunc(actions.DoCreateDetailingListField).
Attr("@click", web.Plaid().
URL(ctx.R.URL.Path).
EventFunc(actions.DoCreateDetailingListField).
Query(SectionFieldName, b.name).
Query(ParamID, id).
Go())
Expand Down Expand Up @@ -657,9 +663,11 @@ func (b *SectionBuilder) showElement(obj any, index int, ctx *web.EventContext)
Rounded("0").
Icon("mdi-square-edit-outline").
Attr("v-show", fmt.Sprintf("isHovering&&%t", b.elementEditBtn)).
Attr("@click", web.Plaid().EventFunc(actions.DoEditDetailingListField).
Attr("@click", web.Plaid().
URL(ctx.R.URL.Path).
EventFunc(actions.DoEditDetailingListField).
Query(SectionFieldName, b.name).
Query(ParamID, ctx.Queries().Get(ParamID)).
Query(ParamID, ctx.Param(ParamID)).
Query(b.EditBtnKey(), strconv.Itoa(index)).
Go())

Expand Down Expand Up @@ -693,9 +701,11 @@ func (b *SectionBuilder) editElement(obj any, index, _ int, ctx *web.EventContex
Rounded("0").
Icon("mdi-delete-outline").
Attr("v-show", fmt.Sprintf("%t", !b.disableElementDeleteBtn)).
Attr("@click", web.Plaid().EventFunc(actions.DoDeleteDetailingListField).
Attr("@click", web.Plaid().
URL(ctx.R.URL.Path).
EventFunc(actions.DoDeleteDetailingListField).
Query(SectionFieldName, b.name).
Query(ParamID, ctx.Queries().Get(ParamID)).
Query(ParamID, ctx.Param(ParamID)).
Query(b.DeleteBtnKey(), index).
Go())

Expand All @@ -713,9 +723,11 @@ func (b *SectionBuilder) editElement(obj any, index, _ int, ctx *web.EventContex

saveBtn := VBtn("Save").Size(SizeSmall).Variant(VariantFlat).Color(ColorSecondaryDarken2).
Attr("style", "text-transform: none;").
Attr("@click", web.Plaid().EventFunc(actions.DoSaveDetailingListField).
Attr("@click", web.Plaid().
URL(ctx.R.URL.Path).
EventFunc(actions.DoSaveDetailingListField).
Query(SectionFieldName, b.name).
Query(ParamID, ctx.Queries().Get(ParamID)).
Query(ParamID, ctx.Param(ParamID)).
Query(b.SaveBtnKey(), strconv.Itoa(index)).
Go())

Expand Down
Loading
0