Review apply
@ -6,7 +6,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: 4.3rem;
|
margin-top: 3.8rem;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
box-shadow: 0 2px 4px #e3e9f3;
|
box-shadow: 0 2px 4px #e3e9f3;
|
||||||
> a {
|
> a {
|
||||||
|
@ -10,9 +10,18 @@ const Wrapper = styled.div`
|
|||||||
padding: 1.9rem 3rem 1.8rem 3rem;
|
padding: 1.9rem 3rem 1.8rem 3rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
div {
|
||||||
|
p {
|
||||||
|
width: fit-content;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
button {
|
button {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 1.7rem;
|
top: 1.9rem;
|
||||||
right: 1rem;
|
right: 1rem;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,23 @@ import SubTitle from './SubTitle';
|
|||||||
import Title from './Title';
|
import Title from './Title';
|
||||||
import Wrapper from './Wrapper';
|
import Wrapper from './Wrapper';
|
||||||
|
|
||||||
function ListHeader({ button, subtitle, subtitleValues, title, titleValues }) {
|
function ListHeader({ button, subtitle, subtitleValues, title }) {
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
{button && <Button {...button} />}
|
{button && <Button {...button} />}
|
||||||
<FormattedMessage id={title} values={titleValues}>
|
<div>
|
||||||
{msg => <Title>{msg}</Title>}
|
{title.map(item => {
|
||||||
</FormattedMessage>
|
return (
|
||||||
|
<FormattedMessage
|
||||||
|
key={item.label}
|
||||||
|
id={item.label}
|
||||||
|
values={item.values}
|
||||||
|
>
|
||||||
|
{msg => <Title>{msg} </Title>}
|
||||||
|
</FormattedMessage>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
<FormattedMessage id={subtitle} values={subtitleValues}>
|
<FormattedMessage id={subtitle} values={subtitleValues}>
|
||||||
{msg => <SubTitle>{msg}</SubTitle>}
|
{msg => <SubTitle>{msg}</SubTitle>}
|
||||||
</FormattedMessage>
|
</FormattedMessage>
|
||||||
@ -24,16 +34,19 @@ ListHeader.defaultProps = {
|
|||||||
button: null,
|
button: null,
|
||||||
subtitle: 'app.utils.defaultMessage',
|
subtitle: 'app.utils.defaultMessage',
|
||||||
subtitleValues: {},
|
subtitleValues: {},
|
||||||
title: 'app.utils.defaultMessage',
|
title: null,
|
||||||
titleValues: {},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ListHeader.propTypes = {
|
ListHeader.propTypes = {
|
||||||
button: PropTypes.object,
|
button: PropTypes.object,
|
||||||
subtitle: PropTypes.string,
|
subtitle: PropTypes.string,
|
||||||
subtitleValues: PropTypes.object,
|
subtitleValues: PropTypes.object,
|
||||||
title: PropTypes.string,
|
title: PropTypes.arrayOf(
|
||||||
titleValues: PropTypes.object,
|
PropTypes.shape({
|
||||||
|
label: PropTypes.string,
|
||||||
|
values: PropTypes.object,
|
||||||
|
})
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ListHeader;
|
export default ListHeader;
|
||||||
|
@ -13,7 +13,7 @@ const ListWrapper = styled.div`
|
|||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
}
|
}
|
||||||
.list-button {
|
.list-button {
|
||||||
padding: 1rem 3rem 2.5rem 3rem;
|
padding: 1.3rem 3rem 2.5rem 3rem;
|
||||||
button {
|
button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,6 @@ export { default as PopUpWarning } from './components/PopUpWarning';
|
|||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
export { default as auth } from './utils/auth';
|
export { default as auth } from './utils/auth';
|
||||||
export { default as attributeIcons } from './utils/attributeIcons';
|
|
||||||
export { default as cleanData } from './utils/cleanData';
|
export { default as cleanData } from './utils/cleanData';
|
||||||
export { darken } from './utils/colors';
|
export { darken } from './utils/colors';
|
||||||
export { default as getQueryParameters } from './utils/getQueryParameters';
|
export { default as getQueryParameters } from './utils/getQueryParameters';
|
||||||
|
Before Width: | Height: | Size: 841 B After Width: | Height: | Size: 841 B |
Before Width: | Height: | Size: 1007 B After Width: | Height: | Size: 1007 B |
Before Width: | Height: | Size: 879 B After Width: | Height: | Size: 879 B |
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 438 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 848 B After Width: | Height: | Size: 848 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 356 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 625 B After Width: | Height: | Size: 625 B |
@ -8,8 +8,9 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { capitalize } from 'lodash';
|
import { capitalize } from 'lodash';
|
||||||
import { attributeIcons, IcoContainer } from 'strapi-helper-plugin';
|
import { IcoContainer } from 'strapi-helper-plugin';
|
||||||
|
|
||||||
|
import attributeIcons from '../../utils/attributeIcons';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
|
|
||||||
import styles from './styles.scss';
|
import styles from './styles.scss';
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { attributeIcons } from 'strapi-helper-plugin';
|
|
||||||
|
|
||||||
|
import attributeIcons from '../../utils/attributeIcons';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
|
|
||||||
import styles from './styles.scss';
|
import styles from './styles.scss';
|
||||||
|
@ -3,12 +3,15 @@ import PropTypes from 'prop-types';
|
|||||||
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
import { attributeIcons, PopUpWarning } from 'strapi-helper-plugin';
|
import { PopUpWarning } from 'strapi-helper-plugin';
|
||||||
|
|
||||||
|
import attributeIcons from '../../utils/attributeIcons';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
|
|
||||||
import StyledListRow from './StyledListRow';
|
import StyledListRow from './StyledListRow';
|
||||||
|
|
||||||
function ListRow({
|
function ListRow({
|
||||||
|
attributeId,
|
||||||
canOpenModal,
|
canOpenModal,
|
||||||
deleteAttribute,
|
deleteAttribute,
|
||||||
isTemporary,
|
isTemporary,
|
||||||
@ -47,9 +50,14 @@ function ListRow({
|
|||||||
)}
|
)}
|
||||||
</FormattedMessage>
|
</FormattedMessage>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isTemporary && (
|
{isTemporary && (
|
||||||
<FormattedMessage id={`${pluginId}.contentType.temporaryDisplay`} />
|
<FormattedMessage
|
||||||
|
id={`${pluginId}.contentType.temporaryDisplay`}
|
||||||
|
style={{
|
||||||
|
paddingLeft: '15px',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
@ -95,7 +103,7 @@ function ListRow({
|
|||||||
type="danger"
|
type="danger"
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
deleteAttribute(name);
|
deleteAttribute(attributeId);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
@ -112,6 +120,7 @@ ListRow.defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ListRow.propTypes = {
|
ListRow.propTypes = {
|
||||||
|
attributeId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
canOpenModal: PropTypes.bool,
|
canOpenModal: PropTypes.bool,
|
||||||
deleteAttribute: PropTypes.func,
|
deleteAttribute: PropTypes.func,
|
||||||
isTemporary: PropTypes.bool.isRequired,
|
isTemporary: PropTypes.bool.isRequired,
|
||||||
|
@ -43,10 +43,6 @@ import {
|
|||||||
SUBMIT_CONTENT_TYPE_SUCCEEDED,
|
SUBMIT_CONTENT_TYPE_SUCCEEDED,
|
||||||
SUBMIT_TEMP_CONTENT_TYPE,
|
SUBMIT_TEMP_CONTENT_TYPE,
|
||||||
SUBMIT_TEMP_CONTENT_TYPE_SUCCEEDED,
|
SUBMIT_TEMP_CONTENT_TYPE_SUCCEEDED,
|
||||||
SUBMIT_GROUP,
|
|
||||||
SUBMIT_GROUP_SUCCEEDED,
|
|
||||||
SUBMIT_TEMP_GROUP,
|
|
||||||
SUBMIT_TEMP_GROUP_SUCCEEDED,
|
|
||||||
UPDATE_TEMP_CONTENT_TYPE,
|
UPDATE_TEMP_CONTENT_TYPE,
|
||||||
ON_CHANGE_EXISTING_CONTENT_TYPE_MAIN_INFOS,
|
ON_CHANGE_EXISTING_CONTENT_TYPE_MAIN_INFOS,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
@ -438,42 +434,6 @@ export function updateTempContentType() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function submitGroup(oldGroupName, data, context, source) {
|
|
||||||
const attributes = formatGroupAttributes(data.attributes);
|
|
||||||
const body = Object.assign(cloneDeep(data), { attributes });
|
|
||||||
|
|
||||||
return {
|
|
||||||
type: SUBMIT_GROUP,
|
|
||||||
oldGroupName,
|
|
||||||
body,
|
|
||||||
source,
|
|
||||||
context,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function submitGroupSucceeded() {
|
|
||||||
return {
|
|
||||||
type: SUBMIT_GROUP_SUCCEEDED,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function submitTempGroup(data, context) {
|
|
||||||
const attributes = formatGroupAttributes(data.attributes);
|
|
||||||
const body = Object.assign(cloneDeep(data), { attributes });
|
|
||||||
|
|
||||||
return {
|
|
||||||
type: SUBMIT_TEMP_GROUP,
|
|
||||||
body,
|
|
||||||
context,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function submitTempGroupSucceeded() {
|
|
||||||
return {
|
|
||||||
type: SUBMIT_TEMP_GROUP_SUCCEEDED,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
export const buildModelAttributes = attributes => {
|
export const buildModelAttributes = attributes => {
|
||||||
const formattedAttributes = attributes.reduce((acc, current) => {
|
const formattedAttributes = attributes.reduce((acc, current) => {
|
||||||
|
@ -259,27 +259,9 @@ function appReducer(state = initialState, action) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.update('newGroupClone', () => state.get('newGroup'));
|
.update('newGroupClone', () => state.get('newGroup'));
|
||||||
case DELETE_GROUP_ATTRIBUTE: {
|
case DELETE_GROUP_ATTRIBUTE:
|
||||||
const pathToAttributes = action.keys
|
return state.removeIn(action.keys);
|
||||||
.slice()
|
|
||||||
.reverse()
|
|
||||||
.splice(1)
|
|
||||||
.reverse();
|
|
||||||
const attributes = state.getIn(pathToAttributes);
|
|
||||||
const attributeName = action.keys.pop();
|
|
||||||
const attributeToDelete = attributes.findIndex(
|
|
||||||
attribute => attribute.get('name') === attributeName
|
|
||||||
);
|
|
||||||
|
|
||||||
return state.removeIn([...pathToAttributes, attributeToDelete]);
|
|
||||||
}
|
|
||||||
case DELETE_GROUP_SUCCEEDED:
|
case DELETE_GROUP_SUCCEEDED:
|
||||||
console.log({
|
|
||||||
st: state
|
|
||||||
.get('groups')
|
|
||||||
.findIndex(group => group.get('uid') === action.uid),
|
|
||||||
action,
|
|
||||||
});
|
|
||||||
return state.removeIn([
|
return state.removeIn([
|
||||||
'groups',
|
'groups',
|
||||||
state.get('groups').findIndex(group => group.get('uid') === action.uid),
|
state.get('groups').findIndex(group => group.get('uid') === action.uid),
|
||||||
|
@ -16,9 +16,9 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
EmptyAttributesBlock,
|
EmptyAttributesBlock,
|
||||||
getQueryParameters,
|
getQueryParameters,
|
||||||
ListWrapper,
|
|
||||||
ListHeader,
|
|
||||||
List,
|
List,
|
||||||
|
ListHeader,
|
||||||
|
ListWrapper,
|
||||||
} from 'strapi-helper-plugin';
|
} from 'strapi-helper-plugin';
|
||||||
|
|
||||||
import { deleteGroupAttribute } from '../App/actions';
|
import { deleteGroupAttribute } from '../App/actions';
|
||||||
@ -132,9 +132,15 @@ export class GroupPage extends React.Component {
|
|||||||
|
|
||||||
const attributes = this.getFeatureAttributes();
|
const attributes = this.getFeatureAttributes();
|
||||||
const attributesNumber = this.getFeatureAttributesLength();
|
const attributesNumber = this.getFeatureAttributesLength();
|
||||||
const listTitle = `${pluginId}.table.attributes.title.${
|
|
||||||
attributesNumber > 1 ? 'plural' : 'singular'
|
const title = [
|
||||||
}`;
|
{
|
||||||
|
label: `${pluginId}.table.attributes.title.${
|
||||||
|
attributesNumber > 1 ? 'plural' : 'singular'
|
||||||
|
}`,
|
||||||
|
values: { number: attributesNumber },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const buttonProps = {
|
const buttonProps = {
|
||||||
kind: 'secondaryHotlineAdd',
|
kind: 'secondaryHotlineAdd',
|
||||||
@ -153,26 +159,21 @@ export class GroupPage extends React.Component {
|
|||||||
>
|
>
|
||||||
{attributesNumber === 0 ? (
|
{attributesNumber === 0 ? (
|
||||||
<EmptyAttributesBlock
|
<EmptyAttributesBlock
|
||||||
description={`${pluginId}.home.emptyAttributes.description.${
|
description={`${pluginId}.home.emptyAttributes.description.${this.featureType}`}
|
||||||
this.featureType
|
|
||||||
}`}
|
|
||||||
id="openAddAttr"
|
id="openAddAttr"
|
||||||
label="content-type-builder.button.attributes.add"
|
label="content-type-builder.button.attributes.add"
|
||||||
title="content-type-builder.home.emptyAttributes.title"
|
title="content-type-builder.home.emptyAttributes.title"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ListWrapper>
|
<ListWrapper>
|
||||||
<ListHeader
|
<ListHeader title={title} button={{ ...buttonProps }} />
|
||||||
title={listTitle}
|
|
||||||
titleValues={{ number: attributesNumber }}
|
|
||||||
button={{ ...buttonProps }}
|
|
||||||
/>
|
|
||||||
<List>
|
<List>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
{attributes.map(attribute => (
|
{attributes.map((attribute, index) => (
|
||||||
<ListRow
|
<ListRow
|
||||||
key={attribute.name}
|
key={attribute.name}
|
||||||
|
attributeId={index}
|
||||||
{...attribute}
|
{...attribute}
|
||||||
canOpenModal={canOpenModal}
|
canOpenModal={canOpenModal}
|
||||||
context={this.context}
|
context={this.context}
|
||||||
|
@ -24,6 +24,9 @@ const Tr = styled.tr`
|
|||||||
button {
|
button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
p {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default Tr;
|
export default Tr;
|
||||||
|
@ -106,9 +106,14 @@ class HomePage extends React.Component {
|
|||||||
const displayedData = type === 'groups' ? groups : models;
|
const displayedData = type === 'groups' ? groups : models;
|
||||||
const availableNumber = type === 'groups' ? groups.length : models.length;
|
const availableNumber = type === 'groups' ? groups.length : models.length;
|
||||||
const titleType = type === 'groups' ? type : 'contentType';
|
const titleType = type === 'groups' ? type : 'contentType';
|
||||||
const title = `${pluginId}.table.${titleType}.title.${
|
const title = [
|
||||||
availableNumber > 1 ? 'plural' : 'singular'
|
{
|
||||||
}`;
|
label: `${pluginId}.table.${titleType}.title.${
|
||||||
|
availableNumber > 1 ? 'plural' : 'singular'
|
||||||
|
}`,
|
||||||
|
values: { number: availableNumber },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.homePage}>
|
<div className={styles.homePage}>
|
||||||
@ -132,7 +137,6 @@ class HomePage extends React.Component {
|
|||||||
<ListWrapper>
|
<ListWrapper>
|
||||||
<ListHeader
|
<ListHeader
|
||||||
title={title}
|
title={title}
|
||||||
titleValues={{ number: availableNumber }}
|
|
||||||
button={{
|
button={{
|
||||||
kind: 'secondaryHotlineAdd',
|
kind: 'secondaryHotlineAdd',
|
||||||
label: `${pluginId}.button.${type}.create`,
|
label: `${pluginId}.button.${type}.create`,
|
||||||
|
@ -107,9 +107,12 @@ describe('CTB <HomePage />', () => {
|
|||||||
const list = wrapper.find(ListHeader);
|
const list = wrapper.find(ListHeader);
|
||||||
|
|
||||||
expect(list).toHaveLength(1);
|
expect(list).toHaveLength(1);
|
||||||
expect(list.prop('title')).toBe(
|
expect(list.prop('title')).toMatchObject([
|
||||||
`${pluginId}.table.contentType.title.plural`
|
{
|
||||||
);
|
label: `${pluginId}.table.contentType.title.plural`,
|
||||||
|
values: { number: 4 },
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should handle the listheader title correctly if there is more than 1 group', () => {
|
it('Should handle the listheader title correctly if there is more than 1 group', () => {
|
||||||
@ -120,7 +123,12 @@ describe('CTB <HomePage />', () => {
|
|||||||
const list = wrapper.find(ListHeader);
|
const list = wrapper.find(ListHeader);
|
||||||
|
|
||||||
expect(list).toHaveLength(1);
|
expect(list).toHaveLength(1);
|
||||||
expect(list.prop('title')).toBe(`${pluginId}.table.groups.title.plural`);
|
expect(list.prop('title')).toMatchObject([
|
||||||
|
{
|
||||||
|
label: `${pluginId}.table.groups.title.plural`,
|
||||||
|
values: { number: 4 },
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should handle the listheader title correctly if there is less than 2 groups', () => {
|
it('Should handle the listheader title correctly if there is less than 2 groups', () => {
|
||||||
@ -140,9 +148,12 @@ describe('CTB <HomePage />', () => {
|
|||||||
const list = wrapper.find(ListHeader);
|
const list = wrapper.find(ListHeader);
|
||||||
|
|
||||||
expect(list).toHaveLength(1);
|
expect(list).toHaveLength(1);
|
||||||
expect(list.prop('title')).toBe(
|
expect(list.prop('title')).toMatchObject([
|
||||||
`${pluginId}.table.groups.title.singular`
|
{
|
||||||
);
|
label: `${pluginId}.table.groups.title.singular`,
|
||||||
|
values: { number: 1 },
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should handle the listheader title correctly if there is less than 2 models', () => {
|
it('Should handle the listheader title correctly if there is less than 2 models', () => {
|
||||||
@ -161,9 +172,12 @@ describe('CTB <HomePage />', () => {
|
|||||||
const list = wrapper.find(ListHeader);
|
const list = wrapper.find(ListHeader);
|
||||||
|
|
||||||
expect(list).toHaveLength(1);
|
expect(list).toHaveLength(1);
|
||||||
expect(list.prop('title')).toBe(
|
expect(list.prop('title')).toMatchObject([
|
||||||
`${pluginId}.table.contentType.title.singular`
|
{
|
||||||
);
|
label: `${pluginId}.table.contentType.title.singular`,
|
||||||
|
values: { number: 1 },
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ const StyledLeftMenu = styled.div`
|
|||||||
i {
|
i {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
top: calc(50% - ${sizes.margin * 0.5}px);
|
top: calc(50% - ${sizes.margin * 0.5}px);
|
||||||
color: ${colors.grey};
|
color: ${colors.leftMenu.grey};
|
||||||
}
|
}
|
||||||
&.active {
|
&.active {
|
||||||
background-color: ${colors.leftMenu.lightGrey};
|
background-color: ${colors.leftMenu.lightGrey};
|
||||||
|
@ -17,6 +17,9 @@ import {
|
|||||||
BackHeader,
|
BackHeader,
|
||||||
Button,
|
Button,
|
||||||
EmptyAttributesBlock,
|
EmptyAttributesBlock,
|
||||||
|
List,
|
||||||
|
ListHeader,
|
||||||
|
ListWrapper,
|
||||||
PopUpWarning,
|
PopUpWarning,
|
||||||
routerPropTypes,
|
routerPropTypes,
|
||||||
getQueryParameters,
|
getQueryParameters,
|
||||||
@ -539,6 +542,34 @@ export class ModelPage extends React.Component {
|
|||||||
const attributeType = this.getAttributeType();
|
const attributeType = this.getAttributeType();
|
||||||
const actionType = this.getActionType();
|
const actionType = this.getActionType();
|
||||||
|
|
||||||
|
// const attributes = this.getModelAttributes();
|
||||||
|
const attributesNumber = this.getModelAttributesLength();
|
||||||
|
const relationsNumber = this.getModelRelationShipsLength();
|
||||||
|
|
||||||
|
let title = [
|
||||||
|
{
|
||||||
|
label: `${pluginId}.table.attributes.title.${
|
||||||
|
attributesNumber > 1 ? 'plural' : 'singular'
|
||||||
|
}`,
|
||||||
|
values: { number: attributesNumber },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
if (relationsNumber > 0) {
|
||||||
|
title.push({
|
||||||
|
label: `${pluginId}.table.relations.title.${
|
||||||
|
attributesNumber > 1 ? 'plural' : 'singular'
|
||||||
|
}`,
|
||||||
|
values: { number: relationsNumber },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const buttonProps = {
|
||||||
|
kind: 'secondaryHotlineAdd',
|
||||||
|
label: `${pluginId}.button.attributes.add`,
|
||||||
|
onClick: () => this.handleClickOpenModalChooseAttributes(),
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.modelpage}>
|
<div className={styles.modelpage}>
|
||||||
<BackHeader onClick={this.handleGoBack} />
|
<BackHeader onClick={this.handleGoBack} />
|
||||||
@ -559,7 +590,7 @@ export class ModelPage extends React.Component {
|
|||||||
pluginHeaderActions={this.getPluginHeaderActions()}
|
pluginHeaderActions={this.getPluginHeaderActions()}
|
||||||
onClickIcon={this.handleClickEditModelMainInfos}
|
onClickIcon={this.handleClickEditModelMainInfos}
|
||||||
>
|
>
|
||||||
{this.getModelAttributesLength() === 0 ? (
|
{attributesNumber === 0 ? (
|
||||||
<EmptyAttributesBlock
|
<EmptyAttributesBlock
|
||||||
description="content-type-builder.home.emptyAttributes.description"
|
description="content-type-builder.home.emptyAttributes.description"
|
||||||
id="openAddAttr"
|
id="openAddAttr"
|
||||||
@ -568,51 +599,75 @@ export class ModelPage extends React.Component {
|
|||||||
title="content-type-builder.home.emptyAttributes.title"
|
title="content-type-builder.home.emptyAttributes.title"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Block>
|
<ListWrapper>
|
||||||
<Flex>
|
<ListHeader title={title} button={{ ...buttonProps }} />
|
||||||
<ListTitle>
|
{/* <List>
|
||||||
{this.getModelAttributesLength()}
|
<table>
|
||||||
|
<tbody>
|
||||||
<FormattedMessage
|
{attributes.map(attribute => (
|
||||||
id={`${listTitleMessageIdBasePrefix}.${
|
<ListRow
|
||||||
this.getModelAttributesLength() > 1
|
key={attribute.name}
|
||||||
? 'plural'
|
{...attribute}
|
||||||
: 'singular'
|
canOpenModal={canOpenModal}
|
||||||
}`}
|
context={this.context}
|
||||||
/>
|
deleteAttribute={this.handleDeleteGroupAttribute}
|
||||||
{this.getModelRelationShipsLength() > 0 && (
|
isTemporary={false}
|
||||||
<React.Fragment>
|
type={attribute.type}
|
||||||
|
|
||||||
<FormattedMessage
|
|
||||||
id={`${listTitleMessageIdBasePrefix}.including`}
|
|
||||||
/>
|
/>
|
||||||
|
))}
|
||||||
{this.getModelRelationShipsLength()}
|
</tbody>
|
||||||
|
</table>
|
||||||
<FormattedMessage
|
</List> */}
|
||||||
id={`${pluginId}.modelPage.contentType.list.relationShipTitle.${
|
<div className="list-button">
|
||||||
this.getModelRelationShipsLength() > 1
|
<Button {...buttonProps} />
|
||||||
? 'plural'
|
|
||||||
: 'singular'
|
|
||||||
}`}
|
|
||||||
/>
|
|
||||||
</React.Fragment>
|
|
||||||
)}
|
|
||||||
</ListTitle>
|
|
||||||
<div>
|
|
||||||
<Button
|
|
||||||
label={`${pluginId}.button.attributes.add`}
|
|
||||||
onClick={this.handleClickOpenModalChooseAttributes}
|
|
||||||
secondaryHotlineAdd
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Flex>
|
|
||||||
<div>
|
|
||||||
<Ul id="attributesList">
|
|
||||||
{Object.keys(this.getModelAttributes()).map(this.renderLi)}
|
|
||||||
</Ul>
|
|
||||||
</div>
|
</div>
|
||||||
</Block>
|
|
||||||
|
<Block>
|
||||||
|
<Flex>
|
||||||
|
<ListTitle>
|
||||||
|
{this.getModelAttributesLength()}
|
||||||
|
|
||||||
|
<FormattedMessage
|
||||||
|
id={`${listTitleMessageIdBasePrefix}.${
|
||||||
|
this.getModelAttributesLength() > 1
|
||||||
|
? 'plural'
|
||||||
|
: 'singular'
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
{this.getModelRelationShipsLength() > 0 && (
|
||||||
|
<React.Fragment>
|
||||||
|
|
||||||
|
<FormattedMessage
|
||||||
|
id={`${listTitleMessageIdBasePrefix}.including`}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{this.getModelRelationShipsLength()}
|
||||||
|
|
||||||
|
<FormattedMessage
|
||||||
|
id={`${pluginId}.modelPage.contentType.list.relationShipTitle.${
|
||||||
|
this.getModelRelationShipsLength() > 1
|
||||||
|
? 'plural'
|
||||||
|
: 'singular'
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
)}
|
||||||
|
</ListTitle>
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
label={`${pluginId}.button.attributes.add`}
|
||||||
|
onClick={this.handleClickOpenModalChooseAttributes}
|
||||||
|
secondaryHotlineAdd
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Flex>
|
||||||
|
<div>
|
||||||
|
<Ul id="attributesList">
|
||||||
|
{Object.keys(this.getModelAttributes()).map(this.renderLi)}
|
||||||
|
</Ul>
|
||||||
|
</div>
|
||||||
|
</Block>
|
||||||
|
</ListWrapper>
|
||||||
)}
|
)}
|
||||||
</ViewContainer>
|
</ViewContainer>
|
||||||
|
|
||||||
|
@ -193,5 +193,7 @@
|
|||||||
"table.groups.title.singular": "{number} Group is available",
|
"table.groups.title.singular": "{number} Group is available",
|
||||||
"table.attributes.title.plural": "{number} fields",
|
"table.attributes.title.plural": "{number} fields",
|
||||||
"table.attributes.title.singular": "{number} field",
|
"table.attributes.title.singular": "{number} field",
|
||||||
|
"table.relations.title.plural": "including {number} relationships",
|
||||||
|
"table.relations.title.singular": "including {number} relationship",
|
||||||
"prompt.content.unsaved": "Are you sure you want to leave this content type? All your modifications will be lost."
|
"prompt.content.unsaved": "Are you sure you want to leave this content type? All your modifications will be lost."
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ module.exports = {
|
|||||||
model: 'file',
|
model: 'file',
|
||||||
via: 'related',
|
via: 'related',
|
||||||
plugin: 'upload',
|
plugin: 'upload',
|
||||||
type: 'media',
|
type: 'relation',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -51,7 +51,7 @@ module.exports = {
|
|||||||
model: 'file',
|
model: 'file',
|
||||||
via: 'related',
|
via: 'related',
|
||||||
plugin: 'upload',
|
plugin: 'upload',
|
||||||
type: 'media',
|
type: 'relation',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|