mirror of
https://github.com/strapi/strapi.git
synced 2025-08-05 15:29:04 +00:00
Fix design
This commit is contained in:
parent
28f35f678b
commit
8422e8c2f1
@ -52,6 +52,7 @@
|
||||
}
|
||||
|
||||
.buttonContainer {
|
||||
padding-top: .3rem;
|
||||
> button:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
|
||||
|
||||
const modalFooter = this.props.noButtons ? <div className={styles.modalFooter} />
|
||||
: <ModalFooter className={styles.modalFooter}>
|
||||
<Button onClick={this.props.toggle} className={styles.secondary}>Cancel</Button>
|
||||
<Button type="submit" onClick={this.props.handleSubmit} className={styles.primary}>Save</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}><FormattedMessage id={this.props.buttonSubmitMessage} /></Button>{' '}
|
||||
</ModalFooter>;
|
||||
return (
|
||||
<div className={styles.popUpForm}>
|
||||
@ -102,6 +102,7 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
|
||||
}
|
||||
|
||||
PopUpForm.propTypes = {
|
||||
buttonSubmitMessage: React.PropTypes.string.isRequired,
|
||||
form: React.PropTypes.oneOfType([
|
||||
React.PropTypes.array.isRequired,
|
||||
React.PropTypes.object.isRequired,
|
||||
|
@ -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 noButtons = includes(this.props.hash, '#choose');
|
||||
|
||||
const buttonSubmitMessage = includes(this.props.hash.split('::')[1], 'contentType') ? 'form.button.save' : 'form.button.continue';
|
||||
return (
|
||||
<div className={styles.form}>
|
||||
<PopUpForm
|
||||
@ -326,6 +326,7 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
||||
noButtons={noButtons}
|
||||
overrideRenderInputCondition={this.checkForNestedInput}
|
||||
overrideRenderInput={this.renderInput}
|
||||
buttonSubmitMessage={buttonSubmitMessage}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -59,6 +59,7 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
|
||||
|
||||
// Refecth content type after editing it
|
||||
if (prevProps.location.hash !== this.props.location.hash && this.props.didFetchModel) {
|
||||
console.log('ok')
|
||||
this.fetchModel();
|
||||
}
|
||||
}
|
||||
@ -187,7 +188,7 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
|
||||
render() {
|
||||
// Url to redirects the user if he modifies the temporary content type name
|
||||
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 ?
|
||||
<EmptyAttributesView handleClick={this.handleClickAddAttribute} /> :
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { fromJS, Map, List } from 'immutable';
|
||||
// import { findIndex, differenceWith, isEqual, filter } from 'lodash';
|
||||
/* eslint-disable new-cap */
|
||||
import {
|
||||
ADD_ATTRIBUTE_TO_CONTENT_TYPE,
|
||||
@ -22,17 +23,24 @@ const initialState = fromJS({
|
||||
attributes: List(),
|
||||
}),
|
||||
postContentTypeSuccess: false,
|
||||
showButtons: false,
|
||||
});
|
||||
|
||||
function modelPageReducer(state = initialState, action) {
|
||||
switch (action.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
|
||||
.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));
|
||||
}
|
||||
case MODEL_FETCH_SUCCEEDED:
|
||||
return state
|
||||
.set('model', Map(action.model.model))
|
||||
|
@ -9,27 +9,27 @@ import { temporaryContentTypePosted } from 'containers/App/actions';
|
||||
|
||||
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 { makeSelectModel } from './selectors';
|
||||
|
||||
// Individual exports for testing
|
||||
export function* attributeDelete(action) {
|
||||
try {
|
||||
if (action.sendRequest) {
|
||||
const body = yield select(makeSelectModel());
|
||||
const requestUrl = `/content-type-builder/models/${action.modelName}`;
|
||||
const opts = {
|
||||
method: 'PUT',
|
||||
body,
|
||||
};
|
||||
|
||||
yield call(request, requestUrl, opts);
|
||||
}
|
||||
} catch(error) {
|
||||
window.Strapi.notification.error('An error occured');
|
||||
}
|
||||
}
|
||||
// export function* attributeDelete(action) {
|
||||
// try {
|
||||
// if (action.sendRequest) {
|
||||
// const body = yield select(makeSelectModel());
|
||||
// const requestUrl = `/content-type-builder/models/${action.modelName}`;
|
||||
// const opts = {
|
||||
// method: 'PUT',
|
||||
// body,
|
||||
// };
|
||||
//
|
||||
// yield call(request, requestUrl, opts);
|
||||
// }
|
||||
// } catch(error) {
|
||||
// window.Strapi.notification.error('An error occured');
|
||||
// }
|
||||
// }
|
||||
|
||||
export function* fetchModel(action) {
|
||||
try {
|
||||
@ -70,13 +70,13 @@ export function* submitChanges() {
|
||||
|
||||
export function* defaultSaga() {
|
||||
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);
|
||||
|
||||
yield take(LOCATION_CHANGE);
|
||||
|
||||
yield cancel(loadModelWatcher);
|
||||
yield cancel(deleteAttributeWatcher);
|
||||
// yield cancel(deleteAttributeWatcher);
|
||||
yield cancel(loadSubmitChanges);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
"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.continue": "Continue",
|
||||
"form.button.save": "Save",
|
||||
|
||||
"form.contentType.item.connections": "Connection",
|
||||
|
@ -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.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.name": "Nom",
|
||||
"form.contentType.item.description": "Description",
|
||||
|
Loading…
x
Reference in New Issue
Block a user