Skip to content
This repository has been archived by the owner on Aug 27, 2018. It is now read-only.

Commit

Permalink
fixing the display align
Browse files Browse the repository at this point in the history
  • Loading branch information
GuenoleK committed Nov 8, 2016
1 parent 27419e2 commit b42610e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/behaviours/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const fieldForBuilder = (props, textOnly = false, multiple = false, list = false
if (get(definitions, `${entityPath}.${propertyName}`).validateOnBlur !== false) onInputBlur(propertyName, entityPath, rawInputValue);
if (userDefinedOnBlur) userDefinedOnBlur();
};
const fieldForLine = list ? fieldForListBuilder(entityPath, propertyName, false, false, options.listOnly)(props): {};
const fieldForLine = list ? fieldForListBuilder(entityPath, propertyName, false, false, options.isRaw, options.listOnly)(props): {};
const selectForLine = list ? fieldForListBuilder(entityPath, propertyName, true)(props): {};
const textForLine = list ? fieldForListBuilder(entityPath, propertyName, false, true)(props): {};

Expand All @@ -72,7 +72,7 @@ const fieldForBuilder = (props, textOnly = false, multiple = false, list = false
}


const fieldForListBuilder = (entityPathList, propertyNameList, multiple= false, textOnly= false, listOnly) => {
const fieldForListBuilder = (entityPathList, propertyNameList, multiple= false, textOnly= false, isRaw, listOnly) => {
const fieldForLineBuilder = (connectedComponentProps) => (propertyName, {FieldComponent = DefaultFieldComponent, entityPath, onBlur: userDefinedOnBlur,onChange: userDefinedOnChange, ...options} = {}, index) => {
const {fields, definitions, domains, onInputChange, onInputBlur, entityPathArray, editing, onInputBlurList} = connectedComponentProps;
const {onChange: optionsOnChange, ...otherOptions} = options;
Expand Down Expand Up @@ -107,6 +107,7 @@ const fieldForListBuilder = (entityPathList, propertyNameList, multiple= false,
onChange={onChange}
onBlur={onBlur}
fields={fields}
isRaw={isRaw}
{...connectedComponentProps}
{...options} />;
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const FieldLabelValueComponent = ({editing, isRequired, label, name, valid, Valu
<div data-focus='field' className='mdl-grid' data-mode={editing ? 'edit' : 'consult'} data-required={isRequired} data-valid={valid}>
<div
data-focus='field-label-container'
className={(isRaw && index === undefined || listOnly) ? '' : (isRaw && index != undefined) ? 'mdl-cell mdl-cell--top mdl-cell--2-col' : 'mdl-cell mdl-cell--top mdl-cell--4-col'} style={(listOnly) ? {margin: '8px', width: 'calc(10% - 16px)'} : (index != undefined || isRaw) ? {marginTop: '0px'} : {}}>
className={(isRaw && index === undefined && !listOnly && label != undefined) ? ''
: (isRaw && index != undefined || isRaw && listOnly || isRaw && label === undefined) ? 'mdl-cell mdl-cell--top mdl-cell--2-col'
: 'mdl-cell mdl-cell--top mdl-cell--4-col'} style={(index != undefined || isRaw) ? {marginTop: '0px'} : {}}>
{(displayLabel || (displayLabel === false && index != undefined) || displayLabel === undefined) && <Label name={name} text={label} />}
</div>
<div data-focus='field-value-container' className='mdl-cell mdl-cell--top mdl-cell--8-col' style={(index != undefined || isRaw) ? {marginTop: '0px'} : {}}>
Expand All @@ -35,7 +37,6 @@ class Field extends PureComponent {
SelectComponentDisplay = DefaultSelectDisplayComponent,
ListComponent = DefaultListComponent } = otherProps.metadata;

console.log(listOnly);
const renderConsult = () => list ? <ListComponent fieldForLine={fieldForLine} values={otherProps.formattedInputValue} {...otherProps}/> : (multiple ? <SelectComponentDisplay {...otherProps} /> : <DisplayComponent {...otherProps} />);
const renderEdit = () => list ? <ListComponent fieldForLine={fieldForLine} values={otherProps.formattedInputValue} {...otherProps}/> : (multiple ? <SmartSelectComponent SelectComponent={SelectComponent} {...otherProps}/> : <InputComponent {...otherProps}/>);
const ValueComponent = otherProps.editing ? renderEdit() : renderConsult();
Expand Down
2 changes: 1 addition & 1 deletion src/components/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {PropTypes} from 'react';


function List({fieldForLine, selectForLine, textForLine, LineComponent, children, options, error, values, ...otherProps}) {
const renderLine = () => { debugger
const renderLine = () => {
return (values ? values.map((element, index) => {
// fieldFor which wrapp the index.
const lineFieldFor = (linePropertyName, lineOptions) => fieldForLine(linePropertyName, lineOptions, index)
Expand Down

0 comments on commit b42610e

Please sign in to comment.