Bugzilla – Attachment 149162 Details for
Bug 33066
We need a KohaTable Vue component
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33066: Reintroduce column filters
Bug-33066-Reintroduce-column-filters.patch (text/plain), 6.77 KB, created by
Jonathan Druart
on 2023-04-05 07:22:01 UTC
(
hide
)
Description:
Bug 33066: Reintroduce column filters
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-04-05 07:22:01 UTC
Size:
6.77 KB
patch
obsolete
>From f8a122be5ac71ff4e1376929b956199608865939 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 7 Mar 2023 15:02:25 +0100 >Subject: [PATCH] Bug 33066: Reintroduce column filters >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> > >Signed-off-by: AgustÃn Moyano <agustinmoyano@theke.io> >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 13 ++++-- > .../js/vue/components/ERM/AgreementsList.vue | 41 ++++++++++--------- > .../prog/js/vue/components/KohaTable.vue | 6 ++- > 3 files changed, 35 insertions(+), 25 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 689fc4307cd..bcf308c56c3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -822,7 +822,7 @@ function _dt_on_visibility(add_filters, table_node, table_dt){ > } > } > >-function _dt_add_filters(table_node, table_dt) { >+function _dt_add_filters(table_node, table_dt, filters_options = {}) { > $(table_node).find('thead tr').clone().appendTo( $(table_node).find('thead') ); > > $(table_node).find('thead tr:eq(1) th').each( function (i) { >@@ -831,14 +831,19 @@ function _dt_add_filters(table_node, table_dt) { > $(this).data('th-id', i); > if ( is_searchable ) { > let input_type = 'input'; >- if ( $(this).data('filter') ) { >+ if ( $(this).data('filter') || filters_options.hasOwnProperty(i)) { > input_type = 'select' > let filter_type = $(this).data('filter'); >- var existing_search = table_dt.column(i).search(); >+ let existing_search = table_dt.column(i).search(); > let select = $('<select><option value=""></option></select'); > > // FIXME eval here is bad and dangerous, how do we workaround that? >- $(eval(filter_type)).each(function(){ >+ if ( !filters_options.hasOwnProperty(i) ) { >+ filters_options[i] = eval(filter_type) >+ } else if ( typeof filters_options[i] === "function" ) { >+ filters_options[i] = filters_options[i]() >+ } >+ $(filters_options[i]).each(function(){ > let o = $('<option value="%s">%s</option>'.format(this._id, this._str)); > if ( existing_search === this._id ) { > o.prop("selected", "selected"); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >index 1d4bf59235e..752d175f972 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue >@@ -98,6 +98,25 @@ export default { > url: () => this.table_url(), > table_settings: this.agreement_table_settings, > add_filters: true, >+ filters_options: { >+ 1: () => >+ this.vendors.map(e => { >+ e["_id"] = e["id"] >+ e["_str"] = e["name"] >+ return e >+ }), >+ 3: () => this.map_av_dt_filter("av_agreement_statuses"), >+ 4: () => >+ this.map_av_dt_filter("av_agreement_closure_reasons"), >+ 5: [ >+ { _id: 0, _str: _("No") }, >+ { _id: 1, _str: _("Yes") }, >+ ], >+ 6: () => >+ this.map_av_dt_filter( >+ "av_agreement_renewal_priorities" >+ ), >+ }, > actions: { > 0: ["show"], > "-1": ["edit", "delete"], >@@ -110,7 +129,7 @@ export default { > vm.before_route_entered = true // FIXME This is ugly, but we need to distinguish when it's used as main component or child component (from EHoldingsEBSCOPAckagesShow for instance) > if (!vm.building_table) { > vm.building_table = true >- vm.getAgreementCount().then(() => vm.initialized = true) >+ vm.getAgreementCount().then(() => (vm.initialized = true)) > } > }) > }, >@@ -491,29 +510,11 @@ export default { > getTableColumns: function () { > let get_lib_from_av = this.get_lib_from_av > let escape_str = this.escape_str >- window["vendors"] = this.vendors.map(e => { >- e["_id"] = e["id"] >- e["_str"] = e["name"] >- return e >- }) > let vendors_map = this.vendors.reduce((map, e) => { > map[e.id] = e > return map > }, {}) >- let avs = [ >- "av_agreement_statuses", >- "av_agreement_closure_reasons", >- "av_agreement_renewal_priorities", >- ] >- let c = this >- avs.forEach(function (av_cat) { >- window[av_cat] = c.map_av_dt_filter(av_cat) >- }) > >- window["av_agreement_is_perpetual"] = [ >- { _id: 0, _str: _("No") }, >- { _id: 1, _str: _("Yes") }, >- ] > return [ > { > title: __("Name"), >@@ -536,7 +537,7 @@ export default { > orderable: true, > render: function (data, type, row, meta) { > return row.vendor_id != undefined >- ? escape_str(vendors_map[row.vendor_id].name) >+ ? row.vendor_id //escape_str(vendors_map[row.vendor_id].name) > : "" > }, > }, >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue >index e334c405fce..2e0173e1a2f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue >@@ -120,7 +120,7 @@ export default { > let dt = this.$refs.table.dt() > let table_node = dt.table().node() > if (this.add_filters) { >- _dt_add_filters(table_node, dt) >+ _dt_add_filters(table_node, dt, this.filters_options) > } > > dt.on("column-visibility.dt", function () { >@@ -189,6 +189,10 @@ export default { > type: Boolean, > required: false, > }, >+ filters_options: { >+ type: Object, >+ required: false, >+ }, > }, > } > </script> >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33066
:
147352
|
147353
|
147354
|
147692
|
147693
|
147694
|
147713
|
147846
|
147847
|
147848
|
147849
|
147850
|
147851
|
147852
|
147853
|
147855
|
147856
|
147857
|
147858
|
147862
|
147865
|
147902
|
147903
|
147904
|
147905
|
147906
|
147907
|
147908
|
147909
|
147910
|
147911
|
147912
|
147913
|
147914
|
147915
|
147916
|
147917
|
147918
|
147921
|
147922
|
147923
|
147925
|
147926
|
147928
|
147957
|
147960
|
147971
|
147972
|
148718
|
149158
|
149159
|
149160
|
149161
| 149162 |
149163
|
149164
|
149165
|
149166
|
149167
|
149168
|
149169
|
149170
|
149171
|
149172
|
149173
|
149174
|
149175
|
149176
|
149177
|
149178
|
149179
|
149180
|
149181
|
149182
|
149183