-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CXSPA-8968: Domain Values on Demand implementation #19876
Draft
Larisa-Staroverova
wants to merge
31
commits into
develop
Choose a base branch
from
feature/CXSPA-8968
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
3dce3d1
CXSPA-8968: Extend normalizer
Larisa-Staroverova ef4125d
CXSPA-8968: Define new show-options component and add it to header co…
Larisa-Staroverova a448c9b
style: CXSPA-8968 - style show more options for attribute header
Uli-Tiger 9684f63
fix: CXSPA-8968 - remove readOnDemand UI Type mapping, as we get prop…
Uli-Tiger 368ed22
fix: CXSPA-8968 switch uiType DDLB to uiType LAZY_LOAD_DDLB for domai…
Uli-Tiger b4e5fbe
feature: CXSPA-8968 read domain on demand
Uli-Tiger b4bcccd
test: CXSPA-8968 - fix existing tests, add tests for header component
Uli-Tiger 7826c0d
test: CXSPA-8986 show more options component test
Uli-Tiger 6f1a586
test: CXSPA-8968 - add more tests
Uli-Tiger 2389189
test: CXSPA-8968 - add ReadAttributeDomain action and its effect
Uli-Tiger 04b2e7a
test: CXSPA-8968 - update tests for OccConfiguratorVariantNormalizer …
Uli-Tiger a57843b
Merge branch 'develop' into feature/CXSPA-8968
Larisa-Staroverova 8b01064
Merge branch 'develop' into feature/CXSPA-8968
Uli-Tiger cb72336
fix: CXSPA-8968 - update padding properties in SCSS for configurator …
Uli-Tiger 756d3f3
feature: CXSPA-8968 - update according to new UI concept
Uli-Tiger b00fe77
review: CXSPA-8968 changes due to review
Uli-Tiger 3139a2c
Merge branch 'develop' into feature/CXSPA-8968
Uli-Tiger 07ce200
Merge branch 'develop' into feature/CXSPA-8968
Larisa-Staroverova a98ccc0
fix: CXSPA-8968 fix after merge - add standlone:false to new components
Uli-Tiger c85b200
Merge branch 'develop' into feature/CXSPA-8968
Uli-Tiger cca5970
Add styling files for show-options component and bind them accordingly
Larisa-Staroverova a7f41f6
Merge branch 'develop' into feature/CXSPA-8968
Uli-Tiger 6db8231
Merge branch 'develop' into feature/CXSPA-8968
Larisa-Staroverova 396f124
Merge branch 'develop' into feature/CXSPA-8968
Larisa-Staroverova 9b82621
Merge branch 'develop' into feature/CXSPA-8968
Larisa-Staroverova b8aa828
CXSPA-8968: aria attributes
steinsebastian 73fcff4
CXSPA-8968: Accessibility for show options link
steinsebastian 43eac04
CXSPA-8968: Prettier
steinsebastian 66887f3
Merge branch 'develop' into feature/CXSPA-8968
Uli-Tiger 3cca25c
CXSPA-8968: Incorporate review feedback
steinsebastian 0c32e08
Merge branch 'feature/CXSPA-8968' of https://github.com/SAP/spartacus…
steinsebastian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
17 changes: 17 additions & 0 deletions
17
...ator/rulebased/components/attribute/show-options/configurator-show-options.component.html
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,17 @@ | ||
<ng-container> | ||
<button | ||
class="btn btn-tertiary" | ||
tabindex="0" | ||
(click)="showOptions()" | ||
[attr.title]="'configurator.button.showOptions' | cxTranslate" | ||
[attr.aria-label]=" | ||
'configurator.a11y.showOptionsForAttribute' | ||
| cxTranslate: { attribute: attributeComponentContext.attribute.label } | ||
" | ||
[attr.aria-describedby]=" | ||
'cx-configurator--label--' + attributeComponentContext.attribute.name | ||
" | ||
> | ||
{{ 'configurator.button.showOptions' | cxTranslate }} | ||
</button> | ||
</ng-container> |
108 changes: 108 additions & 0 deletions
108
...r/rulebased/components/attribute/show-options/configurator-show-options.component.spec.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,108 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ConfiguratorShowOptionsComponent } from './configurator-show-options.component'; | ||
import { I18nTestingModule } from '@spartacus/core'; | ||
import { ConfiguratorCommonsService } from '../../../core/facade/configurator-commons.service'; | ||
import { CommonConfiguratorTestUtilsService } from '../../../../common/testing/common-configurator-test-utils.service'; | ||
import { ConfiguratorStorefrontUtilsService } from '../../service/configurator-storefront-utils.service'; | ||
import { By } from '@angular/platform-browser'; | ||
import { getTestScheduler } from 'jasmine-marbles'; | ||
import { Observable, of } from 'rxjs'; | ||
import { ConfiguratorTestUtils } from '../../../testing/configurator-test-utils'; | ||
|
||
class MockConfiguratorCommonsService { | ||
readAttributeDomain() {} | ||
isConfigurationLoading(): Observable<boolean> { | ||
return of(false); | ||
} | ||
} | ||
|
||
class MockConfiguratorStorefrontUtilsService { | ||
focusFirstActiveElement() {} | ||
createAttributeUiKey() {} | ||
} | ||
|
||
describe('ConfiguratorShowOptionsComponent', () => { | ||
let component: ConfiguratorShowOptionsComponent; | ||
let fixture: ComponentFixture<ConfiguratorShowOptionsComponent>; | ||
let htmlElem: HTMLElement; | ||
let configuratorCommonsService: ConfiguratorCommonsService; | ||
let configuratorStorefrontUtilsService: ConfiguratorStorefrontUtilsService; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ConfiguratorShowOptionsComponent], | ||
imports: [I18nTestingModule], | ||
providers: [ | ||
{ | ||
provide: ConfiguratorCommonsService, | ||
useClass: MockConfiguratorCommonsService, | ||
}, | ||
{ | ||
provide: ConfiguratorStorefrontUtilsService, | ||
useClass: MockConfiguratorStorefrontUtilsService, | ||
}, | ||
], | ||
}).compileComponents(); | ||
|
||
configuratorCommonsService = TestBed.inject(ConfiguratorCommonsService); | ||
configuratorStorefrontUtilsService = TestBed.inject( | ||
ConfiguratorStorefrontUtilsService | ||
); | ||
spyOn(configuratorCommonsService, 'readAttributeDomain'); | ||
fixture = TestBed.createComponent(ConfiguratorShowOptionsComponent); | ||
component = fixture.componentInstance; | ||
htmlElem = fixture.nativeElement; | ||
|
||
component.attributeComponentContext = | ||
ConfiguratorTestUtils.getAttributeContext(); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should render "Show Options" button', () => { | ||
CommonConfiguratorTestUtilsService.expectElementPresent( | ||
expect, | ||
htmlElem, | ||
'.btn' | ||
); | ||
}); | ||
|
||
it('should delegate to configurator commons service when clicking "Show Options" button', () => { | ||
fixture.debugElement.query(By.css('.btn')).nativeElement.click(); | ||
expect(configuratorCommonsService.readAttributeDomain).toHaveBeenCalledWith( | ||
component.attributeComponentContext.owner, | ||
component.attributeComponentContext.group, | ||
component.attributeComponentContext.attribute | ||
); | ||
}); | ||
|
||
describe('focusFirstValue', () => { | ||
it('should call focusFirstActiveElement of configurator storefront utils service ', () => { | ||
//we need to run the test in a test scheduler | ||
//because of the delay() in method focusFirstValue | ||
getTestScheduler().run(({ cold, flush }) => { | ||
const configurationLoading = cold('-a-b-c', { | ||
a: false, | ||
b: true, | ||
c: false, | ||
}); | ||
spyOn( | ||
configuratorCommonsService, | ||
'isConfigurationLoading' | ||
).and.returnValue(configurationLoading); | ||
spyOn( | ||
configuratorStorefrontUtilsService, | ||
'focusFirstActiveElement' | ||
).and.callThrough(); | ||
component['focusFirstValue'](); | ||
flush(); | ||
expect( | ||
configuratorStorefrontUtilsService.focusFirstActiveElement | ||
).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
}); | ||
}); |
58 changes: 58 additions & 0 deletions
58
...urator/rulebased/components/attribute/show-options/configurator-show-options.component.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,58 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <spartacus-team@sap.com> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { Component, Input } from '@angular/core'; | ||
import { delay, take, distinctUntilChanged, skip } from 'rxjs/operators'; | ||
import { ConfiguratorCommonsService } from '../../../core/facade/configurator-commons.service'; | ||
import { ConfiguratorAttributeCompositionContext } from '../composition/configurator-attribute-composition.model'; | ||
import { ConfiguratorStorefrontUtilsService } from '../../service/configurator-storefront-utils.service'; | ||
|
||
@Component({ | ||
selector: 'cx-configurator-show-options', | ||
templateUrl: './configurator-show-options.component.html', | ||
standalone: false, | ||
}) | ||
export class ConfiguratorShowOptionsComponent { | ||
@Input() attributeComponentContext: ConfiguratorAttributeCompositionContext; | ||
|
||
constructor( | ||
protected configuratorCommonsService: ConfiguratorCommonsService, | ||
protected configuratorStorefrontUtilsService: ConfiguratorStorefrontUtilsService | ||
) {} | ||
|
||
/** | ||
* fires a request to read the attribute domain, | ||
* so that all options of the attribute become visible on the UI | ||
*/ | ||
showOptions() { | ||
Uli-Tiger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.focusFirstValue(); | ||
this.configuratorCommonsService.readAttributeDomain( | ||
this.attributeComponentContext.owner, | ||
this.attributeComponentContext.group, | ||
this.attributeComponentContext.attribute | ||
); | ||
} | ||
|
||
protected focusFirstValue(): void { | ||
this.configuratorCommonsService | ||
.isConfigurationLoading(this.attributeComponentContext.owner) | ||
.pipe( | ||
distinctUntilChanged(), | ||
skip(2), // first isLoading=false as it is called before the readAttributeDomain, second is Loading=true, third is loading=false | ||
take(1), | ||
delay(0) // we need to consider the re-rendering of the page | ||
) | ||
.subscribe(() => | ||
this.configuratorStorefrontUtilsService.focusFirstActiveElement( | ||
'#' + | ||
this.configuratorStorefrontUtilsService.createAttributeUiKey( | ||
'group-attribute', | ||
this.attributeComponentContext.attribute.name | ||
) | ||
) | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...figurator/rulebased/components/attribute/show-options/configurator-show-options.module.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,18 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <spartacus-team@sap.com> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { I18nModule } from '@spartacus/core'; | ||
import { ConfiguratorShowOptionsComponent } from './configurator-show-options.component'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, I18nModule], | ||
providers: [], | ||
declarations: [ConfiguratorShowOptionsComponent], | ||
exports: [ConfiguratorShowOptionsComponent], | ||
}) | ||
export class ConfiguratorShowOptionsModule {} |
8 changes: 8 additions & 0 deletions
8
feature-libs/product-configurator/rulebased/components/attribute/show-options/index.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,8 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <spartacus-team@sap.com> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export * from './configurator-show-options.component'; | ||
export * from './configurator-show-options.module'; |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to talk to our accessibility expert whether
Show Options
buttons is read properlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we miss a reference to the attribute name at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steinsebastian: maybe we need a aria text describing what the button does?