@jsonforms/angular-material 3.0.0 → 3.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/controls/autocomplete.renderer.d.ts +2 -2
- package/lib/cjs/controls/autocomplete.renderer.js +1 -1
- package/lib/cjs/controls/autocomplete.renderer.js.map +1 -1
- package/lib/cjs/controls/autocomplete.renderer.metadata.json +1 -1
- package/lib/cjs/controls/date.renderer.js +1 -1
- package/lib/cjs/controls/date.renderer.js.map +1 -1
- package/lib/cjs/controls/date.renderer.metadata.json +1 -1
- package/lib/cjs/controls/number.renderer.js +2 -2
- package/lib/cjs/controls/number.renderer.js.map +1 -1
- package/lib/cjs/controls/number.renderer.metadata.json +1 -1
- package/lib/cjs/controls/text.renderer.js +1 -1
- package/lib/cjs/controls/text.renderer.js.map +1 -1
- package/lib/cjs/controls/text.renderer.metadata.json +1 -1
- package/lib/cjs/controls/textarea.renderer.js +1 -1
- package/lib/cjs/controls/textarea.renderer.js.map +1 -1
- package/lib/cjs/controls/textarea.renderer.metadata.json +1 -1
- package/lib/cjs/layouts/array-layout.renderer.d.ts +8 -0
- package/lib/cjs/layouts/array-layout.renderer.js +12 -2
- package/lib/cjs/layouts/array-layout.renderer.js.map +1 -1
- package/lib/cjs/layouts/array-layout.renderer.metadata.json +1 -1
- package/lib/cjs/layouts/categorization-layout.renderer.d.ts +2 -1
- package/lib/cjs/layouts/categorization-layout.renderer.js +5 -2
- package/lib/cjs/layouts/categorization-layout.renderer.js.map +1 -1
- package/lib/cjs/layouts/categorization-layout.renderer.metadata.json +1 -1
- package/lib/cjs/layouts/group-layout.renderer.js +1 -1
- package/lib/cjs/layouts/group-layout.renderer.js.map +1 -1
- package/lib/cjs/layouts/group-layout.renderer.metadata.json +1 -1
- package/lib/cjs/layouts/horizontal-layout.renderer.js +1 -1
- package/lib/cjs/layouts/horizontal-layout.renderer.js.map +1 -1
- package/lib/cjs/layouts/horizontal-layout.renderer.metadata.json +1 -1
- package/lib/cjs/layouts/layout.renderer.d.ts +5 -3
- package/lib/cjs/layouts/layout.renderer.js +18 -14
- package/lib/cjs/layouts/layout.renderer.js.map +1 -1
- package/lib/cjs/layouts/layout.renderer.metadata.json +1 -1
- package/lib/cjs/layouts/vertical-layout.renderer.js +1 -1
- package/lib/cjs/layouts/vertical-layout.renderer.js.map +1 -1
- package/lib/cjs/layouts/vertical-layout.renderer.metadata.json +1 -1
- package/lib/cjs/module.js +3 -1
- package/lib/cjs/module.js.map +1 -1
- package/lib/cjs/module.metadata.json +1 -1
- package/lib/cjs/other/master-detail/master.js +3 -0
- package/lib/cjs/other/master-detail/master.js.map +1 -1
- package/lib/cjs/other/master-detail/master.metadata.json +1 -1
- package/lib/cjs/other/table.renderer.d.ts +9 -0
- package/lib/cjs/other/table.renderer.js +28 -2
- package/lib/cjs/other/table.renderer.js.map +1 -1
- package/lib/cjs/other/table.renderer.metadata.json +1 -1
- package/lib/esm/controls/autocomplete.renderer.d.ts +2 -2
- package/lib/esm/controls/autocomplete.renderer.js +1 -1
- package/lib/esm/controls/autocomplete.renderer.js.map +1 -1
- package/lib/esm/controls/autocomplete.renderer.metadata.json +1 -1
- package/lib/esm/controls/date.renderer.js +1 -1
- package/lib/esm/controls/date.renderer.js.map +1 -1
- package/lib/esm/controls/date.renderer.metadata.json +1 -1
- package/lib/esm/controls/number.renderer.js +3 -3
- package/lib/esm/controls/number.renderer.js.map +1 -1
- package/lib/esm/controls/number.renderer.metadata.json +1 -1
- package/lib/esm/controls/text.renderer.js +1 -1
- package/lib/esm/controls/text.renderer.js.map +1 -1
- package/lib/esm/controls/text.renderer.metadata.json +1 -1
- package/lib/esm/controls/textarea.renderer.js +1 -1
- package/lib/esm/controls/textarea.renderer.js.map +1 -1
- package/lib/esm/controls/textarea.renderer.metadata.json +1 -1
- package/lib/esm/layouts/array-layout.renderer.d.ts +8 -0
- package/lib/esm/layouts/array-layout.renderer.js +12 -2
- package/lib/esm/layouts/array-layout.renderer.js.map +1 -1
- package/lib/esm/layouts/array-layout.renderer.metadata.json +1 -1
- package/lib/esm/layouts/categorization-layout.renderer.d.ts +2 -1
- package/lib/esm/layouts/categorization-layout.renderer.js +6 -3
- package/lib/esm/layouts/categorization-layout.renderer.js.map +1 -1
- package/lib/esm/layouts/categorization-layout.renderer.metadata.json +1 -1
- package/lib/esm/layouts/group-layout.renderer.js +1 -1
- package/lib/esm/layouts/group-layout.renderer.js.map +1 -1
- package/lib/esm/layouts/group-layout.renderer.metadata.json +1 -1
- package/lib/esm/layouts/horizontal-layout.renderer.js +1 -1
- package/lib/esm/layouts/horizontal-layout.renderer.js.map +1 -1
- package/lib/esm/layouts/horizontal-layout.renderer.metadata.json +1 -1
- package/lib/esm/layouts/layout.renderer.d.ts +5 -3
- package/lib/esm/layouts/layout.renderer.js +18 -14
- package/lib/esm/layouts/layout.renderer.js.map +1 -1
- package/lib/esm/layouts/layout.renderer.metadata.json +1 -1
- package/lib/esm/layouts/vertical-layout.renderer.js +1 -1
- package/lib/esm/layouts/vertical-layout.renderer.js.map +1 -1
- package/lib/esm/layouts/vertical-layout.renderer.metadata.json +1 -1
- package/lib/esm/module.js +3 -1
- package/lib/esm/module.js.map +1 -1
- package/lib/esm/module.metadata.json +1 -1
- package/lib/esm/other/master-detail/master.js +4 -1
- package/lib/esm/other/master-detail/master.js.map +1 -1
- package/lib/esm/other/master-detail/master.metadata.json +1 -1
- package/lib/esm/other/table.renderer.d.ts +9 -0
- package/lib/esm/other/table.renderer.js +29 -3
- package/lib/esm/other/table.renderer.js.map +1 -1
- package/lib/esm/other/table.renderer.metadata.json +1 -1
- package/package.json +23 -8
- package/src/controls/autocomplete.renderer.ts +5 -3
- package/src/controls/date.renderer.ts +3 -1
- package/src/controls/number.renderer.ts +4 -3
- package/src/controls/text.renderer.ts +3 -1
- package/src/controls/textarea.renderer.ts +3 -1
- package/src/layouts/array-layout.renderer.ts +43 -2
- package/src/layouts/categorization-layout.renderer.ts +8 -2
- package/src/layouts/group-layout.renderer.ts +1 -1
- package/src/layouts/horizontal-layout.renderer.ts +1 -1
- package/src/layouts/layout.renderer.ts +17 -12
- package/src/layouts/vertical-layout.renderer.ts +1 -1
- package/src/module.ts +3 -1
- package/src/other/master-detail/master.ts +5 -0
- package/src/other/table.renderer.ts +80 -3
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/arraylayoutrenderer.html +0 -1046
- package/docs/classes/autocompletecontrolrenderer.html +0 -887
- package/docs/classes/booleancontrolrenderer.html +0 -771
- package/docs/classes/categorizationtablayoutrenderer.html +0 -370
- package/docs/classes/datecontrolrenderer.html +0 -739
- package/docs/classes/grouplayoutrenderer.html +0 -426
- package/docs/classes/horizontallayoutrenderer.html +0 -426
- package/docs/classes/jsonformsangularmaterialmodule.html +0 -133
- package/docs/classes/jsonformsdetailcomponent.html +0 -227
- package/docs/classes/labelrenderer.html +0 -363
- package/docs/classes/layoutrenderer.html +0 -465
- package/docs/classes/masterlistcomponent.html +0 -1054
- package/docs/classes/numbercontrolrenderer.html +0 -893
- package/docs/classes/objectcontrolrenderer.html +0 -761
- package/docs/classes/rangecontrolrenderer.html +0 -792
- package/docs/classes/tablerenderer.html +0 -920
- package/docs/classes/textarearenderer.html +0 -739
- package/docs/classes/textcontrolrenderer.html +0 -760
- package/docs/classes/togglecontrolrenderer.html +0 -771
- package/docs/classes/verticallayoutrenderer.html +0 -426
- package/docs/globals.html +0 -606
- package/docs/index.html +0 -375
- package/docs/interfaces/columndescription.html +0 -192
- package/docs/interfaces/ownpropsofautocomplete.html +0 -327
- package/example/app/app.component.ts +0 -122
- package/example/app/app.module.ts +0 -42
- package/example/index.html +0 -25
- package/example/main.ts +0 -37
- package/test/autocomplete-control.spec.ts +0 -322
- package/test/boolean-control.spec.ts +0 -76
- package/test/categorization-tab-layout.spec.ts +0 -331
- package/test/date-control.spec.ts +0 -280
- package/test/group-layout.spec.ts +0 -104
- package/test/horizontal-layout.spec.ts +0 -94
- package/test/label-renderer.spec.ts +0 -78
- package/test/master-detail.spec.ts +0 -408
- package/test/number-control.spec.ts +0 -208
- package/test/object-control.spec.ts +0 -245
- package/test/range-control.spec.ts +0 -104
- package/test/table-control.spec.ts +0 -253
- package/test/text-area.spec.ts +0 -108
- package/test/text-control.spec.ts +0 -89
- package/test/toggle-control.spec.ts +0 -77
- package/test/tsconfig.test.json +0 -18
- package/test/util.ts +0 -28
- package/test/vertical-layout.spec.ts +0 -113
- package/test-config/karma-test-shim.js +0 -21
- package/test-config/karma.conf.js +0 -58
- package/test-config/protractor.conf.js +0 -28
- package/test-config/webpack.test.js +0 -65
- package/tsconfig.cjs.json +0 -9
- package/tsconfig.json +0 -16
- package/webpack/webpack.build.js +0 -13
- package/webpack/webpack.dev.js +0 -37
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { DebugElement } from '@angular/core';
|
|
26
|
-
import { ComponentFixture } from '@angular/core/testing';
|
|
27
|
-
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
28
|
-
import { ReactiveFormsModule } from '@angular/forms';
|
|
29
|
-
import { MatError, MatFormFieldModule } from '@angular/material/form-field';
|
|
30
|
-
import { MatInputModule } from '@angular/material/input';
|
|
31
|
-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
32
|
-
import { JsonFormsAngularService, JsonFormsControl } from '@jsonforms/angular';
|
|
33
|
-
import {
|
|
34
|
-
baseSetup,
|
|
35
|
-
ErrorTestExpectation,
|
|
36
|
-
getJsonFormsService,
|
|
37
|
-
numberAdditionalPropsTest,
|
|
38
|
-
numberBaseTest,
|
|
39
|
-
numberErrorTest,
|
|
40
|
-
numberInputEventTest,
|
|
41
|
-
prepareComponent
|
|
42
|
-
} from '@jsonforms/angular-test';
|
|
43
|
-
import { Actions, ControlElement, JsonFormsCore } from '@jsonforms/core';
|
|
44
|
-
import { NumberControlRenderer, NumberControlRendererTester } from '../src';
|
|
45
|
-
|
|
46
|
-
describe('Material number field tester', () => {
|
|
47
|
-
const uischema = {
|
|
48
|
-
type: 'Control',
|
|
49
|
-
scope: '#/properties/foo'
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
it('should succeed with floats', () => {
|
|
53
|
-
expect(
|
|
54
|
-
NumberControlRendererTester(uischema, {
|
|
55
|
-
type: 'object',
|
|
56
|
-
properties: {
|
|
57
|
-
foo: {
|
|
58
|
-
type: 'number'
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}, undefined)
|
|
62
|
-
).toBe(2);
|
|
63
|
-
});
|
|
64
|
-
it('should succeed with integers', () => {
|
|
65
|
-
expect(
|
|
66
|
-
NumberControlRendererTester(uischema, {
|
|
67
|
-
type: 'object',
|
|
68
|
-
properties: {
|
|
69
|
-
foo: {
|
|
70
|
-
type: 'integer'
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, undefined)
|
|
74
|
-
).toBe(2);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const imports = [
|
|
79
|
-
MatFormFieldModule,
|
|
80
|
-
MatInputModule,
|
|
81
|
-
NoopAnimationsModule,
|
|
82
|
-
ReactiveFormsModule,
|
|
83
|
-
FlexLayoutModule
|
|
84
|
-
];
|
|
85
|
-
const providers = [JsonFormsAngularService];
|
|
86
|
-
const componentUT: any = NumberControlRenderer;
|
|
87
|
-
const errorTest: ErrorTestExpectation = {
|
|
88
|
-
errorInstance: MatError,
|
|
89
|
-
numberOfElements: 1,
|
|
90
|
-
indexOfElement: 0
|
|
91
|
-
};
|
|
92
|
-
const toSelect = (el: DebugElement) => el.nativeElement;
|
|
93
|
-
const testConfig = { imports, providers, componentUT };
|
|
94
|
-
|
|
95
|
-
describe(
|
|
96
|
-
'Number control Base Tests',
|
|
97
|
-
numberBaseTest(testConfig, 'input', toSelect)
|
|
98
|
-
);
|
|
99
|
-
describe(
|
|
100
|
-
'Number control Input Event Tests',
|
|
101
|
-
numberInputEventTest(testConfig, 'input', toSelect)
|
|
102
|
-
);
|
|
103
|
-
describe('Number control Error Tests', numberErrorTest(testConfig, errorTest));
|
|
104
|
-
describe(
|
|
105
|
-
'Number control Additional Props Tests',
|
|
106
|
-
numberAdditionalPropsTest(testConfig, 'input', toSelect)
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
describe(
|
|
110
|
-
'Number control custom', () => {
|
|
111
|
-
let fixture: ComponentFixture<any>;
|
|
112
|
-
let numberNativeElement: any;
|
|
113
|
-
let component: JsonFormsControl;
|
|
114
|
-
baseSetup(testConfig);
|
|
115
|
-
|
|
116
|
-
const defaultSchema = {
|
|
117
|
-
type: 'object',
|
|
118
|
-
properties: {
|
|
119
|
-
foo: { type: 'number' }
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
const defaultData = {foo:1000000};
|
|
123
|
-
const defaultUischema: ControlElement = {
|
|
124
|
-
type: 'Control',
|
|
125
|
-
scope: '#/properties/foo'
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
beforeEach(() => {
|
|
129
|
-
const preparedComponents = prepareComponent(
|
|
130
|
-
testConfig, 'input', toSelect);
|
|
131
|
-
fixture = preparedComponents.fixture;
|
|
132
|
-
numberNativeElement = preparedComponents.numberNativeElement;
|
|
133
|
-
component = preparedComponents.component;
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('default grouping behavior', () => {
|
|
137
|
-
const uischema = Object.assign({},defaultUischema);
|
|
138
|
-
component.uischema = uischema;
|
|
139
|
-
const state:JsonFormsCore = {
|
|
140
|
-
data: defaultData,
|
|
141
|
-
schema: defaultSchema,
|
|
142
|
-
uischema: uischema
|
|
143
|
-
};
|
|
144
|
-
getJsonFormsService(component).init({
|
|
145
|
-
core: state, i18n: {
|
|
146
|
-
locale: 'en',
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
getJsonFormsService(component).updateCore(
|
|
150
|
-
Actions.init(state.data, state.schema)
|
|
151
|
-
);
|
|
152
|
-
component.ngOnInit();
|
|
153
|
-
fixture.detectChanges();
|
|
154
|
-
|
|
155
|
-
expect(numberNativeElement.value).toBe('1,000,000');
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('should use config for grouping', () => {
|
|
159
|
-
const uischema = Object.assign({},defaultUischema);
|
|
160
|
-
component.uischema = uischema;
|
|
161
|
-
const state:JsonFormsCore = {
|
|
162
|
-
data: defaultData,
|
|
163
|
-
schema: defaultSchema,
|
|
164
|
-
uischema: uischema
|
|
165
|
-
};
|
|
166
|
-
getJsonFormsService(component).init({
|
|
167
|
-
core: state, i18n: {
|
|
168
|
-
locale: 'en',
|
|
169
|
-
},config: {
|
|
170
|
-
useGrouping: false
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
getJsonFormsService(component).updateCore(
|
|
174
|
-
Actions.init(state.data, state.schema)
|
|
175
|
-
);
|
|
176
|
-
component.ngOnInit();
|
|
177
|
-
fixture.detectChanges();
|
|
178
|
-
|
|
179
|
-
expect(numberNativeElement.value).toBe('1000000');
|
|
180
|
-
});
|
|
181
|
-
it('should use uischema for grouping', () => {
|
|
182
|
-
const uischema = Object.assign({},defaultUischema);
|
|
183
|
-
uischema.options = {
|
|
184
|
-
useGrouping: false
|
|
185
|
-
}
|
|
186
|
-
component.uischema = uischema;
|
|
187
|
-
const state:JsonFormsCore = {
|
|
188
|
-
data: defaultData,
|
|
189
|
-
schema: defaultSchema,
|
|
190
|
-
uischema: uischema
|
|
191
|
-
};
|
|
192
|
-
getJsonFormsService(component).init({
|
|
193
|
-
core: state, i18n: {
|
|
194
|
-
locale: 'en',
|
|
195
|
-
},config: {
|
|
196
|
-
useGrouping: true
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
getJsonFormsService(component).updateCore(
|
|
200
|
-
Actions.init(state.data, state.schema)
|
|
201
|
-
);
|
|
202
|
-
component.ngOnInit();
|
|
203
|
-
fixture.detectChanges();
|
|
204
|
-
|
|
205
|
-
expect(numberNativeElement.value).toBe('1000000');
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
);
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
|
26
|
-
import { CommonModule } from '@angular/common';
|
|
27
|
-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
28
|
-
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
29
|
-
import { ReactiveFormsModule } from '@angular/forms';
|
|
30
|
-
import { MatCardModule } from '@angular/material/card';
|
|
31
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
32
|
-
import { MatInputModule } from '@angular/material/input';
|
|
33
|
-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
34
|
-
import { JsonFormsAngularService, JsonFormsModule } from '@jsonforms/angular';
|
|
35
|
-
import { ControlElement } from '@jsonforms/core';
|
|
36
|
-
import {
|
|
37
|
-
GroupLayoutRenderer,
|
|
38
|
-
groupLayoutTester,
|
|
39
|
-
TextControlRenderer,
|
|
40
|
-
TextControlRendererTester,
|
|
41
|
-
VerticalLayoutRenderer,
|
|
42
|
-
verticalLayoutTester
|
|
43
|
-
} from '../src';
|
|
44
|
-
import {
|
|
45
|
-
ObjectControlRenderer,
|
|
46
|
-
ObjectControlRendererTester
|
|
47
|
-
} from '../src/other/object.renderer';
|
|
48
|
-
import { getJsonFormsService } from '@jsonforms/angular-test';
|
|
49
|
-
|
|
50
|
-
const uischema1: ControlElement = { type: 'Control', scope: '#' };
|
|
51
|
-
const uischema2: ControlElement = {
|
|
52
|
-
type: 'Control',
|
|
53
|
-
scope: '#/properties/foo'
|
|
54
|
-
};
|
|
55
|
-
const schema1 = {
|
|
56
|
-
type: 'object',
|
|
57
|
-
properties: {
|
|
58
|
-
foo: { type: 'string' }
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const schema2 = {
|
|
62
|
-
type: 'object',
|
|
63
|
-
properties: {
|
|
64
|
-
foo: {
|
|
65
|
-
type: 'object',
|
|
66
|
-
properties: {
|
|
67
|
-
foo_1: { type: 'string' }
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
bar: {
|
|
71
|
-
type: 'object',
|
|
72
|
-
properties: {
|
|
73
|
-
bar_1: { type: 'string' }
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const renderers = [
|
|
79
|
-
{ tester: TextControlRendererTester, renderer: TextControlRenderer },
|
|
80
|
-
{ tester: verticalLayoutTester, renderer: VerticalLayoutRenderer },
|
|
81
|
-
{ tester: groupLayoutTester, renderer: GroupLayoutRenderer },
|
|
82
|
-
{ tester: ObjectControlRendererTester, renderer: ObjectControlRenderer }
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
describe('Object Control tester', () => {
|
|
86
|
-
it('should succeed', () => {
|
|
87
|
-
expect(ObjectControlRendererTester(uischema1, schema1, undefined)).toBe(2);
|
|
88
|
-
expect(ObjectControlRendererTester(uischema2, schema2, undefined)).toBe(2);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
describe('Object Control', () => {
|
|
92
|
-
let fixture: ComponentFixture<any>;
|
|
93
|
-
let component: any;
|
|
94
|
-
|
|
95
|
-
beforeEach(async(() => {
|
|
96
|
-
TestBed.configureTestingModule({
|
|
97
|
-
declarations: [
|
|
98
|
-
ObjectControlRenderer,
|
|
99
|
-
TextControlRenderer,
|
|
100
|
-
VerticalLayoutRenderer,
|
|
101
|
-
GroupLayoutRenderer
|
|
102
|
-
],
|
|
103
|
-
imports: [
|
|
104
|
-
CommonModule,
|
|
105
|
-
JsonFormsModule,
|
|
106
|
-
MatCardModule,
|
|
107
|
-
NoopAnimationsModule,
|
|
108
|
-
MatFormFieldModule,
|
|
109
|
-
MatInputModule,
|
|
110
|
-
ReactiveFormsModule,
|
|
111
|
-
FlexLayoutModule
|
|
112
|
-
],
|
|
113
|
-
providers: [JsonFormsAngularService]
|
|
114
|
-
})
|
|
115
|
-
.overrideModule(BrowserDynamicTestingModule, {
|
|
116
|
-
set: {
|
|
117
|
-
entryComponents: [
|
|
118
|
-
TextControlRenderer,
|
|
119
|
-
VerticalLayoutRenderer,
|
|
120
|
-
GroupLayoutRenderer,
|
|
121
|
-
ObjectControlRenderer
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
.compileComponents();
|
|
126
|
-
|
|
127
|
-
fixture = TestBed.createComponent(ObjectControlRenderer);
|
|
128
|
-
component = fixture.componentInstance;
|
|
129
|
-
}));
|
|
130
|
-
|
|
131
|
-
it('object control creates group', async(() => {
|
|
132
|
-
component.uischema = uischema2;
|
|
133
|
-
component.schema = schema2;
|
|
134
|
-
|
|
135
|
-
getJsonFormsService(component).init({
|
|
136
|
-
|
|
137
|
-
renderers: renderers,
|
|
138
|
-
core: {
|
|
139
|
-
data: {},
|
|
140
|
-
schema: schema2,
|
|
141
|
-
uischema: undefined
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
fixture.detectChanges();
|
|
146
|
-
component.ngOnInit();
|
|
147
|
-
fixture.whenStable().then(() => {
|
|
148
|
-
// one for the object renderer and one for the group
|
|
149
|
-
expect(fixture.nativeElement.querySelectorAll('mat-card').length).toBe(2);
|
|
150
|
-
expect(
|
|
151
|
-
fixture.nativeElement.querySelectorAll('mat-card-title')[0].textContent
|
|
152
|
-
).toBe('Foo');
|
|
153
|
-
});
|
|
154
|
-
}));
|
|
155
|
-
|
|
156
|
-
it('render all elements', async(() => {
|
|
157
|
-
|
|
158
|
-
component.uischema = uischema1;
|
|
159
|
-
component.schema = schema2;
|
|
160
|
-
|
|
161
|
-
getJsonFormsService(component).init({
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
core: {
|
|
165
|
-
data: {},
|
|
166
|
-
schema: schema2,
|
|
167
|
-
uischema: undefined
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
});
|
|
171
|
-
getJsonFormsService(component).registerRenderers(renderers);
|
|
172
|
-
|
|
173
|
-
fixture.detectChanges();
|
|
174
|
-
component.ngOnInit();
|
|
175
|
-
fixture.whenStable().then(() => {
|
|
176
|
-
expect(fixture.nativeElement.querySelectorAll('input').length).toBe(2);
|
|
177
|
-
});
|
|
178
|
-
}));
|
|
179
|
-
|
|
180
|
-
it('render only own elements', async(() => {
|
|
181
|
-
component.uischema = uischema2;
|
|
182
|
-
component.schema = schema2;
|
|
183
|
-
|
|
184
|
-
getJsonFormsService(component).init({
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
core: {
|
|
188
|
-
data: {},
|
|
189
|
-
schema: schema2,
|
|
190
|
-
uischema: undefined
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
getJsonFormsService(component).registerRenderers(renderers);
|
|
195
|
-
fixture.detectChanges();
|
|
196
|
-
component.ngOnInit();
|
|
197
|
-
fixture.whenStable().then(() => {
|
|
198
|
-
expect(fixture.nativeElement.querySelectorAll('input').length).toBe(1);
|
|
199
|
-
});
|
|
200
|
-
}));
|
|
201
|
-
|
|
202
|
-
xit('can be disabled', async(() => {
|
|
203
|
-
|
|
204
|
-
component.uischema = uischema1;
|
|
205
|
-
component.schema = schema1;
|
|
206
|
-
component.disabled = true;
|
|
207
|
-
|
|
208
|
-
getJsonFormsService(component).init({
|
|
209
|
-
|
|
210
|
-
core: {
|
|
211
|
-
data: {},
|
|
212
|
-
schema: schema1,
|
|
213
|
-
uischema: undefined
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
});
|
|
217
|
-
getJsonFormsService(component).registerRenderers(renderers);
|
|
218
|
-
fixture.detectChanges();
|
|
219
|
-
component.ngOnInit();
|
|
220
|
-
fixture.whenStable().then(() => {
|
|
221
|
-
expect(fixture.nativeElement.querySelector('input').disabled).toBe(true);
|
|
222
|
-
});
|
|
223
|
-
}));
|
|
224
|
-
xit('should be enabled by default', async(() => {
|
|
225
|
-
|
|
226
|
-
component.uischema = uischema1;
|
|
227
|
-
component.schema = schema1;
|
|
228
|
-
|
|
229
|
-
getJsonFormsService(component).init({
|
|
230
|
-
core: {
|
|
231
|
-
data: {},
|
|
232
|
-
schema: schema1,
|
|
233
|
-
uischema: undefined
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
});
|
|
237
|
-
getJsonFormsService(component).registerRenderers(renderers);
|
|
238
|
-
component.ngOnInit();
|
|
239
|
-
fixture.detectChanges();
|
|
240
|
-
fixture.whenRenderingDone().then(() => {
|
|
241
|
-
fixture.detectChanges();
|
|
242
|
-
expect(fixture.nativeElement.querySelector('input').disabled).toBeFalsy();
|
|
243
|
-
});
|
|
244
|
-
}));
|
|
245
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import { ReactiveFormsModule } from '@angular/forms';
|
|
26
|
-
import { MatError, MatFormFieldModule } from '@angular/material/form-field';
|
|
27
|
-
import { MatSlider, MatSliderModule } from '@angular/material/slider';
|
|
28
|
-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
29
|
-
import {
|
|
30
|
-
ErrorTestExpectation,
|
|
31
|
-
rangeBaseTest,
|
|
32
|
-
rangeErrorTest,
|
|
33
|
-
rangeInputEventTest
|
|
34
|
-
} from '@jsonforms/angular-test';
|
|
35
|
-
import { RangeControlRenderer, RangeControlRendererTester } from '../src';
|
|
36
|
-
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
37
|
-
import { JsonFormsAngularService } from '@jsonforms/angular';
|
|
38
|
-
|
|
39
|
-
describe('Material number field tester', () => {
|
|
40
|
-
const uischema = {
|
|
41
|
-
type: 'Control',
|
|
42
|
-
scope: '#/properties/foo',
|
|
43
|
-
options: { slider: true }
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
it('should succeed with floats', () => {
|
|
47
|
-
expect(
|
|
48
|
-
RangeControlRendererTester(uischema, {
|
|
49
|
-
type: 'object',
|
|
50
|
-
properties: {
|
|
51
|
-
foo: {
|
|
52
|
-
type: 'number',
|
|
53
|
-
minimum: -42.42,
|
|
54
|
-
maximum: 42.42,
|
|
55
|
-
default: 0.42
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, undefined)
|
|
59
|
-
).toBe(4);
|
|
60
|
-
});
|
|
61
|
-
it('should succeed with integers', () => {
|
|
62
|
-
expect(
|
|
63
|
-
RangeControlRendererTester(uischema, {
|
|
64
|
-
type: 'object',
|
|
65
|
-
properties: {
|
|
66
|
-
foo: {
|
|
67
|
-
type: 'integer',
|
|
68
|
-
minimum: -42,
|
|
69
|
-
maximum: 42,
|
|
70
|
-
default: 1
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, undefined)
|
|
74
|
-
).toBe(4);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
const imports = [
|
|
78
|
-
NoopAnimationsModule,
|
|
79
|
-
MatSliderModule,
|
|
80
|
-
MatFormFieldModule,
|
|
81
|
-
ReactiveFormsModule,
|
|
82
|
-
FlexLayoutModule
|
|
83
|
-
];
|
|
84
|
-
const providers = [JsonFormsAngularService];
|
|
85
|
-
const componentUT: any = RangeControlRenderer;
|
|
86
|
-
const errorTest: ErrorTestExpectation = {
|
|
87
|
-
errorInstance: MatError,
|
|
88
|
-
numberOfElements: 1,
|
|
89
|
-
indexOfElement: 0
|
|
90
|
-
};
|
|
91
|
-
const defaultTestConfig = { imports, providers, componentUT };
|
|
92
|
-
|
|
93
|
-
describe(
|
|
94
|
-
'Range control Base Tests',
|
|
95
|
-
rangeBaseTest(defaultTestConfig, MatSlider)
|
|
96
|
-
);
|
|
97
|
-
describe(
|
|
98
|
-
'Range control Input Event Tests',
|
|
99
|
-
rangeInputEventTest(defaultTestConfig, MatSlider)
|
|
100
|
-
);
|
|
101
|
-
describe(
|
|
102
|
-
'Range control Error Tests',
|
|
103
|
-
rangeErrorTest(defaultTestConfig, MatSlider, errorTest)
|
|
104
|
-
);
|