Author: jruchaud Date: 2015-04-30 09:50:31 +0000 (Thu, 30 Apr 2015) New Revision: 1306 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1306 Log: Implement un/select all Modified: wit/js/components/FilterLogs.js Modified: wit/js/components/FilterLogs.js =================================================================== --- wit/js/components/FilterLogs.js 2015-04-29 20:18:03 UTC (rev 1305) +++ wit/js/components/FilterLogs.js 2015-04-30 09:50:31 UTC (rev 1306) @@ -99,6 +99,18 @@ this.createTree(nextProps); }, + toggleTagChecked: function(e) { + Object.keys(this.state.tags).forEach(function(tag) { + this.state.tags[tag] = e.target.checked; + }, this); + + this.createTree({ + data: this.props.data, + tags: this.state.tags + }); + e.stopPropagation(); + }, + filterTag: function(e) { this.state.tags[e.target.name] = e.target.checked; this.createTree({ @@ -197,46 +209,54 @@ return ( <div className={classString}> - <h1>{items.length ? "Result" : "No result"}</h1> + <h1>Result</h1> - <div className={items.length ? "" : "hidden"}> - <div ref="actions" className="btn-group" role="group"> - <button type="button" className="btn btn-primary" onClick={this.onToggleFilterTag}> - Filter <span className="glyphicon glyphicon-tag" aria-hidden="true"></span> - </button> - - <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> + <div ref="actions" className="btn-group" role="group"> + <button type="button" className="btn btn-primary" onClick={this.onToggleFilterTag}> + Filter <span className="glyphicon glyphicon-tag" 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> + <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> + + <div ref="filterTags" className="hidden" onChange={this.filterTag}> + <div className="pull-left"> + <label className="checkbox-label"> + <input type="checkbox" defaultChecked onChange={this.toggleTagChecked} /> + select/unselect all + </label> </div> + {tags} + </div> - <div ref="filterTags" className="hidden" onChange={this.filterTag}> - {tags} - </div> + <table className="table"> + <thead> + <tr> + <th>Date</th> + <th>Duration</th> + <th>Tags</th> + </tr> + </thead> + <tbody> + {items} + </tbody> + </table> - <table className="table"> - <thead> - <tr> - <th>Date</th> - <th>Duration</th> - <th>Tags</th> - </tr> - </thead> - <tbody> - {items} - </tbody> - </table> - </div> + <h3 className={items.length ? "hidden" : "text-center"}> + No result ! + </h3> </div> ); }