Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add group chair contact info to meetings panel #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sass/panels/meeting-times.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ td, th {
width: calc(100% / 3);
}

td.small {
font-size: .8em;
}

td.xsmall {
font-size: .75em;
}

.dot-container {
text-align: center;

Expand Down
131 changes: 99 additions & 32 deletions src/panels/meeting-times.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var MeetingTimesPanel = React.createClass({
return {
index: 0,
groups: [],
displayingMeetings: true,
error: null
};
},
Expand Down Expand Up @@ -49,9 +50,13 @@ var MeetingTimesPanel = React.createClass({
},

nextPage: function() {
var newIndex = this.state.index + ROWS_PER_PAGE;
newIndex = newIndex >= this.state.groups.length ? 0 : newIndex;
this.setState({index: newIndex});
var newIndex = this.state.index;
var displayingMeetings = !this.state.displayingMeetings;
if (displayingMeetings) {
newIndex = newIndex + ROWS_PER_PAGE;
newIndex = newIndex >= this.state.groups.length ? 0 : newIndex;
}
this.setState({index: newIndex, displayingMeetings: displayingMeetings});
},

componentDidMount: function() {
Expand All @@ -62,6 +67,7 @@ var MeetingTimesPanel = React.createClass({

render: function() {
var index = this.state.index;
var displayingMeetings = this.state.displayingMeetings;
var error = this.state.error;
var body = null;
if(error){
Expand All @@ -72,45 +78,106 @@ var MeetingTimesPanel = React.createClass({
else {
var pageTimes = this.state.groups.slice(index, index + ROWS_PER_PAGE);
var items = pageTimes.map(function(meeting) {
var location = meeting.meetingLoc ? meeting.meetingLoc : 'TBA';
var meeting_time = moment(meeting.meetingTime, 'h:mm A', true);
meeting_time = meeting_time.isValid() ? time.formatTime(meeting_time, true) : undefined;
var meeting_date = time.formatMeetingDate(meeting.meetingDay) || meeting.meetingDay;
var fulltime = (meeting_date && meeting_time) ?
(meeting_date + ', ' + meeting_time) : 'TBA';
return <tr key={meeting.name}>
<td>{meeting.name}</td>
<td>{location}</td>
<td>{fulltime}</td>
</tr>;
if (displayingMeetings) {
var location = meeting.meetingLoc ? meeting.meetingLoc : 'TBA';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Location, meeting_time, meeting_date, and fulltime can be calculated outside the if/else block

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed them from the else block since they weren't used there - I can move them and the chair stuff outside the if/else, but then they would be calculated where they're not needed.

var meeting_time = moment(meeting.meetingTime, 'h:mm A', true);
meeting_time = meeting_time.isValid() ? time.formatTime(meeting_time, true) : undefined;
var meeting_date = time.formatMeetingDate(meeting.meetingDay) || meeting.meetingDay;

var fulltime = (meeting_date && meeting_time) ?
(meeting_date + ', ' + meeting_time) : 'TBA';
return <tr key={meeting.name}>
<td>{meeting.name}</td>
<td>{location}</td>
<td>{fulltime}</td>
</tr>;
}
else {
var chairs = meeting.chairs.replace(' and ', ',').split(',');
var chair_name = 'N/A';
if (chairs.length > 0) {
var name_split = $.trim(chairs[0]);
chair_name = name_split;
}

var chair_contacts = meeting.chairContact.split(',');
var display_contact = 'N/A';
if (chairs.length > 0) {
display_contact = chair_contacts[0];
}

var name_class = '';
if (chair_name.length > 17) {
name_class = 'xsmall';
}
else if (chair_name.length > 14) {
name_class = 'small';
}

var fulltime = (meeting_date && meeting_time) ?
(meeting_date + ', ' + meeting_time) : 'TBA';
return <tr key={meeting.name}>
<td>{meeting.name}</td>
<td className={name_class}>{chair_name}</td>
<td>{display_contact}</td>
</tr>;
}

});

var dots = [];
for (var i = 0; i < this.state.groups.length; i += ROWS_PER_PAGE) {
var dotClass = classNames({
dot: true,
active: i == index
active: displayingMeetings && i == index
});
dots.push(<span key={i} className={dotClass} />);

var dotClass2 = classNames({
dot: true,
active: !displayingMeetings && i == index
});
dots.push(<span key={i + 1} className={dotClass2} />);
}

body = <div className="panel-body meeting-times-body">
<table>
<thead>
<tr>
<th>Name</th>
<th>Location</th>
<th>Time</th>
</tr>
</thead>
<tbody>
{items}
</tbody>
</table>
<div className="dot-container">
{dots}
</div>
</div>;
if (displayingMeetings) {
body = <div className="panel-body meeting-times-body">
<table>
<thead>
<tr>
<th>Name</th>
<th>Location</th>
<th>Time</th>
</tr>
</thead>
<tbody>
{items}
</tbody>
</table>
<div className="dot-container">
{dots}
</div>
</div>;
}
else {
body = <div className="panel-body meeting-times-body">
<table>
<thead>
<tr>
<th>Name</th>
<th>Chair</th>
<th>Contact</th>
</tr>
</thead>
<tbody>
{items}
</tbody>
</table>
<div className="dot-container">
{dots}
</div>
</div>;
}
}
return <div className="panel">
<div className="panel-heading">
Expand Down