英文:
Qor admin disable create button and update selected item
问题
在qor admin中,如何禁用创建按钮并禁用更新选定的项目?我已经尝试过,但我只能在每个记录的操作中隐藏删除按钮。这是我的代码:
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")
请注意,这只是隐藏了删除按钮,如果你想要完全禁用创建和更新功能,你需要进行其他的配置。
英文:
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"
答案1
得分: 0
我已经得到了答案,只需为管理员配置添加自定义权限。
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})
英文:
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})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论