ListView: How to remove delete bulk action?

Goodmorning, how can I remove delete bulk action from a list view??
In the roles, for my module, I remove the permission to delete records and if I go into detail of a record, I haven’t the remove button (this is correct), buut, if I select one or more elements from listview, I have 2 bulk action: export and delete.
How can I remove the delete bulk action?
Thank you so much
B

@bf.ts90
There is in file include/ListView/ListViewDisplay.php this button. I think that you can switch off the button in file include/ListView/ListViewSmarty.php for all users or change condition.

  1. switch off for all - include/ListView/ListViewSmarty.php

from:

    public $delete = true;

to:

    public $delete = false;
  1. change condition - include/ListView/ListViewDisplay.php

from:

            if (
                $this->delete
                && !$this->show_action_dropdown_as_delete
            ) {
                $menuItems[] = $this->buildDeleteLink($location);
            }

to:

            if (
                $this->delete
                && !$this->show_action_dropdown_as_delete 
                && ACLController::checkAccess($this->seed->module_dir, 'delete', true)
            ) {
                $menuItems[] = $this->buildDeleteLink($location);
            }
1 Like

Thank you for your answer. is this solution safe upgrade?

@bf.ts90
No. You should change this after upgrade every time. It’s changing the system file which don’t have in customization area.

Not sure if it works but try this sample. It should be upgrade safe:

Look for this line:
$this->lv->deleted = false;

Thanks,

BrozTechnologies

1 Like

@bf.ts90, I am continue discussing.
@BrozTechnologies, thank you. You make a good offer. May be the next step will be:
custom/include/MVC/View/views/view.list.php
with code:

require_once('include/MVC/View/views/view.list.php');
class CustomViewList extends ViewList{
    public function preDisplay()
    {
        parent::preDisplay();
        $this->lv->delete = false;
    }
}

This code will work for all modules and be safe for upgrade.

2 Likes

Just to point out that if you want to apply it to just one module in particular, file should be included in custom/modules/YourDesiredMODULE/views/view.list.php

BrozTechnologies

2 Likes

Thankyou for your reply.
I use your solution combined with @BrozTechnologies tip and it works fine.

Thank you so much @p.konetskiy and @BrozTechnologies :slight_smile:

1 Like

Teamwork always pays off :+1:

BrozTechnologies

2 Likes

Hi,
For all the user’s Export option not display in Contracts module Listview only admin have option to Export, how i fix this from code level.
Thanks