forked from p15670423/monkey
ui: separate json schema-related functions into JsonSchemaHelpers.js
This commit is contained in:
parent
8d024b9002
commit
11ea5e1a7e
|
@ -4,31 +4,10 @@ import {Form} from 'react-bootstrap';
|
||||||
import {cloneDeep} from 'lodash';
|
import {cloneDeep} from 'lodash';
|
||||||
|
|
||||||
import {getComponentHeight} from './utils/HeightCalculator';
|
import {getComponentHeight} from './utils/HeightCalculator';
|
||||||
import {resolveObjectPath} from './utils/ObjectPathResolver';
|
|
||||||
import InfoPane from './InfoPane';
|
import InfoPane from './InfoPane';
|
||||||
import {MasterCheckbox, MasterCheckboxState} from './MasterCheckbox';
|
import {MasterCheckbox, MasterCheckboxState} from './MasterCheckbox';
|
||||||
import ChildCheckbox from './ChildCheckbox';
|
import ChildCheckbox from './ChildCheckbox';
|
||||||
|
import {getFullDefinitionByKey, getDefaultPaneParams} from './JsonSchemaHelpers.js';
|
||||||
function getFullDefinitionByKey(refString, registry, itemKey) {
|
|
||||||
let fullArray = getFullDefinitionsFromRegistry(refString, registry);
|
|
||||||
return fullArray.filter(e => (e.enum[0] === itemKey))[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Definitions passed to components only contains value and label,
|
|
||||||
// custom fields like "info" or "links" must be pulled from registry object using this function
|
|
||||||
function getFullDefinitionsFromRegistry(refString, registry) {
|
|
||||||
return getObjectFromRegistryByRef(refString, registry).anyOf;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getObjectFromRegistryByRef(refString, registry) {
|
|
||||||
let refArray = refString.replace('#', '').split('/');
|
|
||||||
return resolveObjectPath(refArray, registry);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDefaultPaneParams(refString, registry) {
|
|
||||||
let configSection = getObjectFromRegistryByRef(refString, registry);
|
|
||||||
return ({title: configSection.title, content: configSection.description});
|
|
||||||
}
|
|
||||||
|
|
||||||
class AdvancedMultiSelect extends React.Component {
|
class AdvancedMultiSelect extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import {resolveObjectPath} from './utils/ObjectPathResolver';
|
||||||
|
|
||||||
|
function getFullDefinitionByKey(refString, registry, itemKey) {
|
||||||
|
let fullArray = getFullDefinitionsFromRegistry(refString, registry);
|
||||||
|
return fullArray.filter(e => (e.enum[0] === itemKey))[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Definitions passed to components only contains value and label,
|
||||||
|
// custom fields like "info" or "links" must be pulled from registry object using this function
|
||||||
|
function getFullDefinitionsFromRegistry(refString, registry) {
|
||||||
|
return getObjectFromRegistryByRef(refString, registry).anyOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getObjectFromRegistryByRef(refString, registry) {
|
||||||
|
let refArray = refString.replace('#', '').split('/');
|
||||||
|
return resolveObjectPath(refArray, registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDefaultPaneParams(refString, registry) {
|
||||||
|
let configSection = getObjectFromRegistryByRef(refString, registry);
|
||||||
|
return ({title: configSection.title, content: configSection.description});
|
||||||
|
}
|
||||||
|
|
||||||
|
export {getFullDefinitionByKey, getDefaultPaneParams};
|
Loading…
Reference in New Issue