View | Details | Raw Unified | Return to bug 30063
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-6 / +14 lines)
Lines 209-222 Link Here
209
        <script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script>
209
        <script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script>
210
    [% END %]
210
    [% END %]
211
    <script>
211
    <script>
212
        let categories = [% To.json(categories) | $raw %];
212
        let categories = [% To.json(categories) | $raw %].map(e => {
213
        let categories_map = categories.reduce((map, c) => {
213
            e['_id'] = e.categorycode;
214
            map[c.categorycode] = c;
214
            e['_str'] = e.description;
215
            return e;
216
        });
217
        let categories_map = categories.reduce((map, e) => {
218
            map[e._id] = e;
215
            return map;
219
            return map;
216
        }, {});
220
        }, {});
217
        let libraries  = [% To.json(libraries) | $raw %];
221
        let libraries  = [% To.json(libraries) | $raw %].map(e => {
218
        let libraries_map = libraries.reduce((map, l) => {
222
            e['_id'] = e.branchcode;
219
            map[l.branchcode] = l;
223
            e['_str'] = e.branchname;
224
            return e;
225
        });
226
        let libraries_map = libraries.reduce((map, e) => {
227
            map[e._id] = e;
220
            return map;
228
            return map;
221
        }, {});
229
        }, {});
222
230
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-29 / +12 lines)
Lines 811-844 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
811
                    if ( $(this).data('filter') ) {
811
                    if ( $(this).data('filter') ) {
812
                        input_type = 'select'
812
                        input_type = 'select'
813
                        let filter_type = $(this).data('filter');
813
                        let filter_type = $(this).data('filter');
814
                        if ( filter_type == 'libraries' ) {
814
                        var existing_search = table_dt.column(i).search();
815
                            var existing_search = table_dt.column(i).search();
815
                        let select = $('<select><option value=""></option></select');
816
                            let select = $('<select><option value=""></option></select');
816
817
817
                        // FIXME eval here is bad and dangerous, how do we workaround that?
818
                            $(libraries).each(function(){
818
                        $(eval(filter_type)).each(function(){
819
                                let o = $('<option value="%s">%s</option>'.format(this.branchcode, this.branchname));
819
                            let o = $('<option value="%s">%s</option>'.format(this._id, this._str));
820
                                if ( existing_search == this.branchcode ) {
820
                            if ( existing_search == this._id ) {
821
                                    o.prop("selected", "selected");
821
                                o.prop("selected", "selected");
822
                                }
822
                            }
823
                                o.appendTo(select);
823
                            o.appendTo(select);
824
                            });
824
                        });
825
                            $(this).html( select );
825
                        $(this).html( select );
826
                        } else if ( filter_type == 'categories' ) {
827
                            var existing_search = table_dt.column(i).search();
828
                            let select = $('<select><option value=""></option></select');
829
830
                            $(categories).each(function(){
831
                                let o = $('<option value="%s">%s</option>'.format(this.categorycode, this.description));
832
                                if ( existing_search == this.categorycode ) {
833
                                    o.prop("selected", "selected");
834
                                }
835
                                o.appendTo(select);
836
                            });
837
                            $(this).html( select );
838
                        } else {
839
                            console.log("Unknown filter " + filter_type);
840
                            return;
841
                        }
842
                    } else {
826
                    } else {
843
                        var title = $(this).text();
827
                        var title = $(this).text();
844
                        var existing_search = table_dt.column(i).search();
828
                        var existing_search = table_dt.column(i).search();
845
- 

Return to bug 30063