From 9aed8783056b6ac220289a096e342f98a4b14e1c Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 25 Jul 2013 22:45:04 +0200 Subject: Add user filter Users can now either look at the whole list or only tasks assigned to them. Currently this waits for the refresh to change the list, this should be fixed in the future. --- static/js/main.js | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'static/js') diff --git a/static/js/main.js b/static/js/main.js index c20c615..457bd6f 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -393,15 +393,18 @@ var StoryForm = React.createClass({ var StoryPage = React.createClass({ loadStoriesFromServer: function() { - $.get(this.props.url) + $.get(this.state.url) .done(function(data) { this.setState({data: []}); this.setState({data: data}); }.bind(this)); }, getInitialState: function() { - return {data: []}; + return {data: [], url: this.props.url}; }, + setUrl: React.autoBind(function(url) { + this.setState({url: url}); + }), componentWillMount: function() { this.loadStoriesFromServer(); setInterval( @@ -456,7 +459,35 @@ var StoryPage = React.createClass({ } }); +var StoryFilter = React.createClass({ + getInitialState: function() { + return {filter: 'all'}; + }, + handleClick: React.autoBind(function(event) { + this.setState({filter: (this.state.filter != 'all' + ? 'all' : 'user')}); + scrumli_page.setUrl((this.state.filter == "all" + ? "/stories" : "/stories/mine")); + }), + render: function() { + var classes = {all: ['icon-group', 'All'], + user: ['icon-user', 'Mine']}; + + return ( + + {" "} {classes[this.state.filter][1]} + ); + } +}); + +var scrumli_page = ; + React.renderComponent( - , + scrumli_page, document.getElementById('content') ); + +React.renderComponent( + , + document.getElementById('filter') +); -- cgit v1.2.3-54-g00ecf