~unifield-team/unifield-web/jfb-utp-732-727

« back to all changes in this revision

Viewing changes to addons/openerp/static/javascript/listgrid.js

  • Committer: jf
  • Date: 2013-08-06 15:55:59 UTC
  • Revision ID: jfb@tempo-consulting.fr-20130806155559-jltviztia3unrray
[IMP] m2m search view: keep selected items between page navigation

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
        this.sort_key = null;
62
62
    },
63
63
 
 
64
    get_previously_selected: function() {
 
65
        var prefix = this.name == '_terp_list' ? '' : this.name + '/';
 
66
        var previous_field = jQuery('[id*="'+prefix + '_terp_previously_selected'+'"]')
 
67
        if (previous_field) {
 
68
            sel = previous_field.val() || "";
 
69
            if (!sel) {return []};
 
70
            return sel.split(',').map(function(b) {return parseInt(b, 10)});
 
71
        }
 
72
        return [];
 
73
    },
 
74
 
 
75
    set_previously_selected: function(value) {
 
76
        var previous = this.get_previously_selected()
 
77
        var prefix = this.name == '_terp_list' ? '' : this.name + '/';
 
78
        for (var v in value) {
 
79
            if (previous.indexOf(value[v]) == -1) {
 
80
                previous.push(value[v])
 
81
            }
 
82
        }
 
83
        field_previously_selected = jQuery('[id*="'+prefix + '_terp_previously_selected'+'"]');
 
84
        if (field_previously_selected) {
 
85
            field_previously_selected.val(previous.join(','));
 
86
        }
 
87
    },
 
88
 
64
89
    checkAll: function(clear) {
65
90
        jQuery('[id="' + this.name + '"] input.grid-record-selector').attr('checked', !clear);
66
91
        this.onBooleanClicked();