diff --git a/packages/angular-material/src/other/table.renderer.ts b/packages/angular-material/src/other/table.renderer.ts index cf86b6ac0..05b2b298a 100644 --- a/packages/angular-material/src/other/table.renderer.ts +++ b/packages/angular-material/src/other/table.renderer.ts @@ -39,6 +39,7 @@ import { Paths, RankedTester, rankWith, + setReadonly, UISchemaElement } from '@jsonforms/core'; @@ -103,6 +104,9 @@ export class TableRenderer extends JsonFormsArrayControl { if (schema.type === 'object') { return this.getValidColumnProps(schema).map(prop => { const uischema = controlWithoutLabel(`#/properties/${prop}`); + if (!this.isEnabled()) { + setReadonly(uischema); + } return { property: prop, header: startCase(prop), diff --git a/packages/angular-material/test/table-control.spec.ts b/packages/angular-material/test/table-control.spec.ts index c100a345d..6f55f134c 100644 --- a/packages/angular-material/test/table-control.spec.ts +++ b/packages/angular-material/test/table-control.spec.ts @@ -248,7 +248,7 @@ describe('Table', () => { }); })); - xit('can be disabled', async(() => { + it('can be disabled', async(() => { const mockSubStore = MockNgRedux.getSelectorStub(); component.uischema = uischema1; component.schema = schema_object1; @@ -258,7 +258,7 @@ describe('Table', () => { jsonforms: { renderers: renderers, core: { - data: [], + data: [{ foo: 'foo_1', bar: 'bar_1' }], schema: schema_object1 } } @@ -267,7 +267,13 @@ describe('Table', () => { fixture.detectChanges(); component.ngOnInit(); fixture.whenStable().then(() => { - expect(fixture.nativeElement.querySelector('input').disabled).toBe(true); + expect(fixture.nativeElement.querySelectorAll('input').length).toBe(2); + expect( + fixture.nativeElement.querySelectorAll('input')[0].disabled + ).toBeTruthy(); + expect( + fixture.nativeElement.querySelectorAll('input')[1].disabled + ).toBeTruthy(); }); })); it('should be enabled by default', async(() => {