Skip to content

Commit

Permalink
Part of #42 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
larousso committed Feb 13, 2018
1 parent 5160f3c commit 9d7f84b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 27 deletions.
16 changes: 14 additions & 2 deletions example/example-spring/javascript/src/pages/TvShow.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,20 @@ export default class TvShow extends React.Component {
</a>
<Feature path={"mytvshows:season:markaswatched"}>
<Enabled>
{s.allWatched && <button onClick={this.markSeasonWatched(s.number, false)} className="btn btn default pull-right addBtn"><i className="glyphicon glyphicon-ok"/></button>}
{!s.allWatched && <button onClick={this.markSeasonWatched(s.number, true)} className="btn btn default pull-right addBtn"> ADD </button>}
{s.allWatched &&
<button
onClick={this.markSeasonWatched(s.number, false)}
className="btn btn default pull-right addBtn">
<i className="glyphicon glyphicon-ok"/>
</button>
}
{!s.allWatched &&
<button
onClick={this.markSeasonWatched(s.number, true)}
className="btn btn default pull-right addBtn">
ADD
</button>
}
</Enabled>
<Disabled>
<div></div>
Expand Down
27 changes: 14 additions & 13 deletions izanami-server/javascript/src/izanami/inputs/FieldError.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ export class FieldError extends Component {

render() {

const display = this.props.error && this.props.errorMessage
const display = this.props.error || ((this.props.errorMessage || []).length > 0);

if (display) {
return (
<div className="form-group has-error-perso">

{this.props.children}
{
this.props.errorMessage.map((err, index) =>
<div>
<label className="control-label col-sm-offset-2 paddingLabelError" for="inputError1" key={index}>{TranslateService.translate(err)}</label>
</div>
)
}


<div className="form-group has-error">
{this.props.children}
{this.props.errorMessage.map((err, index) =>
<div>
<label
className="control-label col-sm-offset-2 paddingLabelError"
for="inputError1"
key={index}
>
{TranslateService.translate(err)}
</label>
</div>
)}
</div>
);
}
Expand Down
13 changes: 12 additions & 1 deletion izanami-server/javascript/src/izanami/inputs/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ export class Form extends Component {
}
};

getSchema = (name) => {
let current = {...this.props.schema[name]};
if (!current.error) {
current.error = {
key: `obj.${name}`
}
}
return current;
};


generateStep(name, idx) {
if (_.isFunction(name)) {
return React.createElement(name, {})
Expand All @@ -57,7 +68,7 @@ export class Form extends Component {
} else if (name === '---') {
return <hr key={idx}/>
} else {
const {type, disabled, props = {}, error} = this.props.schema[name];
const {type, disabled, props = {}, error} = this.getSchema(name);


let fieldOnError = false;
Expand Down
13 changes: 2 additions & 11 deletions izanami-server/javascript/src/izanami/inputs/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,26 +366,17 @@ export class Table extends Component {
reader.readAsText(e.target.files[0]);
};

buildErrorList = ({errors, fieldErrors = {}}) => {
buildErrorList = ({errors = {}, fieldErrors = {}}) => {
const errorsOnFields = Object.keys(fieldErrors)
.flatMap(k => {
const messages = fieldErrors[k];
const messages = fieldErrors[k] || [];
return messages.map(({message = "", args = []}) =>
({message: `${k}.${message}`, args})
)
});
return [...errors, ...errorsOnFields];
};



toggleModal = (i, value) => {
let deletes = {...this.state.confirmDeletes};
deletes[i] = value;
console.log('deletes', deletes);
return deletes;
};

render() {
console.log('State', this.state);
const columns = this.props.columns.map(c => ({
Expand Down

0 comments on commit 9d7f84b

Please sign in to comment.