From 4098a0de815013c521618b6419d91f997c986ef0 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Fri, 29 Jan 2016 14:26:02 +0100 Subject: draft displaying article --- src/web/js/components/MiddlePanel.react.js | 12 ++++-- src/web/js/components/RightPanel.react.js | 64 ++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 23 deletions(-) (limited to 'src/web/js/components') diff --git a/src/web/js/components/MiddlePanel.react.js b/src/web/js/components/MiddlePanel.react.js index a46d7346..199316e6 100644 --- a/src/web/js/components/MiddlePanel.react.js +++ b/src/web/js/components/MiddlePanel.react.js @@ -6,6 +6,7 @@ var Glyphicon = require('react-bootstrap/Glyphicon'); var MiddlePanelStore = require('../stores/MiddlePanelStore'); var MiddlePanelActions = require('../actions/MiddlePanelActions'); +var RightPanelActions = require('../actions/RightPanelActions'); var TableLine = React.createClass({ propTypes: {article_id: React.PropTypes.number.isRequired, @@ -34,23 +35,28 @@ var TableLine = React.createClass({ onClick={this.toogleRead} />); var liked = (); - return (
+ return (
{title}
{read} {liked} {this.props.title}
); }, - toogleRead: function() { + toogleRead: function(evnt) { this.setState({read: !this.state.read}, function() { MiddlePanelActions.changeRead(this.props.category_id, this.props.feed_id, this.props.article_id, this.state.read); }.bind(this)); + evnt.stopPropagation(); }, - toogleLike: function() { + toogleLike: function(evnt) { this.setState({liked: !this.state.liked}, function() { MiddlePanelActions.changeLike(this.props.category_id, this.props.feed_id, this.props.article_id, this.state.liked); }.bind(this)); + evnt.stopPropagation(); + }, + loadArticle: function() { + RightPanelActions.loadArticle(this.props.article_id); }, }); diff --git a/src/web/js/components/RightPanel.react.js b/src/web/js/components/RightPanel.react.js index 00e2dd54..328bc6b1 100644 --- a/src/web/js/components/RightPanel.react.js +++ b/src/web/js/components/RightPanel.react.js @@ -7,7 +7,17 @@ var RightPanelActions = require('../actions/RightPanelActions'); var Article = React.createClass({ propTypes: {article: React.PropTypes.object.isRequired}, render: function() { - return (
); + var icon = null; + if(this.props.article.icon_url){ + icon = (); + } + var header = (

+ {icon}Title: {this.props.article.title} +

); + return ( +
+ + ); }, }); @@ -61,7 +71,7 @@ var Category = React.createClass({ var RightPanel = React.createClass({ getInitialState: function() { - return {category: null, feed: null, article: null}; + return {category: null, feed: null, article: null, current: null}; }, getCategoryCrum: function() { return (
  • @@ -74,28 +84,39 @@ var RightPanel = React.createClass({
  • ); }, getArticleCrum: function() { - return
  • Article
  • ; + return
  • {this.state.article.title}
  • ; }, render: function() { var content = null; + var brd_category = null; + var brd_feed = null; + var brd_article = null; var breadcrum = null; + if(this.state.category) { + brd_category = (
  • + {this.state.category.name} +
  • ); + } + if(this.state.feed) { + brd_feed = (
  • + {this.state.feed.title} +
  • ); + } if(this.state.article) { - var breadcrum = (
      - {this.getCategoryCrum()} - {this.getFeedCrum()} - {this.getArticleCrum()} -
    ); - var content =
    ; - } else if(this.state.feed) { - var breadcrum = (
      - {this.getCategoryCrum()} - {this.getFeedCrum()} -
    ); + brd_article =
  • {this.state.article.title}
  • ; + } + if(brd_category || brd_feed || brd_article) { + breadcrum = (
      + {brd_category} + {brd_feed} + {brd_article} +
    ); + } + if(this.state.current == 'article') { + var content =
    ; + } else if(this.state.current == 'feed') { var content = ; - } else if(this.state.category) { - var breadcrum = (
      - {this.getCategoryCrum()} -
    ); + } else if(this.state.current == 'category') { var content = ; } @@ -108,10 +129,13 @@ var RightPanel = React.createClass({ ); }, selectCategory: function() { - this.setState({feed: null, article: null}); + this.setState({current: 'category'}); }, selectFeed: function() { - this.setState({article: null}); + this.setState({current: 'feed'}); + }, + selectArticle: function() { + this.setState({current: 'article'}); }, componentDidMount: function() { RightPanelStore.addChangeListener(this._onChange); -- cgit