1

In qor admin, how do I disable the create button and disable update the selected item? I've tried, but I can only hide the Delete button in action for each record. Here is my code:

borrowerLog := a.adm.AddResource(&model.BorrowerHistoryLog{}, &admin.Config{Name: "Borrower Log", Menu: []string{"Borrower"}})
borrowerLog.IndexAttrs("-ID")
borrowerLog.Action(&admin.Action{
    Name: "Delete",
    Visible: func(record interface{}, context *admin.Context) bool {
        return false
    },
})

whitelist := a.adm.AddResource(&model.Whitelist{}, &admin.Config{Name: "Whitelist", Menu: []string{"Client"}})
whitelist.IndexAttrs("-ID"
Nat Riddle
  • 928
  • 1
  • 10
  • 24
Angga Suwito
  • 11
  • 1
  • 3

1 Answers1

0

I've got my answer, just add custom permission for the admin config

customPermission := roles.Allow(roles.Read, roles.Anyone).Deny(roles.Create, roles.Anyone).Deny(roles.Update, roles.Anyone).Deny(roles.Delete, roles.Anyone)
borrowerLog := a.adm.AddResource(&model.BorrowerHistoryLog{}, &admin.Config{Name: "Borrower Log", Menu: []string{"Borrower"}, Permission: customPermission})
Angga Suwito
  • 11
  • 1
  • 3