Skip to content

Commit 0058a08

Browse files
Merge branch 'master' into bugFix/title
2 parents 16eeba4 + 5b516c2 commit 0058a08

24 files changed

+472
-233
lines changed

src/demo/app/demo.component.html

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
fxLayout.lt-sm="column" fxLayoutAlign.lt-sm="flex-start center">
7171

7272
<mat-card fxFlex="0 0 calc(50% - 12px)">
73-
<h4 class="defualt-cursor" (click)="toggleVisible('options')">
73+
<h4 class="default-cursor" (click)="toggleVisible('options')">
7474
{{visible.options ? '▼' : '▶'}} Selected Framework and Options
7575
</h4>
7676
<div *ngIf="visible.options" fxLayout="column" [@expandSection]="true">
@@ -86,6 +86,19 @@ <h4 class="defualt-cursor" (click)="toggleVisible('options')">
8686
</mat-option>
8787
</mat-select>
8888
</mat-form-field>
89+
<mat-form-field>
90+
<mat-select
91+
[(ngModel)]="selectedLanguage"
92+
(change)="loadSelectedLanguage()"
93+
name="language"
94+
placeholder="Language">
95+
<mat-option
96+
*ngFor="let language of languageList"
97+
[value]="language">
98+
{{languages[language]}}
99+
</mat-option>
100+
</mat-select>
101+
</mat-form-field>
89102
<div class="check-row">
90103
<mat-checkbox color="primary" [(ngModel)]="jsonFormOptions.returnEmptyFields">
91104
Return empty fields?
@@ -112,7 +125,7 @@ <h4 class="defualt-cursor" (click)="toggleVisible('options')">
112125
</div>
113126
</div>
114127
<hr>
115-
<h4 class="defualt-cursor" (click)="toggleVisible('schema')">
128+
<h4 class="default-cursor" (click)="toggleVisible('schema')">
116129
{{visible.schema ? '▼' : '▶'}} Input JSON Schema and Form Layout
117130
</h4>
118131
<div *ngIf="visible.schema" [@expandSection]="true"
@@ -128,7 +141,7 @@ <h4 class="defualt-cursor" (click)="toggleVisible('schema')">
128141
</mat-card>
129142

130143
<mat-card fxFlex="0 0 calc(50% - 12px)">
131-
<h4 class="defualt-cursor" (click)="toggleVisible('form')">
144+
<h4 class="default-cursor" (click)="toggleVisible('form')">
132145
{{visible.form ? '▼' : '▶'}} Generated Form
133146
</h4>
134147
<div *ngIf="visible.form" class="json-schema-form" [@expandSection]="true">
@@ -149,7 +162,7 @@ <h4 class="defualt-cursor" (click)="toggleVisible('form')">
149162

150163
</div>
151164
<hr>
152-
<h4 class="defualt-cursor" (click)="toggleVisible('output')">
165+
<h4 class="default-cursor" (click)="toggleVisible('output')">
153166
{{visible.output ? '▼' : '▶'}} Form Output
154167
</h4>
155168
<div *ngIf="visible.output" fxLayout="column" [@expandSection]="true">

src/demo/app/demo.component.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ import { JsonPointer } from '../../lib/src/shared';
2727
})
2828
export class DemoComponent implements OnInit {
2929
examples: any = Examples;
30+
languageList: any = ['en', 'fr'];
31+
languages: any = {
32+
'en': 'English',
33+
'fr': 'French',
34+
};
3035
frameworkList: any = ['material-design', 'bootstrap-3', 'bootstrap-4', 'no-framework'];
3136
frameworks: any = {
3237
'material-design': 'Material Design',
@@ -39,6 +44,7 @@ export class DemoComponent implements OnInit {
3944
selectedExample = 'ng-jsf-flex-layout';
4045
selectedExampleName = 'Flexbox layout';
4146
selectedFramework = 'material-design';
47+
selectedLanguage = 'en';
4248
visible: { [item: string]: boolean } = {
4349
options: true,
4450
schema: true,
@@ -98,6 +104,9 @@ export class DemoComponent implements OnInit {
98104
if (params['framework']) {
99105
this.selectedFramework = params['framework'];
100106
}
107+
if (params['language']) {
108+
this.selectedLanguage = params['language'];
109+
}
101110
this.loadSelectedExample();
102111
}
103112
);
@@ -163,7 +172,8 @@ export class DemoComponent implements OnInit {
163172
this.router.navigateByUrl(
164173
'/?set=' + selectedSet +
165174
'&example=' + selectedExample +
166-
'&framework=' + this.selectedFramework
175+
'&framework=' + this.selectedFramework +
176+
'&language=' + this.selectedLanguage
167177
);
168178
this.liveFormData = {};
169179
this.submittedFormData = null;
@@ -179,13 +189,14 @@ export class DemoComponent implements OnInit {
179189
});
180190
}
181191

182-
loadSelectedFramework(selectedFramework: string) {
183-
this.router.navigateByUrl(
192+
loadSelectedLanguage() {
193+
console.log('loadSelectedLanguage');
194+
window.location.href =
184195
'/?set=' + this.selectedSet +
185196
'&example=' + this.selectedExample +
186-
'&framework=' + selectedFramework
187-
);
188-
this.generateForm(this.jsonFormSchema);
197+
'&framework=' + this.selectedFramework +
198+
'&language=' + this.selectedLanguage;
199+
// this.generateForm(this.jsonFormSchema);
189200
}
190201

191202
// Display the form entered by the user

src/demo/app/demo.module.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
import { RouterModule } from '@angular/router';
1212

1313
import { JsonSchemaFormModule } from '../../lib/src/json-schema-form.module';
14+
import { JsonSchemaFormIntl } from '../../lib/src/json-schema-form-intl';
15+
import { JsonSchemaFormIntlFr } from '../../lib/src/i18n/json-schema-form-intl-fr';
1416
// To include JsonSchemaFormModule after downloading from NPM, use this instead:
1517
// import { JsonSchemaFormModule } from 'angular2-json-schema-form';
1618

@@ -19,14 +21,55 @@ import { DemoComponent } from './demo.component';
1921
import { DemoRootComponent } from './demo-root.component';
2022

2123
import { routes } from './demo.routes';
24+
import { ActivatedRoute, Router } from '@angular/router';
25+
26+
import { Framework } from '../../lib/src/framework-library/framework';
27+
28+
import { FrameworkNoFramework } from '../../lib/src/framework-library/framework.no-framework';
29+
30+
import { Bootstrap3FrameworkModule } from '../../lib/src/framework-library/bootstrap-3-framework/bootstrap-3-framework.module';
31+
import { FrameworkBootstrap3 } from '../../lib/src/framework-library/framework.bootstrap3';
32+
33+
import { Bootstrap4FrameworkModule } from '../../lib/src/framework-library/bootstrap-4-framework/bootstrap-4-framework.module';
34+
import { FrameworkBootstrap4 } from '../../lib/src/framework-library/framework.bootstrap4';
35+
36+
import { MaterialDesignFrameworkModule } from '../../lib/src/framework-library/material-design-framework/material-design-framework.module';
37+
import { FrameworkMaterialDesign } from '../../lib/src/framework-library/framework.material-design';
38+
39+
let language = '';
2240

2341
@NgModule({
2442
declarations: [ AceEditorDirective, DemoComponent, DemoRootComponent ],
2543
imports: [
2644
BrowserModule, BrowserAnimationsModule, FlexLayoutModule, FormsModule,
2745
HttpClientModule, MatButtonModule, MatCardModule, MatCheckboxModule,
2846
MatIconModule, MatMenuModule, MatSelectModule, MatToolbarModule,
29-
RouterModule.forRoot(routes), JsonSchemaFormModule
47+
RouterModule.forRoot(routes), JsonSchemaFormModule,
48+
Bootstrap3FrameworkModule,
49+
Bootstrap4FrameworkModule,
50+
MaterialDesignFrameworkModule
51+
],
52+
providers: [
53+
{
54+
provide: JsonSchemaFormIntl, useFactory:
55+
function(route: ActivatedRoute) {
56+
route.queryParams.subscribe(
57+
params => {
58+
language = params['language'];
59+
});
60+
switch (language) {
61+
case 'fr':
62+
return new JsonSchemaFormIntlFr();
63+
default:
64+
return new JsonSchemaFormIntl();
65+
}
66+
},
67+
deps: [ActivatedRoute]
68+
},
69+
{ provide: Framework, useClass: FrameworkNoFramework, multi: true },
70+
{ provide: Framework, useClass: FrameworkBootstrap3, multi: true },
71+
{ provide: Framework, useClass: FrameworkBootstrap4, multi: true },
72+
{ provide: Framework, useClass: FrameworkMaterialDesign, multi: true }
3073
],
3174
bootstrap: [ DemoRootComponent ]
3275
})

src/lib/src/framework-library/bootstrap-3-framework/bootstrap-3-framework.component.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@ export class Bootstrap3FrameworkComponent implements OnInit, OnChanges {
159159

160160
this.options.htmlClass =
161161
addClasses(this.options.htmlClass, 'schema-form-' + this.layoutNode.type);
162-
this.options.htmlClass =
163-
this.layoutNode.type === 'array' ?
164-
addClasses(this.options.htmlClass, 'list-group') :
165-
this.layoutNode.arrayItem && this.layoutNode.type !== '$ref' ?
166-
addClasses(this.options.htmlClass, 'list-group-item') :
167-
addClasses(this.options.htmlClass, 'form-group');
162+
if (this.layoutNode.type !== 'flex') {
163+
this.options.htmlClass =
164+
this.layoutNode.type === 'array' ?
165+
addClasses(this.options.htmlClass, 'list-group') :
166+
this.layoutNode.arrayItem && this.layoutNode.type !== '$ref' ?
167+
addClasses(this.options.htmlClass, 'list-group-item') :
168+
addClasses(this.options.htmlClass, 'form-group');
169+
}
168170
this.widgetOptions.htmlClass = '';
169171
this.options.labelHtmlClass =
170172
addClasses(this.options.labelHtmlClass, 'control-label');
@@ -287,6 +289,9 @@ export class Bootstrap3FrameworkComponent implements OnInit, OnChanges {
287289
this.widgetOptions.expandable = true;
288290
this.widgetOptions.title = 'Authentication settings';
289291
return null;
292+
case 'fieldset':
293+
this.widgetOptions.title = this.options.title;
294+
return null;
290295
default:
291296
this.widgetOptions.title = null;
292297
return this.jsf.setItemTitle(this);
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, ModuleWithProviders } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

44
import { WidgetLibraryModule } from '../../widget-library/widget-library.module';
55

6-
import { WidgetLibraryService } from '../../widget-library/widget-library.service';
7-
import { FrameworkLibraryService } from '../framework-library.service';
6+
import { JsonSchemaFormService } from '../../json-schema-form.service';
87

98
import { Bootstrap3FrameworkComponent } from './bootstrap-3-framework.component';
109

1110
@NgModule({
1211
imports: [ CommonModule, WidgetLibraryModule ],
1312
declarations: [ Bootstrap3FrameworkComponent ],
1413
exports: [ Bootstrap3FrameworkComponent ],
15-
entryComponents: [ Bootstrap3FrameworkComponent ],
16-
providers: [ WidgetLibraryService, FrameworkLibraryService ]
14+
entryComponents: [ Bootstrap3FrameworkComponent ]
1715
})
18-
export class Bootstrap3FrameworkModule { }
16+
export class Bootstrap3FrameworkModule {
17+
static forRoot(): ModuleWithProviders {
18+
return {
19+
ngModule: Bootstrap3FrameworkModule,
20+
providers: [ JsonSchemaFormService ]
21+
}
22+
}
23+
}

src/lib/src/framework-library/bootstrap-4-framework/bootstrap-4-framework.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ export class Bootstrap4FrameworkComponent implements OnInit, OnChanges {
287287
this.widgetOptions.expandable = true;
288288
this.widgetOptions.title = 'Authentication settings';
289289
return null;
290+
case 'fieldset':
291+
this.widgetOptions.title = this.options.title;
292+
return null;
290293
default:
291294
this.widgetOptions.title = null;
292295
return this.jsf.setItemTitle(this);
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, ModuleWithProviders } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

44
import { WidgetLibraryModule } from '../../widget-library/widget-library.module';
55

6-
import { WidgetLibraryService } from '../../widget-library/widget-library.service';
7-
import { FrameworkLibraryService } from '../framework-library.service';
6+
import { JsonSchemaFormService } from '../../json-schema-form.service';
87

98
import { Bootstrap4FrameworkComponent } from './bootstrap-4-framework.component';
109

1110
@NgModule({
1211
imports: [ CommonModule, WidgetLibraryModule ],
1312
declarations: [ Bootstrap4FrameworkComponent ],
1413
exports: [ Bootstrap4FrameworkComponent ],
15-
entryComponents: [ Bootstrap4FrameworkComponent ],
16-
providers: [ WidgetLibraryService, FrameworkLibraryService ]
14+
entryComponents: [ Bootstrap4FrameworkComponent ]
1715
})
18-
export class Bootstrap4FrameworkModule { }
16+
export class Bootstrap4FrameworkModule {
17+
static forRoot(): ModuleWithProviders {
18+
return {
19+
ngModule: Bootstrap4FrameworkModule,
20+
providers: [ JsonSchemaFormService ]
21+
}
22+
}
23+
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, ModuleWithProviders } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

4-
import { WidgetLibraryModule } from '../widget-library/widget-library.module';
54
import { WidgetLibraryService } from '../widget-library/widget-library.service';
5+
import { WidgetLibraryModule } from '../widget-library/widget-library.module';
66

77
import { FrameworkLibraryService } from './framework-library.service';
8-
9-
import { Bootstrap3FrameworkModule } from './bootstrap-3-framework/bootstrap-3-framework.module';
10-
import { MaterialDesignFrameworkModule } from './material-design-framework/material-design-framework.module';
11-
128
import { NoFrameworkComponent } from './no-framework.component';
13-
import { Bootstrap4FrameworkModule } from './bootstrap-4-framework/bootstrap-4-framework.module';
149

1510
@NgModule({
1611
imports: [
1712
CommonModule, WidgetLibraryModule,
18-
Bootstrap3FrameworkModule, MaterialDesignFrameworkModule, Bootstrap4FrameworkModule
1913
],
2014
declarations: [ NoFrameworkComponent ],
2115
exports: [
2216
NoFrameworkComponent,
23-
Bootstrap3FrameworkModule, MaterialDesignFrameworkModule, Bootstrap4FrameworkModule
2417
],
25-
entryComponents: [ NoFrameworkComponent ],
26-
providers: [ WidgetLibraryService, FrameworkLibraryService ]
18+
entryComponents: [ NoFrameworkComponent ]
2719
})
28-
export class FrameworkLibraryModule { }
20+
export class FrameworkLibraryModule {
21+
static forRoot(): ModuleWithProviders {
22+
return {
23+
ngModule: FrameworkLibraryModule,
24+
providers: [ WidgetLibraryService, FrameworkLibraryService ]
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)