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 819-852 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
819
                    if ( $(this).data('filter') ) {
819
                    if ( $(this).data('filter') ) {
820
                        input_type = 'select'
820
                        input_type = 'select'
821
                        let filter_type = $(this).data('filter');
821
                        let filter_type = $(this).data('filter');
822
                        if ( filter_type == 'libraries' ) {
822
                        var existing_search = table_dt.column(i).search();
823
                            var existing_search = table_dt.column(i).search();
823
                        let select = $('<select><option value=""></option></select');
824
                            let select = $('<select><option value=""></option></select');
824
825
825
                        // FIXME eval here is bad and dangerous, how do we workaround that?
826
                            $(libraries).each(function(){
826
                        $(eval(filter_type)).each(function(){
827
                                let o = $('<option value="%s">%s</option>'.format(this.branchcode, this.branchname));
827
                            let o = $('<option value="%s">%s</option>'.format(this._id, this._str));
828
                                if ( existing_search == this.branchcode ) {
828
                            if ( existing_search == this._id ) {
829
                                    o.prop("selected", "selected");
829
                                o.prop("selected", "selected");
830
                                }
830
                            }
831
                                o.appendTo(select);
831
                            o.appendTo(select);
832
                            });
832
                        });
833
                            $(this).html( select );
833
                        $(this).html( select );
834
                        } else if ( filter_type == 'categories' ) {
835
                            var existing_search = table_dt.column(i).search();
836
                            let select = $('<select><option value=""></option></select');
837
838
                            $(categories).each(function(){
839
                                let o = $('<option value="%s">%s</option>'.format(this.categorycode, this.description));
840
                                if ( existing_search == this.categorycode ) {
841
                                    o.prop("selected", "selected");
842
                                }
843
                                o.appendTo(select);
844
                            });
845
                            $(this).html( select );
846
                        } else {
847
                            console.log("Unknown filter " + filter_type);
848
                            return;
849
                        }
850
                    } else {
834
                    } else {
851
                        var title = $(this).text();
835
                        var title = $(this).text();
852
                        var existing_search = table_dt.column(i).search();
836
                        var existing_search = table_dt.column(i).search();
853
- 

Return to bug 30063