Skip to content

Commit

Permalink
[Angular] Add disable propagation to table
Browse files Browse the repository at this point in the history
  • Loading branch information
eneufeld committed May 17, 2019
1 parent 144f6d3 commit 644e7ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/angular-material/src/other/table.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
Paths,
RankedTester,
rankWith,
setReadonly,
UISchemaElement
} from '@jsonforms/core';

Expand Down Expand Up @@ -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),
Expand Down
12 changes: 9 additions & 3 deletions packages/angular-material/test/table-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -258,7 +258,7 @@ describe('Table', () => {
jsonforms: {
renderers: renderers,
core: {
data: [],
data: [{ foo: 'foo_1', bar: 'bar_1' }],
schema: schema_object1
}
}
Expand All @@ -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(() => {
Expand Down

0 comments on commit 644e7ff

Please sign in to comment.