Created utils for relations

This commit is contained in:
soupette 2019-11-29 07:53:23 +01:00
parent 789e67fe11
commit 4d1dd0d083
4 changed files with 13 additions and 7 deletions

View File

@ -14,7 +14,7 @@ const MultipleMenuList = ({
}) => {
const { componentsGroupedByCategory } = useDataManager();
const Component = components.MenuList;
console.log({ menu: value.value });
const allComponentsCategory = Object.keys(componentsGroupedByCategory).reduce(
(acc, current) => {
const categoryCompos = componentsGroupedByCategory[current].map(compo => {

View File

@ -24,7 +24,7 @@ const Value = ({ children, ...props }) => {
isMultiple,
},
} = props;
console.log({ value });
const displayedCategory = isCreatingComponent ? componentCategory : category;
const displayedName = isCreatingComponent ? componentName : name;
const style = { color: '#333740' };

View File

@ -2,6 +2,10 @@ import { fromJS } from 'immutable';
import pluralize from 'pluralize';
import makeUnique from '../../utils/makeUnique';
import { createComponentUid } from './utils/createUid';
import {
shouldPluralizeName,
shouldPluralizeTargetAttribute,
} from './utils/relations';
const initialState = fromJS({
formErrors: {},
@ -11,11 +15,6 @@ const initialState = fromJS({
isCreatingComponentWhileAddingAField: false,
});
export const shouldPluralizeTargetAttribute = nature =>
['manyToMany', 'manyToOne'].includes(nature) ? 2 : 1;
export const shouldPluralizeName = nature =>
['manyToMany', 'oneToMany', 'manyWay'].includes(nature) ? 2 : 1;
const reducer = (state, action) => {
switch (action.type) {
case 'ADD_COMPONENTS_TO_DYNAMIC_ZONE': {

View File

@ -0,0 +1,7 @@
const shouldPluralizeName = nature =>
['manyToMany', 'oneToMany', 'manyWay'].includes(nature) ? 2 : 1;
const shouldPluralizeTargetAttribute = nature =>
['manyToMany', 'manyToOne'].includes(nature) ? 2 : 1;
export { shouldPluralizeName, shouldPluralizeTargetAttribute };