Skip to content

Commit 0a8f01b

Browse files
committed
angular
1 parent fda1838 commit 0a8f01b

File tree

11 files changed

+36
-91
lines changed

11 files changed

+36
-91
lines changed

package-lock.json

Lines changed: 3 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/angular-material/src/layouts/array-layout.renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export class ArrayLayoutRenderer
181181
}
182182
return {
183183
schema: this.scopedSchema,
184-
path: Paths.compose(this.propsPath, `${index}`),
184+
path: Paths.compose(this.propsPath, [`${index}`]),
185185
uischema
186186
};
187187
}

packages/angular-material/src/other/master-detail/master.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
THE SOFTWARE.
2424
*/
25-
import some from 'lodash/some';
25+
//import some from 'lodash/some';
2626
import get from 'lodash/get';
2727
import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
2828
import {
@@ -31,6 +31,7 @@ import {
3131
} from '@jsonforms/angular';
3232
import {
3333
ArrayControlProps,
34+
composePaths,
3435
ControlElement,
3536
createDefaultValue,
3637
findUISchema,
@@ -44,15 +45,15 @@ import {
4445
uiTypeIs
4546
} from '@jsonforms/core';
4647

47-
const keywords = ['#', 'properties', 'items'];
48+
//const keywords = ['#', 'properties', 'items'];
4849

49-
export const removeSchemaKeywords = (path: string[]) => {
50+
/*export const removeSchemaKeywords = (path: string[]) => {
5051
return path
5152
.split('/')
5253
.filter(s => !some(keywords, key => key === s))
5354
.join('.');
5455
};
55-
56+
*/
5657
@Component({
5758
selector: 'jsonforms-list-with-detail-master',
5859
template: `
@@ -180,14 +181,13 @@ export class MasterListComponent extends JsonFormsArrayControl {
180181
);
181182

182183
const masterItems = (data || []).map((d: any, index: number) => {
183-
const labelRefInstancePath = controlElement.options?.labelRef && removeSchemaKeywords(
184-
controlElement.options.labelRef
185-
);
184+
const labelRefInstancePath = controlElement.options?.labelRef &&
185+
controlElement.options.labelRef;
186186
const isPrimitive = d !== undefined && typeof d !== 'object';
187187
const masterItem = {
188188
label: isPrimitive ? d.toString() : get(d, labelRefInstancePath ?? getFirstPrimitiveProp(schema)),
189189
data: d,
190-
path: `${path}.${index}`,
190+
path: composePaths(path, [`${index}`]),
191191
schema,
192192
uischema: detailUISchema
193193
};

packages/angular-material/src/other/object.renderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export class ObjectControlRenderer extends JsonFormsControlWithDetail {
7070
if (isEmpty(props.path)) {
7171
this.detailUiSchema.type = 'VerticalLayout';
7272
} else {
73-
(this.detailUiSchema as GroupLayout).label = startCase(props.path);
73+
console.log(props.path);
74+
(this.detailUiSchema as GroupLayout).label = props.path.map(element=>startCase(element)).toString();
7475
}
7576
if (!this.isEnabled()) {
7677
setReadonly(this.detailUiSchema);

packages/angular-material/src/other/table.renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class TableRenderer extends JsonFormsArrayControl {
8888
this.displayedColumns = this.items.map(item => item.property);
8989
}
9090
getProps(index: number, props: OwnPropsOfRenderer): OwnPropsOfRenderer {
91-
const rowPath = Paths.compose(props.path, `${index}`);
91+
const rowPath = Paths.compose(props.path, [`${index}`]);
9292
return {
9393
schema: props.schema,
9494
uischema: props.uischema,

packages/angular-test/src/boolean.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const booleanBaseTest = <C extends JsonFormsControl, I>(
114114
fixture.detectChanges();
115115

116116
getJsonFormsService(component).updateCore(
117-
Actions.update('foo', () => false)
117+
Actions.update(['foo'], () => false)
118118
);
119119
fixture.detectChanges();
120120
expect(component.data).toBe(false);
@@ -130,7 +130,7 @@ export const booleanBaseTest = <C extends JsonFormsControl, I>(
130130
fixture.detectChanges();
131131

132132
getJsonFormsService(component).updateCore(
133-
Actions.update('foo', () => undefined)
133+
Actions.update(['foo'], () => undefined)
134134
);
135135
fixture.detectChanges();
136136
expect(component.data).toBe(undefined);
@@ -146,7 +146,7 @@ export const booleanBaseTest = <C extends JsonFormsControl, I>(
146146
fixture.detectChanges();
147147

148148
getJsonFormsService(component).updateCore(
149-
Actions.update('foo', () => null)
149+
Actions.update(['foo'], () => null)
150150
);
151151
fixture.detectChanges();
152152
expect(component.data).toBe(null);
@@ -162,10 +162,10 @@ export const booleanBaseTest = <C extends JsonFormsControl, I>(
162162
fixture.detectChanges();
163163

164164
getJsonFormsService(component).updateCore(
165-
Actions.update('foo', () => true)
165+
Actions.update(['foo'], () => true)
166166
);
167167
getJsonFormsService(component).updateCore(
168-
Actions.update('bar', () => false)
168+
Actions.update(['bar'], () => false)
169169
);
170170
fixture.detectChanges();
171171
expect(component.data).toBe(true);

packages/angular-test/src/number.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export const numberBaseTest = <C extends JsonFormsControl>(
175175
component.ngOnInit();
176176
fixture.detectChanges();
177177
getJsonFormsService(fixture.componentInstance).updateCore(
178-
Actions.update('foo', () => 456.456)
178+
Actions.update(['foo'], () => 456.456)
179179
);
180180
fixture.detectChanges();
181181
expect(component.data).toBe(456.456);
@@ -191,7 +191,7 @@ export const numberBaseTest = <C extends JsonFormsControl>(
191191
component.ngOnInit();
192192
fixture.detectChanges();
193193
getJsonFormsService(fixture.componentInstance).updateCore(
194-
Actions.update('foo', () => undefined)
194+
Actions.update(['foo'], () => undefined)
195195
);
196196
fixture.detectChanges();
197197

@@ -208,7 +208,7 @@ export const numberBaseTest = <C extends JsonFormsControl>(
208208
component.ngOnInit();
209209
fixture.detectChanges();
210210
getJsonFormsService(fixture.componentInstance).updateCore(
211-
Actions.update('foo', () => null)
211+
Actions.update(['foo'], () => null)
212212
);
213213
fixture.detectChanges();
214214
expect(component.data).toBe(null);
@@ -224,7 +224,7 @@ export const numberBaseTest = <C extends JsonFormsControl>(
224224
component.ngOnInit();
225225
fixture.detectChanges();
226226
getJsonFormsService(fixture.componentInstance).updateCore(
227-
Actions.update('bar', () => 456.456)
227+
Actions.update(['bar'], () => 456.456)
228228
);
229229
fixture.detectChanges();
230230
expect(component.data).toBe(123.123);

packages/angular-test/src/range.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export const rangeBaseTest = <C extends JsonFormsControl, I>(
152152
fixture.detectChanges();
153153

154154
getJsonFormsService(component).updateCore(
155-
Actions.update('foo', () => 4.56)
155+
Actions.update(['foo'], () => 4.56)
156156
);
157157
fixture.detectChanges();
158158
expect(component.data).toBe(4.56);
@@ -169,7 +169,7 @@ export const rangeBaseTest = <C extends JsonFormsControl, I>(
169169
fixture.detectChanges();
170170

171171
getJsonFormsService(component).updateCore(
172-
Actions.update('foo', () => undefined)
172+
Actions.update(['foo'], () => undefined)
173173
);
174174
fixture.detectChanges();
175175
expect(component.data).toBe(undefined);
@@ -186,7 +186,7 @@ export const rangeBaseTest = <C extends JsonFormsControl, I>(
186186
fixture.detectChanges();
187187

188188
getJsonFormsService(component).updateCore(
189-
Actions.update('foo', () => null)
189+
Actions.update(['foo'], () => null)
190190
);
191191
fixture.detectChanges();
192192
expect(component.data).toBe(null);
@@ -203,10 +203,10 @@ export const rangeBaseTest = <C extends JsonFormsControl, I>(
203203
fixture.detectChanges();
204204

205205
getJsonFormsService(component).updateCore(
206-
Actions.update('foo', () => 1.234)
206+
Actions.update(['foo'], () => 1.234)
207207
);
208208
getJsonFormsService(component).updateCore(
209-
Actions.update('bar', () => 456.456)
209+
Actions.update(['bar'], () => 456.456)
210210
);
211211

212212
fixture.detectChanges();

packages/angular-test/src/text.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const textBaseTest = <C extends JsonFormsControl>(
128128
fixture.detectChanges();
129129

130130
getJsonFormsService(component).updateCore(
131-
Actions.update('foo', () => 'bar')
131+
Actions.update(['foo'], () => 'bar')
132132
);
133133
fixture.detectChanges();
134134
expect(component.data).toBe('bar');
@@ -144,7 +144,7 @@ export const textBaseTest = <C extends JsonFormsControl>(
144144
fixture.detectChanges();
145145

146146
getJsonFormsService(component).updateCore(
147-
Actions.update('foo', () => undefined)
147+
Actions.update(['foo'], () => undefined)
148148
);
149149
fixture.detectChanges();
150150
expect(component.data).toBe(undefined);
@@ -160,7 +160,7 @@ export const textBaseTest = <C extends JsonFormsControl>(
160160
fixture.detectChanges();
161161

162162
getJsonFormsService(component).updateCore(
163-
Actions.update('foo', () => null)
163+
Actions.update(['foo'], () => null)
164164
);
165165
fixture.detectChanges();
166166
expect(component.data).toBe(null);
@@ -176,10 +176,10 @@ export const textBaseTest = <C extends JsonFormsControl>(
176176
fixture.detectChanges();
177177

178178
getJsonFormsService(component).updateCore(
179-
Actions.update('foo', () => 'foo')
179+
Actions.update(['foo'], () => 'foo')
180180
);
181181
getJsonFormsService(component).updateCore(
182-
Actions.update('bar', () => 'bar')
182+
Actions.update(['bar'], () => 'bar')
183183
);
184184
fixture.detectChanges();
185185
expect(component.data).toBe('foo');

packages/core/src/util/path.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,7 @@ import range from 'lodash/range';
2828
import { Scopable } from '../models';
2929

3030
export const compose = (path1: string[], path2: string[]) => {
31-
let p1 = path1;
32-
33-
if (isEmpty(p1)) {
34-
return path2;
35-
} else if (isEmpty(path2)) {
36-
return p1;
37-
} else {
38-
return p1.concat(path2);
39-
}
31+
return path1.concat(path2);
4032
};
4133

4234
export { compose as composePaths };

0 commit comments

Comments
 (0)