I feel like I’m missing something here. Here’s what I’ve got:
// Create the sidebar
$sidebar = ee('CP/Sidebar')->make();
// Add the heading
$header = $sidebar->addHeader(lang('locations'));
// Add list
$list = $header->addFolderList('locations_list');
// Set up the remove url
$list->withRemoveUrl(ee('CP/URL')->make(
'addons/settings/treasury/removeLocation/'
));
// Get locations
$locations = // stuff happens here to get locations
// Loop through the locations
foreach ($locations as $location) {
$item = $list->addItem($location->name, ee('CP/URL')->make(
"addons/settings/treasury/showLocation/{$location->id}"
));
// Set the item identification
$item->identifiedBy($location->id);
// Set up edit url
$item->withEditurl(ee('CP/URL')->make(
"addons/settings/treasury/editLocation/{$location->id}"
));
// Set up the remove confirmation message
$item->withRemoveConfirmation('Deleting this location will not delete the files associated with this location.');
}
That should allow the delete button on items to work as far as I can tell from the documentation. However, the confirmation dialog looks like the image attached to this post. No custom message and does not list the item I am trying to delete. Not encouraging.
Clicking confirm and remove takes me to the method/url I specified in the code above, but the id key in the post data is empty.
Inspecting the delete icon link shows that there is a data-confirm attribute with my custom message, and a data-id attribute with the correct id for the items. So it seems like this thing ought to be working.
Help?
Yikes, this is indeed a little messy. The docs also had me assuming that it would just work, but it looks like we have some js in the places where we use it. Looks we missed a refactor during 3.0 - I’m kinda surprised it hasn’t come up elsewhere. I’ll fix that up for you and make it automatic.
For now, this is the snippet:
$(document).ready(function () {
$('.sidebar .folder-list .remove a.m-link').click(function (e) {
var modalIs = '.' + $(this).attr('rel');
$(modalIs + " .checklist").html(''); // Reset it
$(modalIs + " .checklist").append('<li>' + $(this).data('confirm') + '</li>');
$(modalIs + " input[name='dir_id']").val($(this).data('dir_id'));
e.preventDefault();
})
});
Just replace dir_id
and you’re golden. Thanks for catching it!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.