Skip to content

Commit 466d6a8

Browse files
committed
action: add Messages for ajax actionType
1 parent 9c6a40c commit 466d6a8

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

internal/comp/action.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ func (a Action) TransformMultiple(transfor func(schema.Schema) (schema.Schema, e
7070
)
7171
}
7272

73+
// Messages sets the toast messages for the button when the action type is ajax.
74+
// Example:
75+
//
76+
// map[string]string{
77+
// "success": "Operation successful",
78+
// "failed": "Operation failed",
79+
// }
80+
func (a Action) Messages(value map[string]string) Action {
81+
return a.set("messages", value)
82+
}
83+
7384
// ActiveClassName sets the class name for the active state of the button.
7485
func (a Action) ActiveClassName(value string) Action {
7586
return a.set("activeClassName", value)

internal/servemux/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func TransformMultiple(mux *http.ServeMux, src []string, transfor func(schema.Sc
147147
respError(w, err)
148148
return
149149
}
150-
resp := schema.SuccessResponse(" ", output) // " " for empty msg
150+
resp := &schema.Response{Data: output}
151151
w.Write(resp.Json())
152152
})
153153

0 commit comments

Comments
 (0)