-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] pivot: select dimension with arrow keys
In the side panel of pivot properties, when clicking on Add to add a new dimension, the user can now use the arrow keys and Enter key to select a dimension. Note: tests are in odoo because there's currently no pivot in o-spreadsheet alone. closes #4135 Task: 3893736 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
- Loading branch information
1 parent
475feb2
commit aaa7ab5
Showing
6 changed files
with
144 additions
and
56 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/components/composer/autocomplete_dropdown/autocomplete_dropdown_store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { AutoCompleteProposal, AutoCompleteProvider } from "../../../registries"; | ||
import { SpreadsheetStore } from "../../../stores"; | ||
|
||
export class AutoCompleteStore extends SpreadsheetStore { | ||
selectedIndex: number | undefined = undefined; | ||
provider: AutoCompleteProvider | undefined; | ||
|
||
get selectedProposal(): AutoCompleteProposal | undefined { | ||
if (this.selectedIndex === undefined || this.provider === undefined) { | ||
return undefined; | ||
} | ||
return this.provider.proposals[this.selectedIndex]; | ||
} | ||
|
||
useProvider(provider: AutoCompleteProvider) { | ||
this.provider = provider; | ||
this.selectedIndex = provider.autoSelectFirstProposal ? 0 : undefined; | ||
} | ||
|
||
hide() { | ||
this.provider = undefined; | ||
this.selectedIndex = undefined; | ||
} | ||
|
||
selectIndex(index: number) { | ||
this.selectedIndex = index; | ||
} | ||
|
||
moveSelection(direction: "previous" | "next") { | ||
if (!this.provider) { | ||
return; | ||
} | ||
if (this.selectedIndex === undefined) { | ||
this.selectedIndex = 0; | ||
return; | ||
} | ||
if (direction === "next") { | ||
this.selectedIndex--; | ||
if (this.selectedIndex < 0) { | ||
this.selectedIndex = this.provider.proposals.length - 1; | ||
} | ||
} else { | ||
this.selectedIndex = (this.selectedIndex + 1) % this.provider.proposals.length; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useEffect, useRef } from "@odoo/owl"; | ||
|
||
export function useAutofocus({ refName }: { refName: string }) { | ||
const ref = useRef(refName); | ||
useEffect( | ||
(el) => { | ||
el?.focus(); | ||
}, | ||
() => [ref.el] | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters