admin
admin copied to clipboard
Modal window with confirmation action
Hello everyone! I am trying to add a modal window with the text "Are you sure you want to perform this action?" add and edit buttons. I just can’t find in the documentation how this function is added. Could you show an example of how to make this modal window. Thanks.
You can use Actions to achieve this functionality. We used it for creating pre-defined cancellation policies with a button. below is the sample code:
cancellationResource.Action(&admin.Action{
Name: "R",
Handler: func(argument *admin.ActionArgument) error {
var db = configuration.GetDB(C.READ)
productId := getIdFromURL(argument.Context.Context)
if len(productId) == 0 {
return errors.New("Some error occurred. Please try after some time")
}
var cpCount int
var expiryDate string
db.Raw(C.GET_CANCELLATION_COUNT, productId).Row().Scan(&cpCount)
if cpCount == 0 {
expiryDate = getProductExpiry(productId)
if len(S.TrimSpace(expiryDate)) == 0 {
expiryDate = time.Now().AddDate(1, 0, 0).Format(C.DATE_YYYY_MM_DD)
}
err := insertCancellationPolicies(expiryDate, productId, 0)
if err != nil {
return err
}
} else {
return errors.New("Policy already exists")
}
return nil
},
Modes: []string{"collection"},
})
Define ur own handler based on ur use case.
@MarcSky