-
Notifications
You must be signed in to change notification settings - Fork 59
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
Feature: Row actions #348
Feature: Row actions #348
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #348 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 72 72
Lines 5254 5409 +155
==========================================
+ Hits 5254 5409 +155
☔ View full report in Codecov by Sentry. |
Hello @mrharpo, I would love to hear your thoughts on this as it directly affects your work on #302 what changed (compared to #302 ):
Let me know if you see any issues with this approach! I'm open to suggestions on how to best support the row actions |
It looks great, I took a look at the changes, I can't see any problem at the changes you made. |
@jowilf This looks great! 🚀 The implementation doesn't affect our actions directly, but it might be nice if we could merge the concepts, so a task could be available as a In our case, we need to class ArticleView(ModelView):
...
row_actions = ["view", "edit", "go_to_example", "make_published", "delete"]
batch_actions = ["make_published", "delete"]
@row_action(
name="make_published",
text="Mark as published",
confirmation="Are you sure you want to mark this article as published ?",
confirmation_multiple="Are you sure you want to mark these articles as published ?",
icon_class="fas fa-check-circle",
submit_btn_text="Yes, proceed",
submit_btn_class="btn-success",
action_btn_class="btn-info",
)
async def make_published_row_action(self, request: Request, pk: Any) -> str:
... By including it in We're open to suggestions, especially if there's an easier / better way I'm not seeing. But it's also easy enough for us to include both if it ends up being too complicated, or too much of a breaking change. Again, this is all great, and will work fine for our application. Related (but definitely a separate issue), we've discussed having some kind of Thanks for the heads up! |
I agree with @mrharpo combination of those logic would be good, maybe gets harder to implement but good. Also, I think we shouldn't remove batch actions from the details view, it's a great feature. And also, do we need a link row action? I believe we can annotate the return type and decide the action by inspecting the return type, maybe a redirect response would be enough? Combining these features might seem overwhelming at the beginning but I think in the end, we will gain a lot by configurations. I think we can use a parameter here to point where the action will be available, a list of places maybe? These suggestiona/opinions might be considered in the future, when they become high demand features. For now, it all looks great to me. |
It is possible to use the same method for row actions and batch actions with this simple logic: @action(...)
@row_action(...)
async def make_published_action(self, *args) -> str:
request: Request = args[0]
if isinstance(args[1], list):
pks = args[1]
return "BATCH ACTION"
else:
pk = args[1]
return "ROW ACTION"
|
That's great to see.
You have thought of everything. Nothing else, great job! |
row_actions_display_type = RowActionsDisplayType.ICON_LIST
row_actions_display_type = RowActionsDisplayType.DROPDOWN
detail view