mirror of
https://github.com/strapi/strapi.git
synced 2025-10-30 01:17:28 +00:00
Created utils for relations
This commit is contained in:
parent
789e67fe11
commit
4d1dd0d083
@ -14,7 +14,7 @@ const MultipleMenuList = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { componentsGroupedByCategory } = useDataManager();
|
const { componentsGroupedByCategory } = useDataManager();
|
||||||
const Component = components.MenuList;
|
const Component = components.MenuList;
|
||||||
console.log({ menu: value.value });
|
|
||||||
const allComponentsCategory = Object.keys(componentsGroupedByCategory).reduce(
|
const allComponentsCategory = Object.keys(componentsGroupedByCategory).reduce(
|
||||||
(acc, current) => {
|
(acc, current) => {
|
||||||
const categoryCompos = componentsGroupedByCategory[current].map(compo => {
|
const categoryCompos = componentsGroupedByCategory[current].map(compo => {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ const Value = ({ children, ...props }) => {
|
|||||||
isMultiple,
|
isMultiple,
|
||||||
},
|
},
|
||||||
} = props;
|
} = props;
|
||||||
console.log({ value });
|
|
||||||
const displayedCategory = isCreatingComponent ? componentCategory : category;
|
const displayedCategory = isCreatingComponent ? componentCategory : category;
|
||||||
const displayedName = isCreatingComponent ? componentName : name;
|
const displayedName = isCreatingComponent ? componentName : name;
|
||||||
const style = { color: '#333740' };
|
const style = { color: '#333740' };
|
||||||
|
|||||||
@ -2,6 +2,10 @@ import { fromJS } from 'immutable';
|
|||||||
import pluralize from 'pluralize';
|
import pluralize from 'pluralize';
|
||||||
import makeUnique from '../../utils/makeUnique';
|
import makeUnique from '../../utils/makeUnique';
|
||||||
import { createComponentUid } from './utils/createUid';
|
import { createComponentUid } from './utils/createUid';
|
||||||
|
import {
|
||||||
|
shouldPluralizeName,
|
||||||
|
shouldPluralizeTargetAttribute,
|
||||||
|
} from './utils/relations';
|
||||||
|
|
||||||
const initialState = fromJS({
|
const initialState = fromJS({
|
||||||
formErrors: {},
|
formErrors: {},
|
||||||
@ -11,11 +15,6 @@ const initialState = fromJS({
|
|||||||
isCreatingComponentWhileAddingAField: false,
|
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) => {
|
const reducer = (state, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'ADD_COMPONENTS_TO_DYNAMIC_ZONE': {
|
case 'ADD_COMPONENTS_TO_DYNAMIC_ZONE': {
|
||||||
|
|||||||
@ -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 };
|
||||||
Loading…
x
Reference in New Issue
Block a user