-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch products on login; add
getProductAbbreviation
function (#406)
* Start of expanded ProductAreasService * Remove unused functions and classes * Update tests * Test abbreviation logic change * Test cleanup * Fix failing tests * Add fetch call to ProductSelect * Fetch product areas in the background
- Loading branch information
Showing
19 changed files
with
295 additions
and
192 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,83 +1,65 @@ | ||
{{! https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ }} | ||
<div data-test-product-select> | ||
{{#if this.products}} | ||
{{#if @formatIsBadge}} | ||
<Inputs::BadgeDropdownList | ||
@items={{this.products}} | ||
@listIsOrdered={{true}} | ||
@onItemClick={{this.onChange}} | ||
@selected={{@selected}} | ||
@placement={{@placement}} | ||
@isSaving={{@isSaving}} | ||
@renderOut={{@renderOut}} | ||
@secondaryFilterAttribute="abbreviation" | ||
@icon={{this.icon}} | ||
class="product-select-dropdown-list w-80" | ||
...attributes | ||
> | ||
<:item as |dd|> | ||
<dd.Action data-test-product-select-badge-dropdown-item> | ||
<Inputs::ProductSelect::Item | ||
@product={{dd.value}} | ||
@isSelected={{dd.isSelected}} | ||
/> | ||
</dd.Action> | ||
</:item> | ||
</Inputs::BadgeDropdownList> | ||
{{else}} | ||
<X::DropdownList | ||
@items={{this.products}} | ||
@listIsOrdered={{true}} | ||
@onItemClick={{this.onChange}} | ||
@selected={{@selected}} | ||
@placement={{@placement}} | ||
@isSaving={{@isSaving}} | ||
@renderOut={{@renderOut}} | ||
@offset={{@offset}} | ||
@matchAnchorWidth={{@matchAnchorWidth}} | ||
@secondaryFilterAttribute="abbreviation" | ||
class="product-select-dropdown-list" | ||
...attributes | ||
> | ||
<:anchor as |dd|> | ||
<dd.ToggleSelect class="gap-2" id="product-select"> | ||
<Inputs::ProductSelect::Item | ||
@product={{dd.selected}} | ||
@abbreviation={{this.selectedProductAbbreviation}} | ||
/> | ||
</dd.ToggleSelect> | ||
</:anchor> | ||
<:item as |dd|> | ||
<dd.Action data-test-product-select-item-button class="pr-5"> | ||
<Inputs::ProductSelect::Item | ||
@product={{dd.value}} | ||
@isSelected={{dd.isSelected}} | ||
@abbreviation={{dd.attrs.abbreviation}} | ||
/> | ||
</dd.Action> | ||
</:item> | ||
</X::DropdownList> | ||
{{/if}} | ||
{{else if this.fetchProductAreas.isRunning}} | ||
<div class="flex h-6 items-center" I> | ||
<FlightIcon data-test-product-select-spinner @name="loading" /> | ||
</div> | ||
{{else if this.errorIsShown}} | ||
<div class="failed-to-load-text"> | ||
Failed to load | ||
</div> | ||
<Hds::Button | ||
data-test-product-select-failed-to-load-button | ||
@color="secondary" | ||
@size="small" | ||
{{on "click" (perform this.fetchProductAreas)}} | ||
@text="Retry" | ||
@icon="reload" | ||
/> | ||
<div | ||
data-test-product-select | ||
{{! Fetch the most up-to-date product areas in the background }} | ||
{{did-insert (perform this.productAreas.fetch)}} | ||
> | ||
{{#if @formatIsBadge}} | ||
<Inputs::BadgeDropdownList | ||
@items={{this.products}} | ||
@listIsOrdered={{true}} | ||
@onItemClick={{this.onChange}} | ||
@selected={{@selected}} | ||
@placement={{@placement}} | ||
@isSaving={{@isSaving}} | ||
@renderOut={{@renderOut}} | ||
@secondaryFilterAttribute="abbreviation" | ||
@icon={{this.icon}} | ||
class="product-select-dropdown-list w-80" | ||
...attributes | ||
> | ||
<:item as |dd|> | ||
<dd.Action data-test-product-select-badge-dropdown-item> | ||
<Inputs::ProductSelect::Item | ||
@product={{dd.value}} | ||
@isSelected={{dd.isSelected}} | ||
@abbreviation={{dd.attrs.abbreviation}} | ||
/> | ||
</dd.Action> | ||
</:item> | ||
</Inputs::BadgeDropdownList> | ||
{{else}} | ||
<div | ||
class="absolute top-0 left-0" | ||
{{did-insert (perform this.fetchProductAreas)}} | ||
></div> | ||
<X::DropdownList | ||
@items={{this.products}} | ||
@listIsOrdered={{true}} | ||
@onItemClick={{this.onChange}} | ||
@selected={{@selected}} | ||
@placement={{@placement}} | ||
@isSaving={{@isSaving}} | ||
@renderOut={{@renderOut}} | ||
@offset={{@offset}} | ||
@matchAnchorWidth={{@matchAnchorWidth}} | ||
@secondaryFilterAttribute="abbreviation" | ||
class="product-select-dropdown-list" | ||
...attributes | ||
> | ||
<:anchor as |dd|> | ||
<dd.ToggleSelect class="gap-2" id="product-select"> | ||
<Inputs::ProductSelect::Item | ||
@product={{dd.selected}} | ||
@abbreviation={{this.selectedProductAbbreviation}} | ||
/> | ||
</dd.ToggleSelect> | ||
</:anchor> | ||
<:item as |dd|> | ||
<dd.Action data-test-product-select-item-button class="pr-5"> | ||
<Inputs::ProductSelect::Item | ||
@product={{dd.value}} | ||
@isSelected={{dd.isSelected}} | ||
@abbreviation={{dd.attrs.abbreviation}} | ||
/> | ||
</dd.Action> | ||
</:item> | ||
</X::DropdownList> | ||
{{/if}} | ||
</div> |
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
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
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
Oops, something went wrong.