Author: jruchaud Date: 2015-04-29 15:10:57 +0000 (Wed, 29 Apr 2015) New Revision: 1301 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1301 Log: Manage no result Modified: wit/js/components/FilterLogs.js Modified: wit/js/components/FilterLogs.js =================================================================== --- wit/js/components/FilterLogs.js 2015-04-29 15:08:07 UTC (rev 1300) +++ wit/js/components/FilterLogs.js 2015-04-29 15:10:57 UTC (rev 1301) @@ -81,7 +81,7 @@ }, getInitialState: function() { - return {data: {}}; + return {data: null}; }, componentWillReceiveProps: function(nextProps) { @@ -135,44 +135,52 @@ render: function() { var items = []; - var dates = Object.keys(this.state.data); - for (var date of dates) { - var r = this.renderTd(date, [], this.state.data[date]); - items = items.concat(r); + var classString = ""; + if (!this.state.data) { + classString = "hidden"; + + } else { + var dates = Object.keys(this.state.data); + for (var date of dates) { + var r = this.renderTd(date, [], this.state.data[date]); + items = items.concat(r); + } } - + return ( - <div> - <h1>Result</h1> - - <div ref="actions" className="btn-group" role="group"> - <button type="button" className="btn btn-primary" onClick={this.onClipboardCSV}> - CSV <span className="glyphicon glyphicon-copy" aria-hidden="true"></span> - </button> - <button type="button" className="btn btn-primary" onClick={this.onClipboardTXT}> - TXT <span className="glyphicon glyphicon-copy" aria-hidden="true"></span> - </button> - - <button type="button" className="btn btn-primary" onClick={this.onMailCSV}> - CSV <span className="glyphicon glyphicon-envelope" aria-hidden="true"></span> - </button> - <button type="button" className="btn btn-primary" onClick={this.onMailTXT}> - TXT <span className="glyphicon glyphicon-envelope" aria-hidden="true"></span> - </button> + <div className={classString}> + <h1>{items.length ? "Result" : "No result"}</h1> + + <div className={items.length ? "" : "hidden"}> + <div ref="actions" className="btn-group" role="group"> + <button type="button" className="btn btn-primary" onClick={this.onClipboardCSV}> + CSV <span className="glyphicon glyphicon-copy" aria-hidden="true"></span> + </button> + <button type="button" className="btn btn-primary" onClick={this.onClipboardTXT}> + TXT <span className="glyphicon glyphicon-copy" aria-hidden="true"></span> + </button> + + <button type="button" className="btn btn-primary" onClick={this.onMailCSV}> + CSV <span className="glyphicon glyphicon-envelope" aria-hidden="true"></span> + </button> + <button type="button" className="btn btn-primary" onClick={this.onMailTXT}> + TXT <span className="glyphicon glyphicon-envelope" aria-hidden="true"></span> + </button> + </div> + + <table className="table"> + <thead> + <tr> + <th>Date</th> + <th>Duration</th> + <th>Tags</th> + </tr> + </thead> + <tbody> + {items} + </tbody> + </table> </div> - - <table className="table"> - <thead> - <tr> - <th>Date</th> - <th>Duration</th> - <th>Tags</th> - </tr> - </thead> - <tbody> - {items} - </tbody> - </table> </div> ); }
participants (1)
-
jruchaud@users.nuiton.org