On Github get-focus / formation-focus
import React from 'react'; import { Route, IndexRoute } from 'react-router'; import AppLayout from '../components/layout' import HomeRoute from './home-route'; import MasterdataRoutes from './masterdata-routes'; import MoviesRoutes from './movies-route'; import PersonsRoutes from './persons-route'; import SearchRoutes from './advanced-search-route'; import ErrorRoutes from './error-route'; export default { path: `${__BASE_URL__}`, indexRoute: { onEnter: ({ params }, replace) => replace(`${__BASE_URL__}home`) }, component: AppLayout, childRoutes: [...HomeRoute, ...MasterdataRoutes, ...MoviesRoutes, ...PersonsRoutes, ...SearchRoutes, ...ErrorRoutes] }; import React from 'react'; import MovieDetailView from '../views/movie/detail'; const route = [ { path: 'movies/:id', component: (props) => () } ]; export default route;
import moment from 'moment'; import {Date as DateComponent} from 'focus-components/components/input'; export default { InputComponent: DateComponent, formatter: date => date ? moment(date, moment.ISO_8601).format('DD/MM/YYYY') : '', format: ['DD/MM/YYYY', 'DD-MM-YYYY', 'D MMM YYYY'] };
export const movie = { code: { domain: 'DO_ID', required: true }, title: { domain: 'DO_LABEL_LONG', required: true }, creationDate: { domain: 'DO_DATE', required: false } } // fieldFor(creationDate)
import fetch from 'focus-core/network/fetch'; //Fait une reqête ajax import movieUrl from '../config/server/movies'; // Les urls de ws sont configurées export default { loadMovie(id) { return fetch(movieUrl.loadMovie({urlData: {id}})); }, saveMovieSynopsis(data) { return fetch(movieUrl.saveMovie({urlData: {id: data.id}, data: {data}})); }, saveMovieCaracteristics(data) { return fetch(movieUrl.saveMovie({urlData: {id: data.id}, data: {data}})); } }
import {CoreStore} from 'focus-core/store'; const movieStore = new CoreStore({ definition: { movie: 'movie', actors: 'actors' } }); export default movieStore;
import actionBuilder from 'focus-core/application/action-builder'; import {loadMovie, saveMovieSynopsis} from '../services/movie'; export const synopsisActions = { load: actionBuilder({ node: 'movie', service: loadMovie, shouldDumpStoreOnActionCall: true, status: 'loaded' }), save: actionBuilder({ node: 'movie', service: saveMovieSynopsis, shouldDumpStoreOnActionCall: true, status: 'saved' }) }
//librairies import React, {PropTypes} from 'react'; import FocusComponents from 'focus-components'; // web components import Panel from 'focus-components/components/panel'; import {mixin as formMixin} from 'focus-components/common/form'; //stores & actions import movieStore from '../../../stores/movie'; import {caracteristicsActions} from '../../../action/movie'; export default React.createClass({ displayName: 'MovieCaracteristics', propTypes: { id: PropTypes.number }, mixins: [formMixin], definitionPath: 'movie', stores: [{store: movieStore, properties: ['movie']}], action: caracteristicsActions, /** @inheritDoc */ renderContent() { return ( <panel actions="{this._renderActions}" title="movie.detail.caracteristics"> {this.fieldFor('title')} {this.fieldFor('originalTitle')} {this.fieldFor('keywords')} {this.fieldFor('runtime')} {this.fieldFor('movieType')} {this.fieldFor('productionYear')} {this.fieldFor('trailerName')} {this.fieldFor('trailerHRef')} </panel> ); } });