Skip to content
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

remove localization #1954

Merged
merged 1 commit into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ There should not be any behavior changes.
All React Material class components were refactored to functional components.
Please check whether you extended any of our base renderers in your adaptation.

### Localization of Date Picker in Angular Material

Date Picker in Angular Material will use the global configuration of your Angular Material application.

## Migrating to JSON Forms 2.5

### JsonForms Component for Angular
Expand Down
8 changes: 7 additions & 1 deletion packages/angular-material/example/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { Component } from '@angular/core';
import { ExampleDescription, getExamples } from '@jsonforms/examples';
import { UISchemaElement, UISchemaTester } from '@jsonforms/core';
import { angularMaterialRenderers } from '../../src/index';
import { DateAdapter } from '@angular/material/core';

const uiSchema = {
type: 'HorizontalLayout',
elements: [
Expand Down Expand Up @@ -89,14 +91,17 @@ export class AppComponent {
i18n = {
locale: 'en-US'
}
private dateAdapter;
private readonly = false;
data: any;
uischemas: { tester: UISchemaTester; uischema: UISchemaElement; }[] = [
{ tester: itemTester, uischema: uiSchema }
];

constructor() {
constructor(dateAdapter: DateAdapter<Date>) {
this.selectedExample = this.examples[19];
this.dateAdapter = dateAdapter;
dateAdapter.setLocale(this.i18n.locale);
}

onChange(ev: any) {
Expand All @@ -105,6 +110,7 @@ export class AppComponent {

changeLocale(locale: string) {
this.i18n.locale = locale;
this.dateAdapter.setLocale(locale);
}

toggleReadonly() {
Expand Down
8 changes: 0 additions & 8 deletions packages/angular-material/src/controls/date.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
*/
import { Component, ChangeDetectionStrategy } from '@angular/core';
import {
getLocale,
isDateControl,
RankedTester,
rankWith
} from '@jsonforms/core';
import { JsonFormsAngularService, JsonFormsControl } from '@jsonforms/angular';
import { DateAdapter, NativeDateAdapter } from '@angular/material/core';

@Component({
selector: 'DateControlRenderer',
Expand Down Expand Up @@ -58,16 +56,10 @@ import { DateAdapter, NativeDateAdapter } from '@angular/material/core';
export class DateControlRenderer extends JsonFormsControl {
constructor(
jsonformsService: JsonFormsAngularService,
private dateAdapter: DateAdapter<NativeDateAdapter>
) {
super(jsonformsService);
}

mapAdditionalProps() {
const locale = getLocale(this.jsonFormsService.getState());
this.dateAdapter.setLocale(locale);
}

getEventValue = (event: any) => event.value.toISOString().substr(0, 10);
}

Expand Down