diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/index.js index 662e86b88d..5e89bb1ddc 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/index.js @@ -5,10 +5,11 @@ */ import React from 'react'; -import { map } from 'lodash'; +import { get, map } from 'lodash'; import { FormattedMessage } from 'react-intl'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import PopUpHeaderNavLink from 'components/PopUpHeaderNavLink'; +import RelationBox from 'components/RelationBox'; import styles from './styles.scss'; class PopUpRelations extends React.Component { // eslint-disable-line react/prefer-stateless-function @@ -34,10 +35,33 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref ) + renderModalBodyRelations = () => { + console.log('ok'); + return ( + + +
+ +
+ ) + } + render() { const loader = this.props.showLoader ? : ; + + const modalBody = this.props.showRelation ? this.renderModalBodyRelations():
; return (
@@ -53,13 +77,9 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref {this.renderNavContainer()}
- -
-
-
-
-
+ {modalBody} + {loader}{' '} @@ -71,12 +91,20 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref } PopUpRelations.propTypes = { + contentType: React.PropTypes.object, + form: React.PropTypes.oneOfType([ + React.PropTypes.array.isRequired, + React.PropTypes.object.isRequired, + ]), + handleChange: React.PropTypes.func, handleSubmit: React.PropTypes.func, isOpen: React.PropTypes.bool, popUpTitle: React.PropTypes.string.isRequired, routePath: React.PropTypes.string.isRequired, showLoader: React.PropTypes.bool, + showRelation: React.PropTypes.bool, toggle: React.PropTypes.func, + values: React.PropTypes.object, } export default PopUpRelations; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/styles.scss b/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/styles.scss index f3c330b728..c1d9b70cab 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/styles.scss +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/styles.scss @@ -8,11 +8,12 @@ } .modalBody { - padding: 2.2rem 1.4rem 0 1.4rem; + display: flex; + padding: 4.8rem 2.9rem 0 2.9rem; } .modalFooter { - padding: 1rem 1rem 2.8rem 1rem; + padding: 4.4rem 1rem 2.8rem 1rem; border: none; > button { height: 3rem; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/RelationBox/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/RelationBox/index.js index cfda604c0a..399ef00df3 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/RelationBox/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/RelationBox/index.js @@ -5,16 +5,44 @@ */ import React from 'react'; - +import { get, startCase } from 'lodash'; +import Input from 'components/Input'; import styles from './styles.scss'; class RelationBox extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { return (
+
+ + {startCase(get(this.props.header, 'name'))} +
+
+
+
+ +
+
+
); } } +RelationBox.propTypes = { + handleChange: React.PropTypes.func, + header: React.PropTypes.object, + input: React.PropTypes.object, + value: React.PropTypes.string, +} + export default RelationBox; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/RelationBox/styles.scss b/packages/strapi-plugin-content-type-builder/admin/src/components/RelationBox/styles.scss index 5c3c933cbc..5cdd8e6b93 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/RelationBox/styles.scss +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/RelationBox/styles.scss @@ -1,3 +1,36 @@ .relationBox { /* stylelint-disable */ - + height: 13.8rem; + width: 21.5rem; + background-color: #FCFCFC; + box-shadow: 0 1px 2px #CAD2DF; +} + +.headerContainer { + height: 3.6rem; + width: 100%; + background-color: rgba(16, 22, 34, 0.04); + line-height: 3.6rem; + text-align: center; + font-size: 1.4rem; + font-weight: bold; + text-transform: capitalize; + > i { + margin-right: 8px; + color: rgba(50, 55, 64, 0.75); + font-size: 1.3rem; + font-weight: 100; + } +} + + +.inputContainer { + padding-top: 1rem; +} + +.input { + > div { + > label { + font-weight: 600; + } + } } diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/actions.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/actions.js index 79c048d9c8..1c5c43ddb6 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/actions.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/actions.js @@ -6,7 +6,7 @@ /* eslint-disable new-cap */ -import { map , forEach, replace } from 'lodash'; +import { includes, map , forEach, replace } from 'lodash'; import { Map, List } from 'immutable'; import { getValidationsFromForm } from '../../utils/formValidations'; import { storeData } from '../../utils/storeData'; @@ -140,11 +140,24 @@ export function resetIsFormSet() { export function setAttributeForm(hash) { const data = setAttributeFormData(hash); + const attributeRelation = Map({ + name: '', + params: Map({ + columnName: '', + target: '', + targetColumnName: "", + key: '', + nature: '', + required: false, + unique: false, + }), + }); + const attribute = includes(hash, 'defineRelation') ? attributeRelation : data.attribute; const formValidations = getValidationsFromForm(data.form, []); return { type: SET_ATTRIBUTE_FORM, form: data.form, - attribute: data.attribute, + attribute, formValidations, } } diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/forms.json b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/forms.json index 4b2006e5ff..5fa7aedce7 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/forms.json +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/forms.json @@ -83,7 +83,7 @@ { "name": "form.attribute.item.textarea.name", "target": "name", - "type": "textarea", + "type": "string", "value": "", "validations": { "required": true @@ -366,7 +366,20 @@ } }, "relation": { - "defineRelation": {}, + "defineRelation": { + "items": [ + { + "name": "form.attribute.item.defineRelation.fieldName", + "target": "name", + "type": "string", + "value": "", + "placeholder": "relation.attributeName.placeholder", + "validations": { + "required": true + } + } + ] + }, "advancedSettings": {} } } diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js index f73e78cea0..08d0ed67d6 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js @@ -496,6 +496,11 @@ export class Form extends React.Component { // eslint-disable-line react/prefer- renderCustomPopUpHeader={renderCustomPopUpHeader} popUpTitle={popUpTitle} routePath={`${this.props.routePath}/${this.props.hash}`} + contentType={get(this.props.menuData[0], ['items', findIndex(get(this.props.menuData[0], 'items'), ['name', this.props.modelName])])} + form={this.props.form} + showRelation={includes(this.props.hash, 'defineRelation')} + handleChange={this.handleChange} + values={this.props.modifiedDataAttribute} /> ); } diff --git a/packages/strapi-plugin-content-type-builder/admin/src/translations/en.json b/packages/strapi-plugin-content-type-builder/admin/src/translations/en.json index e36334cf4d..66d74478e8 100755 --- a/packages/strapi-plugin-content-type-builder/admin/src/translations/en.json +++ b/packages/strapi-plugin-content-type-builder/admin/src/translations/en.json @@ -33,6 +33,7 @@ "form.attribute.item.maximumLength": "Maximum length", "form.attribute.item.requiredField.description": "You won't be able to create an entry if this field is empty", "form.attribute.item.uniqueField.description": "You won't be able to create an entry if there is an existing entry with identical content", + "form.attribute.item.defineRelation.fieldName": "Field name", "form.button.cancel": "Cancel", "form.button.continue": "Continue",