Skip to content

Commit

Permalink
[IMP] pivot: display pivot name in auto complete dropdown
Browse files Browse the repository at this point in the history
Unless the auto complete suggestion is selected, it only shows the id
of the pivot and not the name. This commit changes that to always show
the name of the pivot in addition to its id.

closes #5270

Task: 3953742
Signed-off-by: Pierre Rousseau (pro) <[email protected]>
  • Loading branch information
hokolomopo committed Dec 11, 2024
1 parent 432acda commit 7448722
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div
class="o-autocomplete-description text-truncate"
t-esc="proposal.description"
t-if="props.selectedIndex === proposal_index"
t-if="props.selectedIndex === proposal_index || proposal.alwaysExpanded"
/>
</div>
</t>
Expand Down
1 change: 1 addition & 0 deletions src/registries/auto_completes/auto_complete_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface AutoCompleteProposal {
* Key to use for fuzzy search.
*/
fuzzySearchKey?: string;
alwaysExpanded?: boolean;
}

export interface AutoCompleteProvider {
Expand Down
1 change: 1 addition & 0 deletions src/registries/auto_completes/pivot_auto_complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ autoCompleteProviders.add("pivot_ids", {
description: definition.name,
htmlContent: [{ value: str, color: tokenColors.NUMBER }],
fuzzySearchKey: str + definition.name,
alwaysExpanded: true,
};
})
.filter(isDefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ describe("spreadsheet pivot auto complete", () => {
fuzzySearchKey: "1My pivot",
htmlContent: [{ color: "#02c39a", value: "1" }],
text: "1",
alwaysExpanded: true,
},
{
description: "My pivot 2",
fuzzySearchKey: "2My pivot 2",
htmlContent: [{ color: "#02c39a", value: "2" }],
text: "2",
alwaysExpanded: true,
},
]);
autoComplete?.selectProposal(autoComplete?.proposals[0].text);
Expand Down
19 changes: 19 additions & 0 deletions tests/composer/autocomplete_dropdown_component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,25 @@ describe("Functions autocomplete", () => {
await keyDown({ key: "Enter" });
expect(composerStore.currentContent).toBe("=SUM(");
});

test("autocomplete proposal can be automatically expanded", async () => {
registries.autoCompleteProviders.add("test", {
getProposals() {
return [
{ text: "option 1", description: " descr1", alwaysExpanded: true },
{ text: "option 2", description: " descr1", alwaysExpanded: true },
{ text: "option 3", description: " descr1", alwaysExpanded: false },
];
},
selectProposal() {},
});
registerCleanup(() => registries.autoCompleteProviders.remove("test"));
await typeInComposer("=SUM(");
const proposals = [...fixture.querySelectorAll(".o-autocomplete-value")].map(
(el) => el.parentElement?.textContent
);
expect(proposals).toEqual(["option 1 descr1", "option 2 descr1", "option 3"]);
});
});

describe("autocomplete functions SUM IF", () => {
Expand Down

0 comments on commit 7448722

Please sign in to comment.