mirror of
https://github.com/strapi/strapi.git
synced 2025-08-09 01:07:27 +00:00
Merge branch 'master' into chore/test-against-nodejs-8-10
This commit is contained in:
commit
5838d19f81
@ -16,6 +16,7 @@ import messages from './messages.json';
|
|||||||
|
|
||||||
function LeftMenuLinkContainer({ layout, plugins }) {
|
function LeftMenuLinkContainer({ layout, plugins }) {
|
||||||
const pluginsObject = plugins.toJS();
|
const pluginsObject = plugins.toJS();
|
||||||
|
|
||||||
// Generate the list of sections
|
// Generate the list of sections
|
||||||
const pluginsSections = Object.keys(pluginsObject).reduce((acc, current) => {
|
const pluginsSections = Object.keys(pluginsObject).reduce((acc, current) => {
|
||||||
pluginsObject[current].leftMenuSections.forEach((section = {}) => {
|
pluginsObject[current].leftMenuSections.forEach((section = {}) => {
|
||||||
@ -68,7 +69,7 @@ function LeftMenuLinkContainer({ layout, plugins }) {
|
|||||||
// Check if the plugins list is empty or not and display plugins by name
|
// Check if the plugins list is empty or not and display plugins by name
|
||||||
const pluginsLinks = !isEmpty(pluginsObject) ? (
|
const pluginsLinks = !isEmpty(pluginsObject) ? (
|
||||||
map(sortBy(pluginsObject, 'name'), plugin => {
|
map(sortBy(pluginsObject, 'name'), plugin => {
|
||||||
if (plugin.id !== 'email' && plugin.id !== 'content-manager') {
|
if (plugin.id !== 'email' && plugin.id !== 'content-manager' && plugin.id !== 'settings-manager') {
|
||||||
return (
|
return (
|
||||||
<LeftMenuLink
|
<LeftMenuLink
|
||||||
key={get(plugin, 'id')}
|
key={get(plugin, 'id')}
|
||||||
@ -85,6 +86,8 @@ function LeftMenuLinkContainer({ layout, plugins }) {
|
|||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const hasSettingsManager = get(pluginsObject, 'settings-manager', null);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.leftMenuLinkContainer}>
|
<div className={styles.leftMenuLinkContainer}>
|
||||||
{linkSections}
|
{linkSections}
|
||||||
@ -105,11 +108,13 @@ function LeftMenuLinkContainer({ layout, plugins }) {
|
|||||||
label={messages.installNewPlugin.id}
|
label={messages.installNewPlugin.id}
|
||||||
destination="/install-plugin"
|
destination="/install-plugin"
|
||||||
/>
|
/>
|
||||||
<LeftMenuLink
|
{hasSettingsManager && (
|
||||||
icon="gear"
|
<LeftMenuLink
|
||||||
label={messages.configuration.id}
|
icon="gear"
|
||||||
destination="/configuration"
|
label={messages.configuration.id}
|
||||||
/>
|
destination="/plugins/settings-manager"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,3 +21,7 @@ button {
|
|||||||
margin-right: -2rem;
|
margin-right: -2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form .row {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* PopUpRelations
|
* PopUpRelations
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { findIndex, get, isEmpty, map, take, takeRight } from 'lodash';
|
import { findIndex, get, isEmpty, map, take, takeRight } from 'lodash';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
import pluralize from 'pluralize';
|
||||||
|
|
||||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||||
import Input from 'components/InputsIndex';
|
import Input from 'components/InputsIndex';
|
||||||
@ -17,12 +18,21 @@ import RelationNaturePicker from 'components/RelationNaturePicker';
|
|||||||
import styles from './styles.scss';
|
import styles from './styles.scss';
|
||||||
|
|
||||||
/* eslint-disable jsx-a11y/tabindex-no-positive */
|
/* eslint-disable jsx-a11y/tabindex-no-positive */
|
||||||
class PopUpRelations extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
class PopUpRelations extends React.Component {
|
||||||
|
// eslint-disable-line react/prefer-stateless-function
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.popUpHeaderNavLinks = [
|
this.popUpHeaderNavLinks = [
|
||||||
{ name: 'defineRelation', message: 'content-type-builder.popUpForm.navContainer.relation', nameToReplace: 'advancedSettings' },
|
{
|
||||||
{ name: 'advancedSettings', message: 'content-type-builder.popUpForm.navContainer.advanced', nameToReplace: 'defineRelation' },
|
name: 'defineRelation',
|
||||||
|
message: 'content-type-builder.popUpForm.navContainer.relation',
|
||||||
|
nameToReplace: 'advancedSettings',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'advancedSettings',
|
||||||
|
message: 'content-type-builder.popUpForm.navContainer.advanced',
|
||||||
|
nameToReplace: 'defineRelation',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,12 +43,93 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (isEmpty(this.props.dropDownItems) && !isEmpty(nextProps.dropDownItems) && !this.props.isEditting) {
|
if (
|
||||||
|
isEmpty(this.props.dropDownItems) &&
|
||||||
|
!isEmpty(nextProps.dropDownItems) &&
|
||||||
|
!this.props.isEditting
|
||||||
|
) {
|
||||||
this.init(nextProps);
|
this.init(nextProps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init = (props) => {
|
setPlaceholders = (firstCTName, secondCTName, relationType, values = this.props.values) => {
|
||||||
|
switch (relationType) {
|
||||||
|
case 'oneToMany':
|
||||||
|
firstCTName = pluralize(firstCTName);
|
||||||
|
break;
|
||||||
|
case 'manyToOne':
|
||||||
|
secondCTName = pluralize(secondCTName);
|
||||||
|
break;
|
||||||
|
case 'manyToMany':
|
||||||
|
firstCTName = pluralize(firstCTName);
|
||||||
|
secondCTName = pluralize(secondCTName);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
if (get(this.props.contentType, 'name') !== get(values, 'params.target')) {
|
||||||
|
this.props.onChange({ target: { name: 'name', value: firstCTName } });
|
||||||
|
this.props.onChange({ target: { name: 'params.key', value: secondCTName } });
|
||||||
|
this.props.resetFormErrors();
|
||||||
|
} else {
|
||||||
|
this.props.onChange({ target: { name: 'name', value: '' } });
|
||||||
|
this.props.onChange({ target: { name: 'params.key', value: '' } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChange = e => {
|
||||||
|
this.props.onChange(e);
|
||||||
|
const shouldResetKeyParams = e.target.value === 'oneWay';
|
||||||
|
|
||||||
|
if (!this.props.isEditting && !shouldResetKeyParams) {
|
||||||
|
this.setPlaceholders(
|
||||||
|
get(this.props.values, ['params', 'target']),
|
||||||
|
get(this.props.contentType, 'name'),
|
||||||
|
e.target.value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldResetKeyParams) {
|
||||||
|
this.props.onChange({ target: { name: 'params.key', value: '-' } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClick = e => {
|
||||||
|
const value = e.target.id.split('.');
|
||||||
|
[
|
||||||
|
{
|
||||||
|
target: {
|
||||||
|
type: 'string',
|
||||||
|
value: value[0],
|
||||||
|
name: 'params.target',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: {
|
||||||
|
type: 'string',
|
||||||
|
value: value[1] !== 'undefined' ? value[1] : '',
|
||||||
|
name: 'params.pluginValue',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
].map(target => this.props.onChange(target));
|
||||||
|
|
||||||
|
if (!this.props.isEditting) {
|
||||||
|
if (get(this.props.contentType, 'name') !== value[0]) {
|
||||||
|
this.setPlaceholders(
|
||||||
|
value[0],
|
||||||
|
get(this.props.contentType, 'name'),
|
||||||
|
get(this.props.values, ['params', 'nature']),
|
||||||
|
value[0],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.props.onChange({ target: { name: 'name', value: '' } });
|
||||||
|
this.props.onChange({ target: { name: 'params.key', value: '' } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
init = props => {
|
||||||
const target = {
|
const target = {
|
||||||
name: 'params.target',
|
name: 'params.target',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -56,7 +147,14 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (get(props.contentType, 'name') !== get(props.dropDownItems, ['0', 'name'])) {
|
||||||
|
[
|
||||||
|
{ target: { name: 'name', value: get(props.dropDownItems, ['0', 'name']) } },
|
||||||
|
{ target: { name: 'params.key', value: get(props.contentType, 'name') } },
|
||||||
|
].map(target => this.props.onChange(target));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
renderNavContainer = () => (
|
renderNavContainer = () => (
|
||||||
<div className={styles.navContainer}>
|
<div className={styles.navContainer}>
|
||||||
@ -70,7 +168,7 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
|
|
||||||
renderModalBodyAdvanced = () => (
|
renderModalBodyAdvanced = () => (
|
||||||
<ModalBody className={`${styles.modalBodyAdvanced}`}>
|
<ModalBody className={`${styles.modalBodyAdvanced}`}>
|
||||||
@ -95,7 +193,10 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
|||||||
<div className={styles.inputContainer}>
|
<div className={styles.inputContainer}>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{map(takeRight(this.props.form.items, 2), (value, index) => {
|
{map(takeRight(this.props.form.items, 2), (value, index) => {
|
||||||
const addon = index === 0 ? get(this.props.values, 'name') : get(this.props.values, ['params', 'key']);
|
const addon =
|
||||||
|
index === 0
|
||||||
|
? get(this.props.values, 'name')
|
||||||
|
: get(this.props.values, ['params', 'key']);
|
||||||
return (
|
return (
|
||||||
<Input
|
<Input
|
||||||
key={index}
|
key={index}
|
||||||
@ -117,12 +218,25 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
)
|
);
|
||||||
|
|
||||||
renderModalBodyRelations = () => {
|
renderModalBodyRelations = () => {
|
||||||
const header = get(this.props.values, ['params', 'pluginValue']) ?
|
const header = get(this.props.values, ['params', 'pluginValue'])
|
||||||
get(this.props.dropDownItems, [findIndex(this.props.dropDownItems, {'name': get(this.props.values, ['params', 'target']), source: get(this.props.values, ['params', 'pluginValue']) })])
|
? get(this.props.dropDownItems, [
|
||||||
: get(this.props.dropDownItems, [findIndex(this.props.dropDownItems, ['name', get(this.props.values, ['params', 'target'])])]);
|
findIndex(this.props.dropDownItems, {
|
||||||
|
name: get(this.props.values, ['params', 'target']),
|
||||||
|
source: get(this.props.values, ['params', 'pluginValue']),
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
: get(this.props.dropDownItems, [
|
||||||
|
findIndex(this.props.dropDownItems, [
|
||||||
|
'name',
|
||||||
|
get(this.props.values, ['params', 'target']),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const errs = findIndex(this.props.formErrors, ['name',get(this.props.form, ['items', '0', 'name'])]) !== -1 ? this.props.formErrors[findIndex(this.props.formErrors, ['name', get(this.props.form, ['items', '0', 'name'])])].errors: [];
|
||||||
|
const errors = findIndex(this.props.formErrors, ['name', get(this.props.form, ['items', '1', 'name'])]) !== -1 ? this.props.formErrors[findIndex(this.props.formErrors, ['name', get(this.props.form, ['items', '1', 'name'])])].errors : [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalBody className={`${styles.modalBody} ${styles.flex}`}>
|
<ModalBody className={`${styles.modalBody} ${styles.flex}`}>
|
||||||
@ -138,11 +252,11 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
|||||||
onSubmit={this.props.onSubmit}
|
onSubmit={this.props.onSubmit}
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
didCheckErrors={this.props.didCheckErrors}
|
didCheckErrors={this.props.didCheckErrors}
|
||||||
errors={findIndex(this.props.formErrors, ['name', get(this.props.form, ['items', '0', 'name'])]) !== -1 ? this.props.formErrors[findIndex(this.props.formErrors, ['name', get(this.props.form, ['items', '0', 'name'])])].errors : []}
|
errors={errs}
|
||||||
/>
|
/>
|
||||||
<RelationNaturePicker
|
<RelationNaturePicker
|
||||||
selectedIco={get(this.props.values, ['params', 'nature'])}
|
selectedIco={get(this.props.values, ['params', 'nature'])}
|
||||||
onChange={this.props.onChange}
|
onChange={this.handleChange}
|
||||||
contentTypeName={get(this.props.contentType, 'name')}
|
contentTypeName={get(this.props.contentType, 'name')}
|
||||||
contentTypeTarget={get(this.props.values, ['params', 'target'])}
|
contentTypeTarget={get(this.props.values, ['params', 'target'])}
|
||||||
/>
|
/>
|
||||||
@ -156,24 +270,46 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
|||||||
value={get(this.props.values, ['params', 'key'])}
|
value={get(this.props.values, ['params', 'key'])}
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
didCheckErrors={this.props.didCheckErrors}
|
didCheckErrors={this.props.didCheckErrors}
|
||||||
errors={findIndex(this.props.formErrors, ['name', get(this.props.form, ['items', '1', 'name'])]) !== -1 ? this.props.formErrors[findIndex(this.props.formErrors, ['name', get(this.props.form, ['items', '1', 'name'])])].errors : []}
|
errors={errors}
|
||||||
dropDownItems={this.props.dropDownItems}
|
dropDownItems={this.props.dropDownItems}
|
||||||
|
onClick={this.handleClick}
|
||||||
/>
|
/>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const loader = this.props.showLoader ?
|
const loader = this.props.showLoader ? (
|
||||||
<Button onClick={this.props.onSubmit} type="submit" className={styles.primary} disabled={this.props.showLoader}><p className={styles.saving}><span>.</span><span>.</span><span>.</span></p></Button>
|
<Button
|
||||||
: <Button type="submit" onClick={this.props.onSubmit} className={styles.primary}><FormattedMessage id="content-type-builder.form.button.continue" /></Button>;
|
onClick={this.props.onSubmit}
|
||||||
|
type="submit"
|
||||||
|
className={styles.primary}
|
||||||
|
disabled={this.props.showLoader}
|
||||||
|
>
|
||||||
|
<p className={styles.saving}>
|
||||||
|
<span>.</span>
|
||||||
|
<span>.</span>
|
||||||
|
<span>.</span>
|
||||||
|
</p>
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button type="submit" onClick={this.props.onSubmit} className={styles.primary}>
|
||||||
|
<FormattedMessage id="content-type-builder.form.button.continue" />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
|
||||||
const modalBody = this.props.showRelation ? this.renderModalBodyRelations(): this.renderModalBodyAdvanced();
|
const modalBody = this.props.showRelation
|
||||||
|
? this.renderModalBodyRelations()
|
||||||
|
: this.renderModalBodyAdvanced();
|
||||||
const handleToggle = this.props.toggle;
|
const handleToggle = this.props.toggle;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.popUpRelations}>
|
<div className={styles.popUpRelations}>
|
||||||
<Modal isOpen={this.props.isOpen} toggle={this.props.toggle} className={`${styles.modalPosition}`}>
|
<Modal
|
||||||
|
isOpen={this.props.isOpen}
|
||||||
|
toggle={this.props.toggle}
|
||||||
|
className={`${styles.modalPosition}`}
|
||||||
|
>
|
||||||
<ModalHeader toggle={this.props.toggle} className={styles.popUpFormHeader} />
|
<ModalHeader toggle={this.props.toggle} className={styles.popUpFormHeader} />
|
||||||
<div className={styles.headerContainer}>
|
<div className={styles.headerContainer}>
|
||||||
<div className={styles.titleContainer}>
|
<div className={styles.titleContainer}>
|
||||||
@ -190,7 +326,9 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref
|
|||||||
{modalBody}
|
{modalBody}
|
||||||
|
|
||||||
<ModalFooter className={styles.modalFooter}>
|
<ModalFooter className={styles.modalFooter}>
|
||||||
<Button onClick={handleToggle} className={styles.secondary}><FormattedMessage id="content-type-builder.form.button.cancel" /></Button>
|
<Button onClick={handleToggle} className={styles.secondary}>
|
||||||
|
<FormattedMessage id="content-type-builder.form.button.cancel" />
|
||||||
|
</Button>
|
||||||
{loader}{' '}
|
{loader}{' '}
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</Modal>
|
</Modal>
|
||||||
@ -203,19 +341,14 @@ PopUpRelations.propTypes = {
|
|||||||
contentType: PropTypes.object,
|
contentType: PropTypes.object,
|
||||||
didCheckErrors: PropTypes.bool.isRequired,
|
didCheckErrors: PropTypes.bool.isRequired,
|
||||||
dropDownItems: PropTypes.array,
|
dropDownItems: PropTypes.array,
|
||||||
form: PropTypes.oneOfType([
|
form: PropTypes.oneOfType([PropTypes.array.isRequired, PropTypes.object.isRequired]).isRequired,
|
||||||
PropTypes.array.isRequired,
|
formErrors: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired,
|
||||||
PropTypes.object.isRequired,
|
|
||||||
]).isRequired,
|
|
||||||
formErrors: PropTypes.oneOfType([
|
|
||||||
PropTypes.array,
|
|
||||||
PropTypes.object,
|
|
||||||
]).isRequired,
|
|
||||||
isEditting: PropTypes.bool,
|
isEditting: PropTypes.bool,
|
||||||
isOpen: PropTypes.bool.isRequired,
|
isOpen: PropTypes.bool.isRequired,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
onSubmit: PropTypes.func.isRequired,
|
onSubmit: PropTypes.func.isRequired,
|
||||||
popUpTitle: PropTypes.string.isRequired,
|
popUpTitle: PropTypes.string.isRequired,
|
||||||
|
resetFormErrors: PropTypes.func.isRequired,
|
||||||
routePath: PropTypes.string.isRequired,
|
routePath: PropTypes.string.isRequired,
|
||||||
showLoader: PropTypes.bool,
|
showLoader: PropTypes.bool,
|
||||||
showRelation: PropTypes.bool.isRequired,
|
showRelation: PropTypes.bool.isRequired,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* RelationBox
|
* RelationBox
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
@ -16,7 +16,8 @@ import styles from './styles.scss';
|
|||||||
|
|
||||||
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
||||||
/* eslint-disable react/jsx-wrap-multilines */
|
/* eslint-disable react/jsx-wrap-multilines */
|
||||||
class RelationBox extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
class RelationBox extends React.Component {
|
||||||
|
// eslint-disable-line react/prefer-stateless-function
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@ -25,58 +26,64 @@ class RelationBox extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClick = (e) => {
|
getPlaceholder = () => {
|
||||||
const value = e.target.id.split('.');
|
switch (true) {
|
||||||
const target = {
|
case this.props.relationType === 'oneToMany' && this.props.isFirstContentType:
|
||||||
type: 'string',
|
return pluralize(this.props.contentTypeTargetPlaceholder);
|
||||||
value: value[0],
|
case this.props.relationType === 'manyToOne' && !this.props.isFirstContentType:
|
||||||
name: 'params.target',
|
return pluralize(this.props.contentTypeTargetPlaceholder);
|
||||||
};
|
case this.props.relationType === 'manyToMany':
|
||||||
|
return pluralize(this.props.contentTypeTargetPlaceholder);
|
||||||
this.props.onChange({ target });
|
default:
|
||||||
|
return this.props.contentTypeTargetPlaceholder;
|
||||||
this.props.onChange({
|
}
|
||||||
target: {
|
|
||||||
type: 'string',
|
|
||||||
value: value[1] !== 'undefined' ? value[1] : '',
|
|
||||||
name: 'params.pluginValue',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle = () => this.setState({ showMenu: !this.state.showMenu });
|
toggle = () => this.setState({ showMenu: !this.state.showMenu });
|
||||||
|
|
||||||
renderDropdownMenu = () => (
|
renderDropdownMenu = () => (
|
||||||
<div className={styles.dropDown}>
|
<div className={styles.dropDown}>
|
||||||
<ButtonDropdown isOpen={this.state.showMenu} toggle={this.toggle} style={{ backgroundColor: 'transparent' }}>
|
<ButtonDropdown
|
||||||
<DropdownToggle caret>
|
isOpen={this.state.showMenu}
|
||||||
</DropdownToggle>
|
toggle={this.toggle}
|
||||||
|
style={{ backgroundColor: 'transparent' }}
|
||||||
|
>
|
||||||
|
<DropdownToggle caret />
|
||||||
<DropdownMenu className={styles.dropDownContent}>
|
<DropdownMenu className={styles.dropDownContent}>
|
||||||
{map(this.props.dropDownItems, (value, key) => {
|
{map(this.props.dropDownItems, (value, key) => {
|
||||||
const id = value.source ? `${value.name}.${value.source}` : `${value.name}. `;
|
const id = value.source ? `${value.name}.${value.source}` : `${value.name}. `;
|
||||||
let divStyle;
|
let divStyle;
|
||||||
|
|
||||||
if (get(this.props.header, 'name') === value.name && !isEmpty(get(this.props.header,'source')) && value.source) {
|
if (
|
||||||
divStyle = { color: '#323740', fontWeight: 'bold'};
|
get(this.props.header, 'name') === value.name &&
|
||||||
} else if (value.source === get(this.props.header, 'source') && value.name === get(this.props.header, 'name')) {
|
!isEmpty(get(this.props.header, 'source')) &&
|
||||||
divStyle = { color: '#323740', fontWeight: 'bold'};
|
value.source
|
||||||
|
) {
|
||||||
|
divStyle = { color: '#323740', fontWeight: 'bold' };
|
||||||
|
} else if (
|
||||||
|
value.source === get(this.props.header, 'source') &&
|
||||||
|
value.name === get(this.props.header, 'name')
|
||||||
|
) {
|
||||||
|
divStyle = { color: '#323740', fontWeight: 'bold' };
|
||||||
} else {
|
} else {
|
||||||
divStyle = { color: 'rgba(50,55,64,0.75)' };
|
divStyle = { color: 'rgba(50,55,64,0.75)' };
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ height: '3.6rem'}} key={key}>
|
<div style={{ height: '3.6rem' }} key={key}>
|
||||||
<DropdownItem onClick={this.handleClick} id={id}>
|
<DropdownItem onClick={this.props.onClick} id={id}>
|
||||||
<div style={divStyle} id={`${value.name}.${value.source}`}>
|
<div style={divStyle} id={`${value.name}.${value.source}`}>
|
||||||
<i className={`fa ${value.icon}`} style={divStyle} id={id} />
|
<i className={`fa ${value.icon}`} style={divStyle} id={id} />
|
||||||
{value.name}
|
{value.name}
|
||||||
{value.source ? (
|
{value.source && (
|
||||||
<FormattedMessage id="content-type-builder.from">
|
<FormattedMessage id="content-type-builder.from">
|
||||||
{(message) => (
|
{message => (
|
||||||
<span style={{ fontStyle: 'italic' }} id={id}>({message}: {value.source})</span>
|
<span style={{ fontStyle: 'italic' }} id={id}>
|
||||||
|
({message}: {value.source})
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
</FormattedMessage>
|
</FormattedMessage>
|
||||||
) : ''}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
</div>
|
</div>
|
||||||
@ -85,63 +92,41 @@ class RelationBox extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</ButtonDropdown>
|
</ButtonDropdown>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let placeholder;
|
|
||||||
|
|
||||||
switch (true) {
|
|
||||||
case this.props.relationType === 'oneToMany' && this.props.isFirstContentType:
|
|
||||||
placeholder = pluralize(this.props.contentTypeTargetPlaceholder);
|
|
||||||
break;
|
|
||||||
case this.props.relationType === 'manyToOne' && !this.props.isFirstContentType:
|
|
||||||
placeholder = pluralize(this.props.contentTypeTargetPlaceholder);
|
|
||||||
break;
|
|
||||||
case this.props.relationType === 'manyToMany':
|
|
||||||
placeholder = pluralize(this.props.contentTypeTargetPlaceholder);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
placeholder = this.props.contentTypeTargetPlaceholder;
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = isEmpty(this.props.input) ?
|
|
||||||
<div /> :
|
|
||||||
<Input
|
|
||||||
disabled={this.props.relationType === 'oneWay' && this.props.tabIndex === '2'}
|
|
||||||
tabIndex={this.props.tabIndex}
|
|
||||||
type={get(this.props.input, 'type')}
|
|
||||||
onChange={this.props.onChange}
|
|
||||||
label={get(this.props.input, 'label')}
|
|
||||||
name={get(this.props.input, 'name')}
|
|
||||||
value={this.props.value}
|
|
||||||
placeholder={placeholder}
|
|
||||||
customBootstrapClass="col-md-12"
|
|
||||||
validations={get(this.props.input, 'validations')}
|
|
||||||
errors={this.props.errors}
|
|
||||||
didCheckErrors={this.props.didCheckErrors}
|
|
||||||
pluginID="content-type-builder"
|
|
||||||
autoFocus={this.props.autoFocus}
|
|
||||||
/>;
|
|
||||||
|
|
||||||
const dropDown = !isEmpty(this.props.dropDownItems) ? this.renderDropdownMenu() : '';
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.relationBox}>
|
<div className={styles.relationBox}>
|
||||||
<div className={styles.headerContainer}>
|
<div className={styles.headerContainer}>
|
||||||
<i className={`fa ${get(this.props.header, 'icon')}`} />
|
<i className={`fa ${get(this.props.header, 'icon')}`} />
|
||||||
{startCase(get(this.props.header, 'name'))}
|
{startCase(get(this.props.header, 'name'))}
|
||||||
<span style={{ fontStyle: 'italic', fontWeight: '500' }}>
|
<span style={{ fontStyle: 'italic', fontWeight: '500' }}>
|
||||||
{get(this.props.header, 'source') ? (
|
{get(this.props.header, 'source') ? `(${get(this.props.header, 'source')})` : ''}
|
||||||
`(${get(this.props.header, 'source')})`
|
|
||||||
): ''}
|
|
||||||
</span>
|
</span>
|
||||||
{dropDown}
|
{!isEmpty(this.props.dropDownItems) && this.renderDropdownMenu()}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.inputContainer}>
|
<div className={styles.inputContainer}>
|
||||||
<form onSubmit={this.props.onSubmit}>
|
<form onSubmit={this.props.onSubmit}>
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
<div className={`row ${styles.input}`}>
|
<div className={`row ${styles.input}`}>
|
||||||
{content}
|
{!isEmpty(this.props.input) && (
|
||||||
|
<Input
|
||||||
|
disabled={this.props.relationType === 'oneWay' && this.props.tabIndex === '2'}
|
||||||
|
tabIndex={this.props.tabIndex}
|
||||||
|
type={get(this.props.input, 'type')}
|
||||||
|
onChange={this.props.onChange}
|
||||||
|
label={get(this.props.input, 'label')}
|
||||||
|
name={get(this.props.input, 'name')}
|
||||||
|
value={this.props.value}
|
||||||
|
placeholder={this.getPlaceholder()}
|
||||||
|
customBootstrapClass="col-md-12"
|
||||||
|
validations={get(this.props.input, 'validations')}
|
||||||
|
errors={this.props.errors}
|
||||||
|
didCheckErrors={this.props.didCheckErrors}
|
||||||
|
pluginID="content-type-builder"
|
||||||
|
autoFocus={this.props.autoFocus}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -161,6 +146,7 @@ RelationBox.propTypes = {
|
|||||||
input: PropTypes.object,
|
input: PropTypes.object,
|
||||||
isFirstContentType: PropTypes.bool,
|
isFirstContentType: PropTypes.bool,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
|
onClick: PropTypes.func,
|
||||||
onSubmit: PropTypes.func.isRequired,
|
onSubmit: PropTypes.func.isRequired,
|
||||||
relationType: PropTypes.string,
|
relationType: PropTypes.string,
|
||||||
tabIndex: PropTypes.string.isRequired,
|
tabIndex: PropTypes.string.isRequired,
|
||||||
@ -175,6 +161,7 @@ RelationBox.defaultProps = {
|
|||||||
header: {},
|
header: {},
|
||||||
input: {},
|
input: {},
|
||||||
isFirstContentType: false,
|
isFirstContentType: false,
|
||||||
|
onClick: () => {},
|
||||||
relationType: 'oneToOne',
|
relationType: 'oneToOne',
|
||||||
value: '',
|
value: '',
|
||||||
};
|
};
|
||||||
|
@ -397,8 +397,6 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
|
|
||||||
if (target.name === 'params.nature' && target.value === "oneWay") {
|
if (target.name === 'params.nature' && target.value === "oneWay") {
|
||||||
this.props.changeInputAttribute('params.key', '-');
|
this.props.changeInputAttribute('params.key', '-');
|
||||||
}else if (target.name === 'params.nature'){
|
|
||||||
this.props.changeInputAttribute('params.key', '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -539,7 +537,6 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
// Ensure typeof(popUpFormType) is String
|
// Ensure typeof(popUpFormType) is String
|
||||||
const popUpFormType = split(this.props.hash, '::')[1] || '';
|
const popUpFormType = split(this.props.hash, '::')[1] || '';
|
||||||
const popUpTitle = this.generatePopUpTitle(popUpFormType);
|
const popUpTitle = this.generatePopUpTitle(popUpFormType);
|
||||||
@ -576,6 +573,7 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
formErrors={this.props.formErrors}
|
formErrors={this.props.formErrors}
|
||||||
didCheckErrors={this.props.didCheckErrors}
|
didCheckErrors={this.props.didCheckErrors}
|
||||||
isEditting={edit}
|
isEditting={edit}
|
||||||
|
resetFormErrors={this.props.resetFormErrors}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,9 @@ function formReducer(state = initialState, action) {
|
|||||||
.update('formErrors', (list) => list.splice(findIndex(state.get('formErrors').toJS(), ['target', 'name']), 1))
|
.update('formErrors', (list) => list.splice(findIndex(state.get('formErrors').toJS(), ['target', 'name']), 1))
|
||||||
.set('didCheckErrors', !state.get('didCheckErrors'));
|
.set('didCheckErrors', !state.get('didCheckErrors'));
|
||||||
case RESET_FORM_ERRORS:
|
case RESET_FORM_ERRORS:
|
||||||
return state.set('formErrors', List());
|
return state
|
||||||
|
.update('didCheckErrors', v => v = !v)
|
||||||
|
.set('formErrors', List());
|
||||||
case RESET_IS_FORM_SET:
|
case RESET_IS_FORM_SET:
|
||||||
return state
|
return state
|
||||||
.set('isFormSet', false)
|
.set('isFormSet', false)
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"graphql": "^0.13.2",
|
"graphql": "^0.13.2",
|
||||||
"graphql-depth-limit": "^1.1.0",
|
"graphql-depth-limit": "^1.1.0",
|
||||||
"graphql-playground-middleware-koa": "^1.5.1",
|
"graphql-playground-middleware-koa": "^1.6.1",
|
||||||
"graphql-tools": "^2.23.1",
|
"graphql-tools": "^2.23.1",
|
||||||
"graphql-type-json": "^0.2.0",
|
"graphql-type-json": "^0.2.0",
|
||||||
"pluralize": "^7.0.0",
|
"pluralize": "^7.0.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user