Fix design

This commit is contained in:
cyril lopez 2017-08-30 18:21:56 +02:00
parent 28f35f678b
commit 8422e8c2f1
8 changed files with 45 additions and 28 deletions

View File

@ -52,6 +52,7 @@
} }
.buttonContainer { .buttonContainer {
padding-top: .3rem;
> button:last-child { > button:last-child {
margin-right: 0; margin-right: 0;
} }

View File

@ -74,8 +74,8 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
const modalFooter = this.props.noButtons ? <div className={styles.modalFooter} /> const modalFooter = this.props.noButtons ? <div className={styles.modalFooter} />
: <ModalFooter className={styles.modalFooter}> : <ModalFooter className={styles.modalFooter}>
<Button onClick={this.props.toggle} className={styles.secondary}>Cancel</Button> <Button onClick={this.props.toggle} className={styles.secondary}><FormattedMessage id="form.button.cancel" /></Button>
<Button type="submit" onClick={this.props.handleSubmit} className={styles.primary}>Save</Button>{' '} <Button type="submit" onClick={this.props.handleSubmit} className={styles.primary}><FormattedMessage id={this.props.buttonSubmitMessage} /></Button>{' '}
</ModalFooter>; </ModalFooter>;
return ( return (
<div className={styles.popUpForm}> <div className={styles.popUpForm}>
@ -102,6 +102,7 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
} }
PopUpForm.propTypes = { PopUpForm.propTypes = {
buttonSubmitMessage: React.PropTypes.string.isRequired,
form: React.PropTypes.oneOfType([ form: React.PropTypes.oneOfType([
React.PropTypes.array.isRequired, React.PropTypes.array.isRequired,
React.PropTypes.object.isRequired, React.PropTypes.object.isRequired,

View File

@ -304,7 +304,7 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
const renderModalBody = includes(this.props.hash, '#choose') ? this.renderModalBodyChooseAttributes : false; const renderModalBody = includes(this.props.hash, '#choose') ? this.renderModalBodyChooseAttributes : false;
const noButtons = includes(this.props.hash, '#choose'); const noButtons = includes(this.props.hash, '#choose');
const buttonSubmitMessage = includes(this.props.hash.split('::')[1], 'contentType') ? 'form.button.save' : 'form.button.continue';
return ( return (
<div className={styles.form}> <div className={styles.form}>
<PopUpForm <PopUpForm
@ -326,6 +326,7 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
noButtons={noButtons} noButtons={noButtons}
overrideRenderInputCondition={this.checkForNestedInput} overrideRenderInputCondition={this.checkForNestedInput}
overrideRenderInput={this.renderInput} overrideRenderInput={this.renderInput}
buttonSubmitMessage={buttonSubmitMessage}
/> />
</div> </div>
); );

View File

@ -59,6 +59,7 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
// Refecth content type after editing it // Refecth content type after editing it
if (prevProps.location.hash !== this.props.location.hash && this.props.didFetchModel) { if (prevProps.location.hash !== this.props.location.hash && this.props.didFetchModel) {
console.log('ok')
this.fetchModel(); this.fetchModel();
} }
} }
@ -187,7 +188,7 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
render() { render() {
// Url to redirects the user if he modifies the temporary content type name // Url to redirects the user if he modifies the temporary content type name
const redirectRoute = replace(this.props.route.path, '/:modelName', ''); const redirectRoute = replace(this.props.route.path, '/:modelName', '');
const addButtons = size(get(this.props.modelPage.model, 'attributes')) > 0; const addButtons = this.props.modelPage.showButtons;
const content = size(this.props.modelPage.model.attributes) === 0 ? const content = size(this.props.modelPage.model.attributes) === 0 ?
<EmptyAttributesView handleClick={this.handleClickAddAttribute} /> : <EmptyAttributesView handleClick={this.handleClickAddAttribute} /> :

View File

@ -5,6 +5,7 @@
*/ */
import { fromJS, Map, List } from 'immutable'; import { fromJS, Map, List } from 'immutable';
// import { findIndex, differenceWith, isEqual, filter } from 'lodash';
/* eslint-disable new-cap */ /* eslint-disable new-cap */
import { import {
ADD_ATTRIBUTE_TO_CONTENT_TYPE, ADD_ATTRIBUTE_TO_CONTENT_TYPE,
@ -22,17 +23,24 @@ const initialState = fromJS({
attributes: List(), attributes: List(),
}), }),
postContentTypeSuccess: false, postContentTypeSuccess: false,
showButtons: false,
}); });
function modelPageReducer(state = initialState, action) { function modelPageReducer(state = initialState, action) {
switch (action.type) { switch (action.type) {
case ADD_ATTRIBUTE_TO_CONTENT_TYPE: case ADD_ATTRIBUTE_TO_CONTENT_TYPE:
return state.updateIn(['model', 'attributes'], (list) => list.push(action.newAttribute));
case CANCEL_CHANGES:
return state.set('model', state.get('initialModel'));
case DELETE_ATTRIBUTE:
return state return state
.updateIn(['model', 'attributes'], (list) => list.push(action.newAttribute))
.set('showButtons', true);
case CANCEL_CHANGES:
return state
.set('showButtons', false)
.set('model', state.get('initialModel'));
case DELETE_ATTRIBUTE: {
return state
.set('showButtons', true)
.updateIn(['model', 'attributes'], (list) => list.splice(action.position, 1)); .updateIn(['model', 'attributes'], (list) => list.splice(action.position, 1));
}
case MODEL_FETCH_SUCCEEDED: case MODEL_FETCH_SUCCEEDED:
return state return state
.set('model', Map(action.model.model)) .set('model', Map(action.model.model))

View File

@ -9,27 +9,27 @@ import { temporaryContentTypePosted } from 'containers/App/actions';
import { storeData } from '../../utils/storeData'; import { storeData } from '../../utils/storeData';
import { DELETE_ATTRIBUTE, MODEL_FETCH, SUBMIT } from './constants'; import { MODEL_FETCH, SUBMIT } from './constants';
import { modelFetchSucceeded, postContentTypeSucceeded } from './actions'; import { modelFetchSucceeded, postContentTypeSucceeded } from './actions';
import { makeSelectModel } from './selectors'; import { makeSelectModel } from './selectors';
// Individual exports for testing // Individual exports for testing
export function* attributeDelete(action) { // export function* attributeDelete(action) {
try { // try {
if (action.sendRequest) { // if (action.sendRequest) {
const body = yield select(makeSelectModel()); // const body = yield select(makeSelectModel());
const requestUrl = `/content-type-builder/models/${action.modelName}`; // const requestUrl = `/content-type-builder/models/${action.modelName}`;
const opts = { // const opts = {
method: 'PUT', // method: 'PUT',
body, // body,
}; // };
//
yield call(request, requestUrl, opts); // yield call(request, requestUrl, opts);
} // }
} catch(error) { // } catch(error) {
window.Strapi.notification.error('An error occured'); // window.Strapi.notification.error('An error occured');
} // }
} // }
export function* fetchModel(action) { export function* fetchModel(action) {
try { try {
@ -70,13 +70,13 @@ export function* submitChanges() {
export function* defaultSaga() { export function* defaultSaga() {
const loadModelWatcher = yield fork(takeLatest, MODEL_FETCH, fetchModel); const loadModelWatcher = yield fork(takeLatest, MODEL_FETCH, fetchModel);
const deleteAttributeWatcher = yield fork(takeLatest, DELETE_ATTRIBUTE, attributeDelete); // const deleteAttributeWatcher = yield fork(takeLatest, DELETE_ATTRIBUTE, attributeDelete);
const loadSubmitChanges = yield fork(takeLatest, SUBMIT, submitChanges); const loadSubmitChanges = yield fork(takeLatest, SUBMIT, submitChanges);
yield take(LOCATION_CHANGE); yield take(LOCATION_CHANGE);
yield cancel(loadModelWatcher); yield cancel(loadModelWatcher);
yield cancel(deleteAttributeWatcher); // yield cancel(deleteAttributeWatcher);
yield cancel(loadSubmitChanges); yield cancel(loadSubmitChanges);
} }

View File

@ -24,8 +24,9 @@
"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.uniqueField.description": "You won't be able to create an entry if there is an existing entry with identical content",
"form.button.cancel": "Cancel", "form.button.cancel": "Cancel",
"form.button.continue": "Continue",
"form.button.save": "Save", "form.button.save": "Save",
"form.contentType.item.connections": "Connection", "form.contentType.item.connections": "Connection",
"form.contentType.item.name": "Name", "form.contentType.item.name": "Name",
"form.contentType.item.description": "Description", "form.contentType.item.description": "Description",

View File

@ -22,6 +22,10 @@
"form.attribute.item.requiredField.description": "Vous ne pourrez pas créer une entrée si ce champ est vide", "form.attribute.item.requiredField.description": "Vous ne pourrez pas créer une entrée si ce champ est vide",
"form.attribute.item.uniqueField.description": "Vous ne pourrez pas créer une entrée s'il existe un champ similaire", "form.attribute.item.uniqueField.description": "Vous ne pourrez pas créer une entrée s'il existe un champ similaire",
"form.button.cancel": "Annuler",
"form.button.continue": "Continue",
"form.button.save": "Sauvegarder",
"form.contentType.item.connections": "Connexion", "form.contentType.item.connections": "Connexion",
"form.contentType.item.name": "Nom", "form.contentType.item.name": "Nom",
"form.contentType.item.description": "Description", "form.contentType.item.description": "Description",