Skip to content

Commit

Permalink
move data items
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-odoo committed Apr 10, 2024
1 parent dc574ab commit b1111ce
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/icons/icons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -964,4 +964,9 @@ https://fontawesome.com/license -->
/>
</svg>
</t>
<t t-name="o-spreadsheet-Icon.UNUSED_PIVOT_WARNING">
<div class="o-unused-pivot-icon text-warning" title="This pivot is not used">
<t t-call="o-spreadsheet-Icon.TRIANGLE_EXCLAMATION"/>
</div>
</t>
</templates>
26 changes: 26 additions & 0 deletions src/registries/menus/topbar_menu_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import * as ACTION_FORMAT from "../../actions/format_actions";
import * as ACTION_INSERT from "../../actions/insert_actions";
import * as ACTIONS from "../../actions/menu_items_actions";
import * as ACTION_VIEW from "../../actions/view_actions";
import { getPivotHighlights } from "../../helpers/pivot/pivot_highlight";
import { HighlightStore } from "../../stores/highlight_store";
import { _t } from "../../translation";
import { MenuItemRegistry } from "../menu_items_registry";
import { formatNumberMenuItemSpec } from "./number_format_menu_registry";
Expand Down Expand Up @@ -454,4 +456,28 @@ topbarMenuRegistry
...ACTION_DATA.createRemoveFilter,
sequence: 40,
separator: true,
})
.addChild("data_sources_data", ["data"], (env) => {
const sequence = 50;
return env.model.getters.getPivotIds().map((pivotId, index) => {
const highlightProvider = {
get highlights() {
return getPivotHighlights(env.model.getters, pivotId);
},
};
return {
id: `item_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
name: env.model.getters.getPivotDisplayName(pivotId),
sequence: sequence + index,
execute: (env) => env.openSidePanel("PIVOT_PROPERTIES_PANEL", { pivotId }),
onStartHover: (env) => env.getStore(HighlightStore).register(highlightProvider),
onStopHover: (env) => env.getStore(HighlightStore).unRegister(highlightProvider),
icon: "o-spreadsheet-Icon.PIVOT",
separator: index === env.model.getters.getPivotIds().length - 1,
secondaryIcon: (env) =>
env.model.getters.isPivotUnused(pivotId)
? "o-spreadsheet-Icon.UNUSED_PIVOT_WARNING"
: undefined,
};
});
});

0 comments on commit b1111ce

Please sign in to comment.