Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// FIXME: is there a better way to control this?
// const count = this.nav.
// .getViews()
// .reduce((acc, view) => acc + (view.data.addToNavStack ? 1 : 0), 0);
// return count > 1;
return false;
}
goBack() {
return this.nav.pop();
}
}
export const categorizationTester: RankedTester = rankWith(
1,
and(uiTypeIs('Categorization'), categorizationHasCategory)
);
schemaMatches,
uiTypeIs,
update
} from '@jsonforms/core';
import { connect } from 'react-redux';
import Table, { TableBody, TableCell, TableHead, TableRow } from 'material-ui/Table';
import Typography from 'material-ui/Typography';
import Button from 'material-ui/Button';
import Toolbar from 'material-ui/Toolbar';
/**
* Tester for an array of objects.
* @type {RankedTester}
*/
export const tableArrayTester: RankedTester = rankWith(10, and(
uiTypeIs('Control'),
schemaMatches(schema =>
!_.isEmpty(schema)
&& schema.type === 'array'
&& !_.isEmpty(schema.items)
&& !Array.isArray(schema.items) // we don't care about tuples
&& (schema.items as JsonSchema).type === 'object'
))
);
export class TableArrayControl extends Renderer {
// TODO duplicate code
addNewItem(path: string) {
const element = {};
this.props.dispatch(
return (
);
}
}
const hasEnumAndText = (schemas: JsonSchema[]) => {
// idea: map to type,enum and check that all types are string and at least one item is of type enum,
const enumSchema = findEnumSchema(schemas);
const stringSchema = findTextSchema(schemas);
const remainingSchemas = schemas.filter(
s => s !== enumSchema || s !== stringSchema
);
const wrongType = remainingSchemas.find(s => s.type && s.type !== 'string');
return enumSchema && stringSchema && !wrongType;
};
const simpleAnyOf = and(
uiTypeIs('Control'),
schemaMatches(
schema => schema.hasOwnProperty('anyOf') && hasEnumAndText(schema.anyOf)
)
);
export const materialAnyOfStringOrEnumControlTester: RankedTester = rankWith(
5,
simpleAnyOf
);
export default withJsonFormsControlProps(MaterialAnyOfStringOrEnumControl);
// this.tabs.tabBar. forEach((tab: Tab, idx: number) => {
// if (contained.indexOf(tab.tabTitle) === -1) {
// indices.push(idx);
// }
// });
// indices.reverse().forEach(idx => this.tabs._tabs.splice(idx, 1));
};
trackByCategory(_i: number, categoryPage: any) {
return categoryPage.params.category.label;
}
}
export const categorizationTester: RankedTester = rankWith(
2,
and(uiTypeIs('Categorization'), categorizationHasCategory)
);
import {
and,
Categorization,
Category,
RankedTester,
rankWith,
uiTypeIs
} from '@jsonforms/core';
export const isCategorization = (
category: Category | Categorization
): category is Categorization => category.type === 'Categorization';
export const categorizationTester: RankedTester = rankWith(
1,
and(uiTypeIs('Categorization'), uischema => {
const hasCategory = (element: Categorization): boolean => {
if (isEmpty(element.elements)) {
return false;
}
return element.elements
.map(elem =>
isCategorization(elem) ? hasCategory(elem) : elem.type === 'Category'
)
.reduce((prev, curr) => prev && curr, true);
};
return hasCategory(uischema as Categorization);
})
);
schema={schema}
uischema={foundUISchema}
path={composePaths(path, `${selectedIndex}`)}
/>
) : (
No Selection
)}
);
};
export const materialListWithDetailTester: RankedTester = rankWith(
4,
and(uiTypeIs('ListWithDetail'), isObjectArray)
);
export default withJsonFormsArrayLayoutProps(MaterialListWithDetailRenderer);
import {
and,
Categorization,
Category,
isVisible,
RankedTester,
rankWith,
StatePropsOfLayout,
Tester,
UISchemaElement,
uiTypeIs,
} from '@jsonforms/core';
import { RendererComponent, withJsonFormsLayoutProps } from '@jsonforms/react';
import { MaterialLayoutRenderer, MaterialLayoutRendererProps } from '../util/layout';
export const isSingleLevelCategorization: Tester = and(
uiTypeIs('Categorization'),
(uischema: UISchemaElement): boolean => {
const categorization = uischema as Categorization;
return categorization.elements && categorization.elements.reduce((acc, e) => acc && e.type === 'Category', true);
}
);
export const materialCategorizationTester: RankedTester = rankWith(1, isSingleLevelCategorization);
export interface CategorizationState {
activeCategory: number;
}
export interface MaterialCategorizationLayoutRendererProps extends StatePropsOfLayout {
selected?: number;
ownState?: boolean;
.subscribe((state: JsonFormsState) => {
const props = mapStateToLayoutProps(state, this.getOwnProps());
this.hidden = !props.visible;
});
}
ngOnDestroy() {
if (this.subscription) {
this.subscription.unsubscribe();
}
}
}
export const categorizationTester: RankedTester = rankWith(
2,
and(uiTypeIs('Categorization'), categorizationHasCategory)
);
[id]="id"
>
`
})
export class BooleanToggleControlRenderer extends JsonFormsControl {
constructor(ngRedux: NgRedux) {
super(ngRedux);
}
isChecked = () => this.data || false;
getEventValue = (toggle: IonToggle) => toggle.value;
}
export const booleanToggleControlTester: RankedTester = rankWith(
3,
and(isBooleanControl, optionIs('toggle', true))
);
Categorization,
categorizationHasCategory,
Category,
isVisible,
optionIs,
RankedTester,
rankWith,
StatePropsOfLayout,
uiTypeIs
} from '@jsonforms/core';
import { RendererComponent, withJsonFormsLayoutProps } from '@jsonforms/react';
import { MaterialLayoutRenderer, MaterialLayoutRendererProps } from '../util/layout';
export const materialCategorizationStepperTester: RankedTester = rankWith(
2,
and(
uiTypeIs('Categorization'),
categorizationHasCategory,
optionIs('variant', 'stepper')
)
);
export interface CategorizationStepperState {
activeCategory: number;
}
export interface MaterialCategorizationStepperLayoutRendererProps extends StatePropsOfLayout {
data: any;
}
export class MaterialCategorizationStepperLayoutRenderer
extends RendererComponent {