Block Designer Pro Repeatable Fields, Collapse All Button
Permalink
Ramon Leenders Block Designer Pro add on is indispensable (https://www.concrete5.org/marketplace/addons/block-designer-pro). He built in the ability to collapse repeatable field groups in order to better drag them into ordered positions.
I've always wanted a Collapse All button, so today I actually did it. This is what I did, you can probably think of a better way, or tell me if I did something wrong. But it works sweetly.
In the auto.js file of the custom block folder, I found the section dealing with the collapse (this).parent() and duplicated it, and modified as so:
Then, I edited my form.php for the block, and found the two places where the "Add Entry" buttons are, and placed this below those:
And that's a wrap! Gonna do this to all my blocks like this here out, but perhaps Ramon will find this and build it into future versions.
I've always wanted a Collapse All button, so today I actually did it. This is what I did, you can probably think of a better way, or tell me if I did something wrong. But it works sweetly.
In the auto.js file of the custom block folder, I found the section dealing with the collapse (this).parent() and duplicated it, and modified as so:
// add a collapse all button -tdd $(container).on('click', '.sortable-item-collapse-all', function (e) { e.preventDefault(); var sortableItem = $('.sortable-item'); if (!$(sortableItem).hasClass('collapsed')) { $(sortableItem).addClass('collapsed'); } else { $(sortableItem).removeClass('collapsed'); } });
Then, I edited my form.php for the block, and found the two places where the "Add Entry" buttons are, and placed this below those:
<?php // add a collapse all button TDD ?> <a href="#" class="btn btn-warning sortable-item-collapse-all">Collapse All</a>
And that's a wrap! Gonna do this to all my blocks like this here out, but perhaps Ramon will find this and build it into future versions.
You could use the addons support page to make him aware, (Mark it as a Discussion)
https://www.concrete5.org/marketplace/addons/block-designer-pro/supp...
A good 'How To', well done and thanks for sharing this with the community.