diff options
Diffstat (limited to 'addons/web/static/src/xml')
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 26 | ||||
| -rw-r--r-- | addons/web/static/src/xml/pivot.xml | 99 |
2 files changed, 99 insertions, 26 deletions
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 8854426367c..c3f57baba47 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -469,9 +469,6 @@ </table> </div> -<div t-name="PivotView" t-attf-class="o_pivot #{widget.enableLinking ? 'o_enable_linking' : ''}"> - <div class="o_field_selection"/> -</div> <t t-name="PivotView.buttons"> <div class="btn-group" role="toolbar" aria-label="Main actions"> <button class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> @@ -491,29 +488,6 @@ <button class="btn btn-secondary fa fa-download o_pivot_download" title="Download xls" aria-label="Download xls"/> </div> </t> -<t t-name="PivotView.GroupBySelection"> - <div class="dropdown-menu o_pivot_field_menu" role="menu"> - <t t-foreach="fields" t-as="field"> - <t t-if="(field[1].type === 'date') || (field[1].type === 'datetime')"> - <div role="menuitem" aria-haspopup="true" class="o_inline_dropdown"> - <a href="#" t-att-data-field="field[0]" t-attf-class="dropdown-item o_pivot_field_selection#{field[2] ? ' disabled' : ''}"> - <t t-esc="field[1].string"/> - </a> - <div class="dropdown-menu" role="menu"> - <a role="menuitem" href="#" class="dropdown-item" t-att-data-interval="'day'" t-att-data-field="field[0]">Day</a> - <a role="menuitem" href="#" class="dropdown-item" t-att-data-interval="'week'" t-att-data-field="field[0]">Week</a> - <a role="menuitem" href="#" class="dropdown-item" t-att-data-interval="'month'" t-att-data-field="field[0]">Month</a> - <a role="menuitem" href="#" class="dropdown-item" t-att-data-interval="'quarter'" t-att-data-field="field[0]">Quarter</a> - <a role="menuitem" href="#" class="dropdown-item" t-att-data-interval="'year'" t-att-data-field="field[0]">Year</a> - </div> - </div> - </t> - <t t-else=""> - <a href="#" role="menuitem" t-att-data-field="field[0]" t-attf-class="dropdown-item#{field[2] ? ' disabled' : ''}"><t t-esc="field[1].string"/></a> - </t> - </t> - </div> -</t> <t t-name="FormSelection"> <div class="btn-group o_selection" aria-atomic="true"> diff --git a/addons/web/static/src/xml/pivot.xml b/addons/web/static/src/xml/pivot.xml new file mode 100644 index 00000000000..6e85f1170de --- /dev/null +++ b/addons/web/static/src/xml/pivot.xml @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="utf-8"?> +<templates> + + <div t-name="web.PivotRenderer" class="o_pivot" owl="1"> + <t t-if="!props.hasData || !props.measures.length" t-call="web.NoContentHelper"> + <t t-set="description" t-value="'Try to add some records, or make sure + that there is at least one measure and + no active filter in the search bar'"/> + </t> + <table t-else="1" class="table-hover table-sm table-bordered" t-att-class="{ o_enable_linking: !props.disableLinking }"> + <thead> + <tr t-foreach="props.table.headers" t-as="row" t-key="'header_' + row_index"> + <t t-foreach="row" t-as="cell" t-key="'header_row_' + cell_index"> + <t t-if="cell.measure" t-call="web.PivotMeasure"/> + <t t-elif="cell.isLeaf !== undefined" t-call="web.PivotHeader"> + <t t-set="isXAxis" t-value="true"/> + </t> + <th t-else="1" t-att-colspan="cell.width" t-att-rowspan="cell.height"/> + </t> + </tr> + </thead> + <tbody> + <tr t-foreach="props.table.rows" t-as="row" t-key="'row_' + row_index"> + <t t-call="web.PivotHeader"> + <t t-set="isXAxis" t-value="false"/> + <t t-set="cell" t-value="row"/> + </t> + <t t-foreach="row.subGroupMeasurements" t-as="cell" t-key="'row_cell_' + cell_index"> + <td class="o_pivot_cell_value text-right" t-att-class="{ + o_empty: cell.value === undefined, + 'font-weight-bold': cell.isBold, + }" t-on-click="trigger('open_view', cell)" + t-on-mouseover="_onMouseEnter" t-on-mouseout="_onMouseLeave"> + <t t-if="cell.value !== undefined"> + <div t-if="cell.originIndexes.length > 1" class="o_variation" t-att-class="{ + o_positive: cell.value > 0, + o_negative: cell.value < 0, + o_null: cell.value === 0, + }" t-esc="_getFormattedVariation(cell)"/> + <div t-else="1" class="o_value" t-esc="_getFormattedValue(cell)"/> + </t> + </td> + </t> + </tr> + </tbody> + </table> + </div> + + <t t-name="web.PivotHeader" owl="1"> + <th t-att-colspan="isXAxis ? cell.width : undefined" t-att-rowspan="isXAxis ? cell.height : undefined" t-att-class="{ + o_pivot_header_cell_closed: cell.isLeaf, + o_pivot_header_cell_opened: !cell.isLeaf, + }" t-attf-style="{{ isXAxis ? undefined : 'padding-left: ' + _getPadding(cell) + 'px;' }}" t-att-title="cell.label" t-on-click.self.prevent="_onHeaderClick(cell, isXAxis ? 'col' : 'row')"> + <span t-on-click.self.prevent="_onHeaderClick(cell, isXAxis ? 'col' : 'row')" t-esc="cell.title"/> + <t t-if="_isClicked(cell.groupId, isXAxis)" t-call="web.PivotGroupBySelection"/> + </th> + </t> + + <t t-name="web.PivotMeasure" owl="1"> + <th class="text-muted" t-att-colspan="cell.width" t-att-rowspan="cell.height" t-att-class="{ + o_pivot_origin_row: cell.originIndexes, + o_pivot_measure_row: !cell.originIndexes, + o_pivot_sort_order_asc: cell.order === 'asc', + o_pivot_sort_order_desc: cell.order === 'desc', + }" t-on-click.prevent="trigger('sort_rows',cell)" t-on-mouseover="_onMouseEnter" t-on-mouseout="_onMouseLeave"> + <t t-esc="cell.title"/> + </th> + </t> + + <div t-name="web.PivotGroupBySelection" class="dropdown" owl="1"> + <div class="dropdown-menu o_pivot_field_menu show" data-display="static" role="menu"> + <t t-foreach="props.selectionGroupBys" t-as="field" t-key="field.field.name"> + <t t-if="(field.field.type === 'date') || (field.field.type === 'datetime')"> + <div role="menuitem" aria-haspopup="true" class="o_inline_dropdown"> + <a href="#" + t-on-click.prevent="_onClickMenuGroupBy(field, 'month')" + class="dropdown-item o_pivot_field_selection" + t-att-class="{ disabled: field.active }" + t-att-data-field="field.name" + > + <t t-esc="field.field.string"/> + </a> + <div class="dropdown-menu" role="menu"> + <a role="menuitem" t-att-data-field="field.name" href="#" class="dropdown-item" t-on-click.prevent="_onClickMenuGroupBy(field, 'day')">Day</a> + <a role="menuitem" t-att-data-field="field.name" href="#" class="dropdown-item" t-on-click.prevent="_onClickMenuGroupBy(field, 'week')">Week</a> + <a role="menuitem" t-att-data-field="field.name" href="#" class="dropdown-item" t-on-click.prevent="_onClickMenuGroupBy(field, 'month')">Month</a> + <a role="menuitem" t-att-data-field="field.name" href="#" class="dropdown-item" t-on-click.prevent="_onClickMenuGroupBy(field, 'quarter')">Quarter</a> + <a role="menuitem" t-att-data-field="field.name" href="#" class="dropdown-item" t-on-click.prevent="_onClickMenuGroupBy(field, 'year')">Year</a> + </div> + </div> + </t> + <a t-else="" href="#" role="menuitem" class="dropdown-item" t-att-data-field="field.name" t-att-class="{ disabled: field.active }" t-on-click.prevent="_onClickMenuGroupBy(field, false)"> + <t t-esc="field.field.string"/> + </a> + </t> + </div> + </div> + +</templates> |
