Skip to content

Commit b0e638f

Browse files
author
Ray Villalobos
committed
04_03e
1 parent d9efebb commit b0e638f

3 files changed

Lines changed: 37 additions & 13 deletions

File tree

builds/app/js/app.js

Lines changed: 19 additions & 7 deletions
Large diffs are not rendered by default.

process/js/SearchAppointments.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ var SearchAppointments = React.createClass({
1111
<button type="button" className="btn btn-primary dropdown-toggle"
1212
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Sort by: <span className="caret"></span></button>
1313
<ul className="dropdown-menu dropdown-menu-right">
14-
<li><a href="#" id="petName">Pet Name</a></li>
15-
<li><a href="#" id="aptDate">Date</a></li>
16-
<li><a href="#" id="ownerName">Owner</a></li>
14+
<li><a href="#" id="petName">Pet Name { (this.props.orderBy === 'petName') ? <span className="glyphicon glyphicon-ok"></span>: null }</a></li>
15+
<li><a href="#" id="aptDate">Date { (this.props.orderBy === 'aptDate') ? <span className="glyphicon glyphicon-ok"></span>: null }</a></li>
16+
<li><a href="#" id="ownerName">Owner { (this.props.orderBy === 'ownerName') ? <span className="glyphicon glyphicon-ok"></span>: null }</a></li>
1717
<li role="separator" className="divider"></li>
18-
<li><a href="#" id="asc">Asc</a></li>
19-
<li><a href="#" id="desc">Desc</a></li>
18+
<li><a href="#" id="asc">Asc { (this.props.orderDir === 'asc') ? <span className="glyphicon glyphicon-ok"></span>: null }</a></li>
19+
<li><a href="#" id="desc">Desc { (this.props.orderDir === 'desc') ? <span className="glyphicon glyphicon-ok"></span>: null }</a></li>
2020
</ul>
2121
</div>
2222
</div>

process/js/app.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ var MainInterface = React.createClass({
1010
getInitialState: function() {
1111
return {
1212
aptBodyVisible: false,
13+
orderBy: 'petName',
14+
orderDir: 'asc',
1315
myAppointments: []
1416
} //return
1517
}, //getInitialState
@@ -52,6 +54,13 @@ var MainInterface = React.createClass({
5254

5355
render: function() {
5456
var filteredApts = this.state.myAppointments;
57+
var orderBy = this.state.orderBy;
58+
var orderDir = this.state.orderDir;
59+
60+
filteredApts = _.orderBy(filteredApts, function(item) {
61+
return item[orderBy].toLowerCase();
62+
}, orderDir);//orderBy
63+
5564
filteredApts = filteredApts.map(function(item, index) {
5665
return(
5766
<AptList key = { index }
@@ -67,7 +76,10 @@ var MainInterface = React.createClass({
6776
handleToggle = { this.toggleAddDisplay }
6877
addApt = { this.addItem }
6978
/>
70-
<SearchAppointments />
79+
<SearchAppointments
80+
orderBy = { this.state.orderBy }
81+
orderDir = { this.state.orderDir }
82+
/>
7183
<ul className="item-list media-list">{filteredApts}</ul>
7284
</div>
7385
) //return

0 commit comments

Comments
 (0)