jferrandis
8 years agoExpert
batch-processing checkbox in custom components
Hi all I made some custom components on the forum page and blog page to alter the display of the message list. As i use a custom comonent, the standard "batch-processing-checkbox" component non...
- 8 years ago
There's no component for that, you would need to rebuild the logic to check if batchprocessing is enabled or not (rest
/users/id/${user.id}/settings/name/layout.show_batch_checkboxes) and recreate the <input> checkbox element with the correct value (board relative message id and board id, url encoded) and class.
- 8 years ago
Thank you for your help
here is my implementation to help someone else
step 1 : create a macro to get the state of the checkbox
<#macro batchProcessingCheckbox userId> <#assign isCheckBoxActivated = rest("/users/id/${userId}/settings/name/layout.show_batch_checkboxes").value /> </#macro>
Step 2 : create a macro to display the checkbox
<#macro batchProcessingCheckboxUI relativeMessageId boardId isCheckBoxActivated> <input name="bm" type="checkbox" value="${relativeMessageId}%3A${boardId}" title="Sélectionner " class="BatchProcessing <#if !isCheckBoxActivated?boolean>hide</#if> "> </#macro>
Step 3 : in custom component, just include différent calls
<@batchProcessingCheckbox userId=user.id />
in the #list topics as topic bloc of code, include the ui
<@batchProcessingCheckboxUI relativeMessageId=messageRelativeId boardId=message.board.id isCheckBoxActivated=isCheckBoxActivated />
Finally add a little js script at the end of your component to show/hide checkbox on click on the menu
<@liaAddScript> ;(function($){ $('.hide-batch-checkboxes-link').click(function() { $('.BatchProcessing').addClass('hide'); }); $('.show-batch-checkboxes-link').click(function() { $('.BatchProcessing').removeClass("hide"); }); })(LITHIUM.jQuery); </@liaAddScript>