Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
It would be nice to clear out contact message entities in bulk.
Proposed resolution
Maybe alter/change the views data handler for Message.
Remaining tasks
?
User interface changes
Yes, add some bulk ops to default view.
API changes
Views data handler changes.
Data model changes
Default view gets bulk ops.
Comment | File | Size | Author |
---|---|---|---|
#33 | interdiff-2693281-30-33.txt | 897 bytes | naveenvalecha |
#33 | 2693281-33.patch | 22.35 KB | naveenvalecha |
|
Comments
Comment #2
Bambell CreditAttribution: Bambell at MD Systems GmbH commentedThat's a use case I encountered today, so I definitely agree. That's not so trivial, but I believe the best approach to this would be to add a "SELECT" column to the tables containing the forms / messages with a checkbox for each entity and a "Delete selected" button as well as a "Select all" button. A "Display per page" dropdown menu to select how many elements to display per page with an "All" option would also be needed.
Comment #3
BerdirThe bulk operations support is generic in views.
To get it for an entity type, all you need is to have actions (action plugin + action config entity). See how node.module defines the delete action plugin and the config entity for it. Define those, re-install the module and you should be able to add that to the view.
Comment #4
larowlanComment #5
naveenvalechagive it a shot.
Questions :
1. will we make contact_form entity translatable ? any existing issue for it ? The translations has been taken care in DeleteMultiple message form as I have borrowed the code from DeleteMultiple node action form ?
2. What other actions do we need ?
Pending items :
1. Do we need the hook_post_update_NAME for views changes ?
2. Need tests.
The code is workable and it can be tested.
Comment #6
naveenvalechalet' s give the candy to testbot :)
Comment #7
naveenvalechaComment #8
naveenvalechaN/W for #5
Comment #9
jibranRe #5 Questions:
Re #5 Pending Items:
I think we should not add this action to current view to avoid upgrade path hassle for view. Just add the default action and enable it in update hook so that it'll be available as views field.
Comment #10
naveenvalecha#9
1. Addressed, remove the translatable code from message deletion form.
2. Okay Thanks!
#5 Pending Items are still left. Leaving this open for others to pickup to work the pending stuff.I'll probably get back on this on tuesday.
Comment #11
naveenvalechaComment #12
larowlanLooking great, just some minor observations.
Only thing missing is some tests.
We need to add this to our follow-up (in the queue around adding more permissions). Because deleting shouldn't need the uber-permission.
We can inject the current user service too
Nit: we could put this in a protected method to isolate it for when it gets deprecated.
Comment #13
naveenvalechaAddressed #12.2, #12.3
#12.1, For permissions I'm working on a sandbox project here https://www.drupal.org/sandbox/naveenvalecha/2725179 I'll take care in the patch.
Addressed #5.2 Added tests
#5.1 can you elaborate little bit more.Do you mean to add/create the action config entity in hook_update ?
Comment #15
naveenvalechaComment #17
jibranNice work @naveenvalecha.
Let's make this an update hook and add the action to active config.
Something like this
Should it be named system.action or contact_storage.action?
I think this can be just Url object no need to convert it to string.
I think content logger is not correct logging service here.
Can we add a quick assert about this as well in the test?
Comment #18
naveenvalecha#17.1
Added Thanks!
#17.2
It would be the system.action
#17.3
it should be string see https://github.com/symfony/http-foundation/blob/master/RedirectResponse....
#17.4
Used the contact logger.
#17.5
Added
Comment #19
jibranThis is ready imo. Thanks @naveenvalecha for addressing the feedback.
Comment #20
andypostJust minor nits, could be fixed on commit
inconsistency
could be oneliner
Comment #21
naveenvalechaFixed nits mentioned in #20
Also fixed some of the docs.
Comment #23
naveenvalechaComment #24
andypostNow looks great for me! Thanx a lot @naveenvalecha
Comment #25
jibranWe need an uninstall hook to remove this from active storage as well.
Comment #26
BerdirNo need for uninstall hook, just add an enforced config dependency on this module so it gets removed automatically.
http://drupal.stackexchange.com/questions/195173/delete-a-content-type-p... (works for all config entities)
Comment #27
naveenvalechanice!, Enforced config dependency in system.action.message_delete_action
Comment #28
jibranIn my experience this doesn't work all the time. Can we add a test to verify that it really works?
Comment #29
Berdirthis is not an enforced dependency, it is a normal dependency. See the example I linked. You don't want to touch what is added automatically but add yours in enforced.
Comment #30
naveenvalechareverted previous change in #27.
Addressed #29
#28,
I have seen at couple of places in core about the enforced config removal.
Comment #31
andypostaction defined in contact_storage module so why it depends on contact?
The enforced here is only for reason to uninstall this config when module uninstalled
contact_storage already depends on contact and views so I suppose they are not needed
Comment #32
naveenvalecha#31.1 Moved the action dependency to contact_storage.
#31.2 yup, agree accommodated the changes accordingly.
Comment #33
naveenvalechaignore previous patch.
Comment #34
andypostNow looks ready
Comment #35
andypostComment #36
larowlanFixed, thanks - rerolled on commit
Comment #39
HongPong CreditAttribution: HongPong as a volunteer and at kor group commentedHow to delete multiple form submissions? VBO isn't available on D8 and I can't spot on documentation. Ah.. it's a view.
To this guy: /admin/structure/views/view/contact_messages
add field:
Contact message: Message operations bulk form (Message operations bulk form)
And save. Works. Becomes available as checkbox and a delete dropdown just as needed. Should probably get on the readme.