un-fao / calipseo-shiny

Calipseo is FAO web- based platform for national Fisheries Authorities to streamline management of fisheries data and the production, analysis and reporting of fishery statistics.
1 stars 0 forks source link

[CALR-84] Add select2.js to improve filter dropdown in data.tables #84

Closed eblondel closed 6 months ago

eblondel commented 6 months ago

Issue migrated from JIRA: https://sdlc.review.fao.org/jira/browse/CALR-84 Creator/Reporter: Emmanuel Blondel @eblondel Assignee: Emmanuel Blondel @eblondel Priority: Medium Status: Done Date of creation: 2022-04-13T13:30:26.000+0000

with first application to vessel list.

This may facilitate somehow the fix of a recent regression we have on the filter dropdown feature of DT. Normally, to enable controlled-terms filtering, we have to factorize the columns. With recent work on enabling custom rendering (including html snippets with icon etc) of column values, this stopped working. The fix is particularly complex we can't really use JS renderers, because we need to rely on the output of i18n function which is on R side and not JS side.

This should also recycled/implemented in other modules where needed. cc [~brian.ojok] [~alexandre.bennici@fao.org] for information, other JIRAs will follow on this respect

This ticket is based on https://stackoverflow.com/questions/71035860/make-a-nicer-looking-dropdown-filter-label-with-datatables-dt-in-r

 

 

eblondel commented 6 months ago

Author: Emmanuel Blondel @eblondel Date of creation: 2022-04-15T08:48:56.841+0000 Last update: 2022-04-15T08:48:56.841+0000

[~brian.ojok] [~alexandre.bennici@fao.org] For your information, see how i've implemented this, applied to the vessel list module. The objective was to make possible dropdown filters in the datatable (for each column) together with the rendering of custom html markup within the table cells (with custom color, icon, etc); AND the display of i18n. DT makes possible the display of markup through JS renders, but it would have prevented from using i18n terms (which are not handle at js level but at R level);

The solution designed relies on substituting the default dropdown filters by a new dropdown (that in addition we implement with select2 which improves display).

Look at the vessel_list to understand how it works, as we may have to recycle it elsewhere:

Notes:

If you have questions, let me know

 

 

eblondel commented 6 months ago

Author: Brian Ojok @brianandy Date of creation: 2022-04-15T08:57:17.573+0000 Last update: 2022-04-15T08:57:17.573+0000

[~emmanuel.blondel] thanks for the information