-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a1c3d9
commit 517a0f3
Showing
11 changed files
with
148 additions
and
16 deletions.
There are no files selected for viewing
21 changes: 19 additions & 2 deletions
21
packages/modules/account/src/lib/components/preferences/preferences.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 |
---|---|---|
@@ -1,8 +1,25 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { VCLFormFieldSchemaRoot } from '@vcl/ng-vcl'; | ||
import { buildLocalizationDataSchema } from '../../jss-forms'; | ||
|
||
@Component({ | ||
selector: 'app-account-preferences', | ||
template: ` <rc-page-preferences /> `, | ||
template: ` | ||
<rc-page-preferences> | ||
<rc-account-localization-data | ||
[localizationFormSchema]="localizationFormSchema" | ||
/> | ||
</rc-page-preferences> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class PreferencesComponent {} | ||
export class PreferencesComponent { | ||
localizationFormSchema: VCLFormFieldSchemaRoot = buildLocalizationDataSchema({ | ||
timezones: [], | ||
locales: [], | ||
}); | ||
|
||
// readonly vm$ = combineLatest({ | ||
// TODO: add timezones and locales | ||
// }); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './account-data.jss-form'; | ||
export * from './personal-data.jss-form'; | ||
export * from './account-information.jss-form'; | ||
export * from './localization-data.jss-form'; | ||
export * from './personal-data.jss-form'; |
44 changes: 44 additions & 0 deletions
44
packages/modules/account/src/lib/jss-forms/localization-data.jss-form.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,44 @@ | ||
import { | ||
IIoRestorecommerceTimezoneTimezone, | ||
IoRestorecommerceLocaleLocale, | ||
} from '@console-core/graphql'; | ||
import { VCLFormFieldSchemaRoot } from '@vcl/ng-vcl'; | ||
|
||
interface ISchemaOptions { | ||
timezones: IIoRestorecommerceTimezoneTimezone[]; | ||
locales: IoRestorecommerceLocaleLocale[]; | ||
} | ||
|
||
export const buildLocalizationDataSchema = ( | ||
options: ISchemaOptions | ||
): VCLFormFieldSchemaRoot => { | ||
return { | ||
type: 'form', | ||
fields: [ | ||
{ | ||
name: 'localeId', | ||
label: 'Language', | ||
type: 'select', | ||
params: { | ||
options: options.locales.map((locale) => ({ | ||
label: locale.description ?? '', | ||
sublabel: locale.value ?? '', | ||
value: locale.id, | ||
})), | ||
}, | ||
}, | ||
{ | ||
name: 'timezoneId', | ||
label: 'Timezone', | ||
type: 'select', | ||
params: { | ||
options: options.timezones.map((timezone) => ({ | ||
label: timezone.id ?? '', | ||
sublabel: timezone.description ?? '', | ||
value: timezone.id, | ||
})), | ||
}, | ||
}, | ||
], | ||
}; | ||
}; |
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
26 changes: 26 additions & 0 deletions
26
...i/src/lib/components/organisms/account/localization-data/localization-data.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,26 @@ | ||
<div class="row small-snap-vertical"> | ||
<div class="flex-4"> | ||
<h3>Localization Data</h3> | ||
<p>Customize language and region related preferences</p> | ||
</div> | ||
<div class="flex-8"> | ||
<div class="account-right-side"> | ||
<vcl-jss-form | ||
ngDefaultControl | ||
#localizationForm="vclJssForm" | ||
[schema]="localizationFormSchema" | ||
></vcl-jss-form> | ||
<div class="row justify-end loose-button-group"> | ||
<button | ||
vcl-button | ||
[disabled]=" | ||
!localizationForm.form.valid || localizationForm.form.pristine | ||
" | ||
(click)="onSaveLocalizationForm()" | ||
> | ||
Save | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
26 changes: 26 additions & 0 deletions
26
.../ui/src/lib/components/organisms/account/localization-data/localization-data.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,26 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
Input, | ||
ViewChild, | ||
} from '@angular/core'; | ||
|
||
import { JssFormComponent, VCLFormFieldSchemaRoot } from '@vcl/ng-vcl'; | ||
|
||
@Component({ | ||
selector: 'rc-account-localization-data', | ||
templateUrl: './localization-data.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class RcLocalizationDataComponent { | ||
@Input({ required: true }) | ||
localizationFormSchema!: VCLFormFieldSchemaRoot; | ||
|
||
@ViewChild('localizationForm') | ||
localizationForm!: JssFormComponent; | ||
|
||
onSaveLocalizationForm() { | ||
// TODO: implement | ||
console.log(this.localizationForm.form.value); | ||
} | ||
} |
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