-
Notifications
You must be signed in to change notification settings - Fork 23.1k
/
list_renderer.js
784 lines (759 loc) · 28 KB
/
list_renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
odoo.define('web.ListRenderer', function (require) {
"use strict";
var BasicRenderer = require('web.BasicRenderer');
var config = require('web.config');
var core = require('web.core');
var Dialog = require('web.Dialog');
var dom = require('web.dom');
var field_utils = require('web.field_utils');
var Pager = require('web.Pager');
var utils = require('web.utils');
var _t = core._t;
// Allowed decoration on the list's rows: bold, italic and bootstrap semantics classes
var DECORATIONS = [
'decoration-bf',
'decoration-it',
'decoration-danger',
'decoration-info',
'decoration-muted',
'decoration-primary',
'decoration-success',
'decoration-warning'
];
var FIELD_CLASSES = {
float: 'o_list_number',
integer: 'o_list_number',
monetary: 'o_list_number',
text: 'o_list_text',
};
var ListRenderer = BasicRenderer.extend({
events: {
'click tbody tr': '_onRowClicked',
'click tbody .o_list_record_selector': '_onSelectRecord',
'click thead th.o_column_sortable': '_onSortColumn',
'click .o_group_header': '_onToggleGroup',
'click thead .o_list_record_selector input': '_onToggleSelection',
},
/**
* @constructor
* @param {Widget} parent
* @param {any} state
* @param {Object} params
* @param {boolean} params.hasSelectors
*/
init: function (parent, state, params) {
this._super.apply(this, arguments);
this.hasHandle = false;
this.handleField = 'sequence';
this._processColumns(params.columnInvisibleFields || {});
this.rowDecorations = _.chain(this.arch.attrs)
.pick(function (value, key) {
return DECORATIONS.indexOf(key) >= 0;
}).mapObject(function (value) {
return py.parse(py.tokenize(value));
}).value();
this.hasSelectors = params.hasSelectors;
this.selection = params.selectedRecords || [];
this.pagers = []; // instantiated pagers (only for grouped lists)
this.editable = params.editable;
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* @override
*/
updateState: function (state, params) {
this._processColumns(params.columnInvisibleFields || {});
if (params.selectedRecords) {
this.selection = params.selectedRecords;
}
return this._super.apply(this, arguments);
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* This method does a in-memory computation of the aggregate values, for
* each columns that corresponds to a numeric field with a proper aggregate
* function.
*
* The result of these computations is stored in the 'aggregate' key of each
* column of this.columns. This will be then used by the _renderFooter
* method to display the appropriate amount.
*
* @private
*/
_computeAggregates: function () {
var self = this;
var data = [];
if (this.selection.length) {
utils.traverse_records(this.state, function (record) {
if (_.contains(self.selection, record.id)) {
data.push(record); // find selected records
}
});
} else {
data = this.state.data;
}
_.each(this.columns, this._computeColumnAggregates.bind(this, data));
},
/**
* Compute the aggregate values for a given column and a set of records.
* The aggregate values are then written, if applicable, in the 'aggregate'
* key of the column object.
*
* @private
* @param {Object[]} data a list of selected/all records
* @param {Object} column
*/
_computeColumnAggregates: function (data, column) {
var attrs = column.attrs;
var field = this.state.fields[attrs.name];
if (!field) {
return;
}
var type = field.type;
if (type !== 'integer' && type !== 'float' && type !== 'monetary') {
return;
}
var func = (attrs.sum && 'sum') || (attrs.avg && 'avg') ||
(attrs.max && 'max') || (attrs.min && 'min');
if (func) {
var count = 0;
var aggregateValue = (func === 'max') ? -Infinity : (func === 'min') ? Infinity : 0;
_.each(data, function (d) {
count += 1;
var value = (d.type === 'record') ? d.data[attrs.name] : d.aggregateValues[attrs.name];
if (func === 'avg') {
aggregateValue += value;
} else if (func === 'sum') {
aggregateValue += value;
} else if (func === 'max') {
aggregateValue = Math.max(aggregateValue, value);
} else if (func === 'min') {
aggregateValue = Math.min(aggregateValue, value);
}
});
if (func === 'avg') {
aggregateValue = count ? aggregateValue / count : aggregateValue;
}
column.aggregate = {
help: attrs[func],
value: aggregateValue,
};
}
},
/**
* return the number of visible columns. Note that this number depends on
* the state of the renderer. For example, in editable mode, it could be
* one more that in non editable mode, because there may be a visible 'trash
* icon'.
*
* @private
* @returns {integer}
*/
_getNumberOfCols: function () {
var n = this.columns.length;
return this.hasSelectors ? n+1 : n;
},
/**
* Removes the columns which should be invisible.
*
* @param {Object} columnInvisibleFields contains the column invisible modifier values
*/
_processColumns: function (columnInvisibleFields) {
var self = this;
self.hasHandle = false;
self.handleField = null;
this.columns = _.reject(this.arch.children, function (c) {
var reject = c.attrs.modifiers.column_invisible;
// If there is an evaluated domain for the field we override the node
// attribute to have the evaluated modifier value.
if (c.attrs.name in columnInvisibleFields) {
reject = columnInvisibleFields[c.attrs.name];
}
if (!reject && c.attrs.widget === 'handle') {
self.handleField = c.attrs.name;
}
return reject;
});
},
/**
* Render a list of <td>, with aggregates if available. It can be displayed
* in the footer, or for each open groups.
*
* @private
* @param {any} aggregateValues
* @returns {jQueryElement[]} a list of <td> with the aggregate values
*/
_renderAggregateCells: function (aggregateValues) {
var self = this;
return _.map(this.columns, function (column) {
var $cell = $('<td>');
if (column.attrs.name in aggregateValues) {
var field = self.state.fields[column.attrs.name];
var value = aggregateValues[column.attrs.name].value;
var help = aggregateValues[column.attrs.name].help;
var formatFunc = field_utils.format[column.attrs.widget];
if (!formatFunc) {
formatFunc = field_utils.format[field.type];
}
var formattedValue = formatFunc(value, field, {escape: true});
$cell.addClass('o_list_number').attr('title', help).html(formattedValue);
}
return $cell;
});
},
/**
* Render the main body of the table, with all its content. Note that it
* has been decided to always render at least 4 rows, even if we have less
* data. The reason is that lists with 0 or 1 lines don't really look like
* a table.
*
* @private
* @returns {jQueryElement} a jquery element <tbody>
*/
_renderBody: function () {
var $rows = this._renderRows();
while ($rows.length < 4) {
$rows.push(this._renderEmptyRow());
}
return $('<tbody>').append($rows);
},
/**
* Render a cell for the table. For most cells, we only want to display the
* formatted value, with some appropriate css class. However, when the
* node was explicitely defined with a 'widget' attribute, then we
* instantiate the corresponding widget.
*
* @private
* @param {Object} record
* @param {Object} node
* @param {integer} colIndex
* @param {Object} [options]
* @param {Object} [options.mode]
* @param {Object} [options.renderInvisible=false]
* force the rendering of invisible cell content
* @param {Object} [options.renderWidgets=false]
* force the rendering of the cell value thanks to a widget
* @returns {jQueryElement} a <td> element
*/
_renderBodyCell: function (record, node, colIndex, options) {
var tdClassName = 'o_data_cell';
if (node.tag === 'button') {
tdClassName += ' o_list_button';
} else if (node.tag === 'field') {
var typeClass = FIELD_CLASSES[this.state.fields[node.attrs.name].type];
if (typeClass) {
tdClassName += (' ' + typeClass);
}
if (node.attrs.widget) {
tdClassName += (' o_' + node.attrs.widget + '_cell');
}
}
var $td = $('<td>', {class: tdClassName});
// We register modifiers on the <td> element so that it gets the correct
// modifiers classes (for styling)
var modifiers = this._registerModifiers(node, record, $td, _.pick(options, 'mode'));
// If the invisible modifiers is true, the <td> element is left empty.
// Indeed, if the modifiers was to change the whole cell would be
// rerendered anyway.
if (modifiers.invisible && !(options && options.renderInvisible)) {
return $td;
}
if (node.tag === 'button') {
return $td.append(this._renderButton(record, node));
} else if (node.tag === 'widget') {
return $td.append(this._renderWidget(record, node));
}
if (node.attrs.widget || (options && options.renderWidgets)) {
var widget = this._renderFieldWidget(node, record, _.pick(options, 'mode'));
this._handleAttributes(widget.$el, node);
return $td.append(widget.$el);
}
var name = node.attrs.name;
var field = this.state.fields[name];
var value = record.data[name];
var formattedValue = field_utils.format[field.type](value, field, {
data: record.data,
escape: true,
isPassword: 'password' in node.attrs,
});
this._handleAttributes($td, node);
return $td.html(formattedValue);
},
/**
* Renders the button element associated to the given node and record.
*
* @private
* @param {Object} record
* @param {Object} node
* @returns {jQuery} a <button> element
*/
_renderButton: function (record, node) {
var $button = $('<button>', {
type: 'button',
title: node.attrs.string,
});
if (node.attrs.icon) {
$button.addClass('o_icon_button');
$button.append($('<i>', {class: 'fa ' + node.attrs.icon}));
} else {
$button.text(node.attrs.string);
}
this._handleAttributes($button, node);
this._registerModifiers(node, record, $button);
if (record.res_id) {
// TODO this should be moved to a handler
var self = this;
$button.on("click", function (e) {
e.stopPropagation();
self.trigger_up('button_clicked', {
attrs: node.attrs,
record: record,
});
});
} else {
if (node.attrs.options.warn) {
var self = this;
$button.on("click", function (e) {
e.stopPropagation();
self.do_warn(_t("Warning"), _t('Please click on the "save" button first'));
});
} else {
$button.prop('disabled', true);
}
}
return $button;
},
/**
* Render a complete empty row. This is used to fill in the blanks when we
* have less than 4 lines to display.
*
* @private
* @returns {jQueryElement} a <tr> element
*/
_renderEmptyRow: function () {
var $td = $('<td> </td>').attr('colspan', this._getNumberOfCols());
return $('<tr>').append($td);
},
/**
* Render the footer. It is a <tfoot> with a single row, containing all
* aggregates, if applicable.
*
* @private
* @param {boolean} isGrouped if the view is grouped, we have to add an
* extra <td>
* @returns {jQueryElement} a <tfoot> element
*/
_renderFooter: function (isGrouped) {
var aggregates = {};
_.each(this.columns, function (column) {
if ('aggregate' in column) {
aggregates[column.attrs.name] = column.aggregate;
}
});
var $cells = this._renderAggregateCells(aggregates);
if (isGrouped) {
$cells.unshift($('<td>'));
}
if (this.hasSelectors) {
$cells.unshift($('<td>'));
}
return $('<tfoot>').append($('<tr>').append($cells));
},
/**
* Renders the pager for a given group
*
* @private
* @param {Object} group
* @returns {JQueryElement} the pager's $el
*/
_renderGroupPager: function (group) {
var pager = new Pager(this, group.count, group.offset + 1, group.limit);
pager.on('pager_changed', this, function (newState) {
var self = this;
pager.disable();
this.trigger_up('load', {
id: group.id,
limit: newState.limit,
offset: newState.current_min - 1,
on_success: function (reloadedGroup) {
_.extend(group, reloadedGroup);
self._renderView();
},
on_fail: pager.enable.bind(pager),
});
});
// register the pager so that it can be destroyed on next rendering
this.pagers.push(pager);
var fragment = document.createDocumentFragment();
pager.appendTo(fragment); // starts the pager
return pager.$el;
},
/**
* Render the row that represent a group
*
* @private
* @param {Object} group
* @param {integer} groupLevel the nesting level (0 for root groups)
* @returns {jQueryElement} a <tr> element
*/
_renderGroupRow: function (group, groupLevel) {
var aggregateValues = _.mapObject(group.aggregateValues, function (value) {
return { value: value };
});
var $cells = this._renderAggregateCells(aggregateValues);
if (this.hasSelectors) {
$cells.unshift($('<td>'));
}
var name = group.value === undefined ? _t('Undefined') : group.value;
var groupBy = this.state.groupedBy[groupLevel];
if (group.fields[groupBy.split(':')[0]].type !== 'boolean') {
name = name || _t('Undefined');
}
var $th = $('<th>')
.addClass('o_group_name')
.text(name + ' (' + group.count + ')');
var $arrow = $('<span>')
.css('padding-left', (groupLevel * 20) + 'px')
.css('padding-right', '5px')
.addClass('fa');
if (group.count > 0) {
$arrow.toggleClass('fa-caret-right', !group.isOpen)
.toggleClass('fa-caret-down', group.isOpen);
}
$th.prepend($arrow);
if (group.isOpen && !group.groupedBy.length && (group.count > group.data.length)) {
var $pager = this._renderGroupPager(group);
var $lastCell = $cells[$cells.length-1];
$lastCell.addClass('o_group_pager').append($pager);
}
return $('<tr>')
.addClass('o_group_header')
.toggleClass('o_group_open', group.isOpen)
.toggleClass('o_group_has_content', group.count > 0)
.data('group', group)
.append($th)
.append($cells);
},
/**
* Render all groups in the view. We assume that the view is in grouped
* mode.
*
* Note that each group is rendered inside a <tbody>, which contains a group
* row, then possibly a bunch of rows for each record.
*
* @private
* @param {Object} data the dataPoint containing the groups
* @param {integer} [groupLevel=0] the nesting level. 0 is for the root group
* @returns {jQueryElement[]} a list of <tbody>
*/
_renderGroups: function (data, groupLevel) {
var self = this;
groupLevel = groupLevel || 0;
var result = [];
var $tbody = $('<tbody>');
_.each(data, function (group) {
if (!$tbody) {
$tbody = $('<tbody>');
}
$tbody.append(self._renderGroupRow(group, groupLevel));
if (group.data.length) {
result.push($tbody);
// render an opened group
if (group.groupedBy.length) {
// the opened group contains subgroups
result = result.concat(self._renderGroups(group.data, groupLevel + 1));
} else {
// the opened group contains records
var $records = _.map(group.data, function (record) {
return self._renderRow(record).prepend($('<td>'));
});
result.push($('<tbody>').append($records));
}
$tbody = null;
}
});
if ($tbody) {
result.push($tbody);
}
return result;
},
/**
* Render the main header for the list view. It is basically just a <thead>
* with the name of each fields
*
* @private
* @param {boolean} isGrouped
* @returns {jQueryElement} a <thead> element
*/
_renderHeader: function (isGrouped) {
var $tr = $('<tr>')
.append(_.map(this.columns, this._renderHeaderCell.bind(this)));
if (this.hasSelectors) {
$tr.prepend(this._renderSelector('th'));
}
if (isGrouped) {
$tr.prepend($('<th>').html(' '));
}
return $('<thead>').append($tr);
},
/**
* Render a single <th> with the informations for a column. If it is not a
* field, the th will be empty. Otherwise, it will contains all relevant
* information for the field.
*
* @private
* @param {Object} node
* @returns {jQueryElement} a <th> element
*/
_renderHeaderCell: function (node) {
var name = node.attrs.name;
var order = this.state.orderedBy;
var isNodeSorted = order[0] && order[0].name === name;
var field = this.state.fields[name];
var $th = $('<th>');
if (!field) {
return $th;
}
var description;
if (node.attrs.widget) {
description = this.state.fieldsInfo.list[name].Widget.prototype.description;
}
if (description === undefined) {
description = node.attrs.string || field.string;
}
$th
.text(description)
.data('name', name)
.toggleClass('o-sort-down', isNodeSorted ? !order[0].asc : false)
.toggleClass('o-sort-up', isNodeSorted ? order[0].asc : false)
.addClass(field.sortable && 'o_column_sortable');
if (field.type === 'float' || field.type === 'integer' || field.type === 'monetary') {
$th.css({textAlign: 'right'});
}
if (config.debug) {
var fieldDescr = {
field: field,
name: name,
string: description || name,
record: this.state,
attrs: node.attrs,
};
this._addFieldTooltip(fieldDescr, $th);
}
return $th;
},
/**
* Render a row, corresponding to a record.
*
* @private
* @param {Object} record
* @returns {jQueryElement} a <tr> element
*/
_renderRow: function (record) {
var self = this;
this.defs = []; // TODO maybe wait for those somewhere ?
var $cells = _.map(this.columns, function (node, index) {
return self._renderBodyCell(record, node, index, {mode: 'readonly'});
});
delete this.defs;
var $tr = $('<tr/>', {class: 'o_data_row'})
.data('id', record.id)
.append($cells);
if (this.hasSelectors) {
$tr.prepend(this._renderSelector('td', !record.res_id));
}
this._setDecorationClasses(record, $tr);
return $tr;
},
/**
* Render all rows. This method should only called when the view is not
* grouped.
*
* @private
* @returns {jQueryElement[]} a list of <tr>
*/
_renderRows: function () {
return _.map(this.state.data, this._renderRow.bind(this));
},
/**
* A 'selector' is the small checkbox on the left of a record in a list
* view. This is rendered as an input inside a div, so we can properly
* style it.
*
* Note that it takes a tag in argument, because selectors in the header
* are renderd in a th, and those in the tbody are in a td.
*
* @private
* @param {string} tag either th or td
* @param {boolean} disableInput if true, the input generated will be disabled
* @returns {jQueryElement}
*/
_renderSelector: function (tag, disableInput) {
var $content = dom.renderCheckbox();
if (disableInput) {
$content.find("input[type='checkbox']").prop('disabled', disableInput);
}
return $('<' + tag + ' width="1">')
.addClass('o_list_record_selector')
.append($content);
},
/**
* Main render function for the list. It is rendered as a table. For now,
* this method does not wait for the field widgets to be ready.
*
* @override
* @private
* returns {Deferred} this deferred is resolved immediately
*/
_renderView: function () {
var self = this;
this.$el
.removeClass('table-responsive')
.empty();
// destroy the previously instantiated pagers, if any
_.invoke(this.pagers, 'destroy');
this.pagers = [];
// display the no content helper if there is no data to display
if (!this._hasContent() && this.noContentHelp) {
this._renderNoContentHelper();
return this._super();
}
var $table = $('<table>').addClass('o_list_view table table-condensed table-striped');
this.$el
.addClass('table-responsive')
.append($table);
var is_grouped = !!this.state.groupedBy.length;
this._computeAggregates();
$table.toggleClass('o_list_view_grouped', is_grouped);
$table.toggleClass('o_list_view_ungrouped', !is_grouped);
this.hasHandle = this.state.orderedBy.length === 0 ||
this.state.orderedBy[0].name === this.handleField;
if (is_grouped) {
$table
.append(this._renderHeader(true))
.append(this._renderGroups(this.state.data))
.append(this._renderFooter(true));
} else {
$table
.append(this._renderHeader())
.append(this._renderBody())
.append(this._renderFooter());
}
if (this.selection.length) {
var $checked_rows = this.$('tr').filter(function (index, el) {
return _.contains(self.selection, $(el).data('id'));
});
$checked_rows.find('.o_list_record_selector input').prop('checked', true);
}
return this._super();
},
/**
* Each line can be decorated according to a few simple rules. The arch
* description of the list may have one of the decoration-X attribute with
* a domain as value. Then, for each record, we check if the domain matches
* the record, and add the text-X css class to the element. This method is
* concerned with the computation of the list of css classes for a given
* record.
*
* @private
* @param {Object} record a basic model record
* @param {jQueryElement} $tr a jquery <tr> element (the row to add decoration)
*/
_setDecorationClasses: function (record, $tr) {
_.each(this.rowDecorations, function (expr, decoration) {
var cssClass = decoration.replace('decoration', 'text');
$tr.toggleClass(cssClass, py.PY_isTrue(py.evaluate(expr, record.evalContext)));
});
},
/**
* Update the footer aggregate values. This method should be called each
* time the state of some field is changed, to make sure their sum are kept
* in sync.
*
* @private
*/
_updateFooter: function () {
this._computeAggregates();
this.$('tfoot').replaceWith(this._renderFooter(!!this.state.groupedBy.length));
},
/**
* Whenever we change the state of the selected rows, we need to call this
* method to keep the this.selection variable in sync, and also to recompute
* the aggregates.
*
* @private
*/
_updateSelection: function () {
var $selectedRows = this.$('tbody .o_list_record_selector input:checked')
.closest('tr');
this.selection = _.map($selectedRows, function (row) {
return $(row).data('id');
});
this.trigger_up('selection_changed', { selection: this.selection });
this._updateFooter();
},
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* @private
* @param {MouseEvent} event
*/
_onRowClicked: function (event) {
// The special_click property explicitely allow events to bubble all
// the way up to bootstrap's level rather than being stopped earlier.
if (!$(event.target).prop('special_click')) {
var id = $(event.currentTarget).data('id');
if (id) {
this.trigger_up('open_record', {id:id, target: event.target});
}
}
},
/**
* @private
* @param {MouseEvent} event
*/
_onSelectRecord: function (event) {
event.stopPropagation();
this._updateSelection();
if (!$(event.currentTarget).find('input').prop('checked')) {
this.$('thead .o_list_record_selector input').prop('checked', false);
}
},
/**
* @private
* @param {MouseEvent} event
*/
_onSortColumn: function (event) {
var name = $(event.currentTarget).data('name');
this.trigger_up('toggle_column_order', {id: this.state.id, name: name});
},
/**
* @private
* @param {MouseEvent} event
*/
_onToggleGroup: function (event) {
var group = $(event.currentTarget).data('group');
if (group.count) {
this.trigger_up('toggle_group', {group: group});
}
},
/**
* When the user clicks on the 'checkbox' on the left of a record, we need
* to toggle its status.
*
* @private
* @param {MouseEvent} event
*/
_onToggleSelection: function (event) {
var checked = $(event.currentTarget).prop('checked') || false;
this.$('tbody .o_list_record_selector input:not(":disabled")').prop('checked', checked);
this._updateSelection();
},
});
return ListRenderer;
});