blob: 20a1c3c7eb79f938708babbba57cfbc4255fc9f9 (
plain)
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
|
odoo.define('web.CustomGroupByItem', function (require) {
"use strict";
const DropdownMenuItem = require('web.DropdownMenuItem');
const { useModel } = require('web/static/src/js/model.js');
/**
* Group by generator menu
*
* Component used to generate new filters of type 'groupBy'. It is composed
* of a button (used to toggle the rendering of the rest of the component) and
* an input (select) used to choose a new field name which will be used as a
* new groupBy value.
* @extends DropdownMenuItem
*/
class CustomGroupByItem extends DropdownMenuItem {
constructor() {
super(...arguments);
this.canBeOpened = true;
this.state.fieldName = this.props.fields[0].name;
this.model = useModel('searchModel');
}
//---------------------------------------------------------------------
// Handlers
//---------------------------------------------------------------------
/**
* @private
*/
_onApply() {
const field = this.props.fields.find(f => f.name === this.state.fieldName);
this.model.dispatch('createNewGroupBy', field);
this.state.open = false;
}
}
CustomGroupByItem.template = 'web.CustomGroupByItem';
CustomGroupByItem.props = {
fields: Array,
};
return CustomGroupByItem;
});
|