Skip to content
Snippets Groups Projects
Commit ece63dfb authored by Martin Ledvinka's avatar Martin Ledvinka
Browse files

UI library update. Most notably updated to Reflux 6.0.0 a rewrote the...

UI library update. Most notably updated to Reflux 6.0.0 a rewrote the TeacherStore and TeachersController to the new Reflux ES6 style.
parent e6bb9986
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
<groupId>cz.cvut.kbss</groupId>
<!-- ArtifactId identifies the project in the group -->
<artifactId>ear-setup</artifactId>
<version>0.0.2</version>
<version>0.0.3</version>
<!-- war packaging is important, otherwise Maven would try to package the application into a jar -->
<packaging>war</packaging>
......
'use strict';
import React from 'react';
import Reflux from "reflux";
import Actions from '../actions/Actions';
import Teachers from './Teachers';
import TeacherStore from '../stores/TeacherStore';
export default class TeachersController extends React.Component {
export default class TeachersController extends Reflux.Component {
constructor(props) {
super(props);
this.state = {
teachers: []
};
this.state = {};
this.store = TeacherStore;
}
componentDidMount() {
Actions.loadTeachers();
this.unsubscribe = TeacherStore.listen(this._onTeachersLoaded);
}
componentWillUnmount() {
this.unsubscribe();
}
_onTeachersLoaded = (data) => {
this.setState({teachers: data});
};
render() {
return <Teachers teachers={this.state.teachers}/>;
}
......
......@@ -7,18 +7,23 @@ import Actions from '../actions/Actions';
const URL = 'rest/teachers';
const TeacherStore = Reflux.createStore({
listenables: [Actions],
export default class TeacherStore extends Reflux.Store {
onLoadTeachers: function() {
constructor() {
super();
this.state = {
teachers: []
};
this.listenables = Actions;
}
onLoadTeachers() {
request.get(URL).accept('json').end((err, resp) => {
if (err) {
console.log('Error when loading teachers. Status: ' + err.status);
} else {
this.trigger(resp.body);
this.setState({teachers: resp.body});
}
});
}
});
export default TeacherStore;
}
{
"name": "ear-setup",
"version": "0.0.1",
"version": "0.0.3",
"description": "System setup sample project for EAR.",
"main": "js/app.js",
"dependencies": {
"react": "~15.0.2",
"react-dom": "~15.0.2",
"react": "~15.4.2",
"react-dom": "~15.4.2",
"keymirror": "~0.1.0",
"object-assign": "~4.0.1",
"superagent": "~1.8.3",
"react-bootstrap": "~0.28.5",
"react-bootstrap": "~0.30.7",
"body-parser": "~1.15.0",
"express": "~4.13.4",
"reflux": "~0.4.1",
"reflux": "~6.0.0",
"classnames": "~2.2.3",
"remarkable": "~1.6.2",
"js-cookie": "~2.1.0",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment