61
61
this.sort_key = null;
64
get_previously_selected: function() {
65
var prefix = this.name == '_terp_list' ? '' : this.name + '/';
66
var previous_field = jQuery('[id*="'+prefix + '_terp_previously_selected'+'"]')
68
sel = previous_field.val() || "";
69
if (!sel) {return []};
70
return sel.split(',').map(function(b) {return parseInt(b, 10)});
75
update_previously_selected: function(value_arr) {
76
var prefix = this.name == '_terp_list' ? '' : this.name + '/';
77
field_previously_selected = jQuery('[id*="'+prefix + '_terp_previously_selected'+'"]');
78
if (field_previously_selected) {
79
field_previously_selected.val(value_arr.join(','));
80
$('#num_selected').html(value_arr.length);
84
set_previously_selected: function(value) {
85
var previous = this.get_previously_selected()
86
for (var v in value) {
87
if (previous.indexOf(value[v]) == -1) {
88
previous.push(value[v])
91
this.update_previously_selected(previous);
94
add_previously_selected: function(value) {
96
this.set_previously_selected([parseInt(value, 10)]);
100
remove_previously_selected: function(value) {
102
value = parseInt(value, 10);
103
var previous = this.get_previously_selected()
104
var pos = previous.indexOf(value)
106
previous.splice(pos, 1);
107
this.update_previously_selected(previous);
64
112
checkAll: function(clear) {
65
jQuery('[id="' + this.name + '"] input.grid-record-selector').attr('checked', !clear);
114
jQuery('[id="' + this.name + '"] input.grid-record-selector').each(function(){
116
if (clear && jthis.attr('checked')) {
117
self.remove_previously_selected(jthis.val());
118
} else if (!clear && !jthis.attr('checked')) {
119
self.add_previously_selected(jthis.val());
121
jthis.attr('checked', !clear);
66
123
this.onBooleanClicked();
118
175
getSelectedRecords: function() {
119
return this.$getSelectedItems().map(function() {
176
return this.get_previously_selected();
178
/*return this.$getSelectedItems().map(function() {
121
180
return this.value
123
182
var box_id = this.id.split('/');
124
183
return box_id[box_id.length - 1]
129
188
$getSelectedItems: function () {
141
200
onBooleanClicked: function() {
201
if (arguments.length == 2) {
202
var clicked = !arguments[0];
203
var id = arguments[1];
205
this.add_previously_selected(id);
207
this.remove_previously_selected(id);
142
210
var $sidebar = jQuery('.toggle-sidebar');
143
211
if ($sidebar.is('.closed')) {
661
ids = this.getSelectedRecords();
737
ids = this.$getSelectedItems().map(function() {
741
var box_id = this.id.split('/');
742
return box_id[box_id.length - 1]
745
//ids = this.getSelectedRecords();
662
746
if (ids.length > 0) {
663
748
ids = '[' + ids.join(', ') + ']';
667
754
if(ids.length == 0 || !confirm(_('Do you really want to delete selected record(s) ?'))) {
758
$.each(todel, function() {
759
self.remove_previously_selected(this);
739
reload: function(edit_inline, concurrency_info, default_get_ctx, clear) {
830
reload: function(edit_inline, concurrency_info, default_get_ctx, clear, ids_to_show) {
740
831
if (openobject.http.AJAX_COUNT > 0) {
741
832
return callLater(1, bind(this.reload, this), edit_inline, concurrency_info);
773
864
args['_terp_clear'] = true;
868
args['_terp_ids_to_show'] = '['+ids_to_show.join(',')+']';
869
args['_terp_offset'] = 0;
776
871
jQuery(idSelector(self.name) + ' .loading-list').show();
778
873
url: '/openerp/listgrid/get',
829
924
$list.parent().replaceWith(obj.view);
927
var selfname = self.name
928
var has_selected = false;
929
var all_selected = self.getSelectedRecords()
930
$.each(all_selected, function() {
931
var el = jQuery(idSelector(selfname+'/'+this));
934
el.attr('checked', true);
938
jQuery(idSelector(self.name + '_delete_record')).parent().show();
940
if (all_selected.length) {
941
self.selectedRow_sum();
832
943
var $editors = self.$adjustEditors(
833
944
document.getElementById(self.name));
834
945
if ($editors.length > 0) {