From 689e1deb8bf97e1371366bdac6f88b0d2173bb82 Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Thu, 26 Jul 2018 12:13:00 -0700 Subject: [PATCH 1/2] fixed bug where 'next up:' still appears before meeting title of meeting in progress --- .../src/components/flightboard/Flightboard.js | 2 +- .../components/flightboard/FlightboardRow.js | 68 ++++++++++--------- .../src/components/single-room/Display.js | 8 +++ 3 files changed, 46 insertions(+), 32 deletions(-) diff --git a/ui-react/src/components/flightboard/Flightboard.js b/ui-react/src/components/flightboard/Flightboard.js index 01f5ca0..bc70d57 100644 --- a/ui-react/src/components/flightboard/Flightboard.js +++ b/ui-react/src/components/flightboard/Flightboard.js @@ -59,7 +59,7 @@ class Flightboard extends Component { { response ? (!error ? rooms.map((room, key) => - + ) :
diff --git a/ui-react/src/components/flightboard/FlightboardRow.js b/ui-react/src/components/flightboard/FlightboardRow.js index dc52cf0..21cc8d1 100644 --- a/ui-react/src/components/flightboard/FlightboardRow.js +++ b/ui-react/src/components/flightboard/FlightboardRow.js @@ -14,16 +14,22 @@ class FlightboardRow extends Component { } getAppointmentTime = () => { - const { item, now } = this.props; + const { room, now } = this.props; - // check if there are times in the item.Start & item.End + // check if there are times in the room.Start & room.End // then: if the meeting is not going on now, append "Next Up: " - if (typeof item.Appointments !== 'undefined' && item.Appointments.length > 0) { - if (item.Appointments[0].Start && item.Appointments[0].End) { + if (typeof room.Appointments !== 'undefined' && room.Appointments.length > 0) { + if (room.Appointments[0].Start && room.Appointments[0].End) { this.setState({ timesPresent: true }); - if (item.Appointments[0].Start < now && now < item.Appointments[0].End) { } else { + + if (room.Busy) { + this.setState({ + nextUp: '' + }); + } + else { this.setState({ nextUp: fbConfig.board.nextUp + ': ' }); @@ -38,7 +44,7 @@ class FlightboardRow extends Component { render() { const { nextUp, timesPresent } = this.state; - const { item, now } = this.props; + const { room, now } = this.props; const styles = { show: {display: 'block'}, @@ -46,21 +52,21 @@ class FlightboardRow extends Component { flex: {display: 'flex'} } - const room = item.Name.toLowerCase().replace(/\s+/g, "-"); - const roomlist = 'roomlist-' + item.Roomlist.toLowerCase().replace(/\s+/g, "-"); + const roomName = room.Name.toLowerCase().replace(/\s+/g, "-"); + const roomlist = 'roomlist-' + room.Roomlist.toLowerCase().replace(/\s+/g, "-"); // set row class based on meet room status - let meetingRoomClass = `${ room } meeting-room ${ item.Busy ? 'meeting-room-busy' : '' }`; - meetingRoomClass += item.Busy ? ' meeting-room-busy' : ''; - meetingRoomClass += item.ErrorMessage ? ' meeting-room-error' : ''; - const meetingClass = item.ErrorMessage + let meetingRoomClass = `${ roomName } meeting-room ${ room.Busy ? 'meeting-room-busy' : '' }`; + meetingRoomClass += room.Busy ? ' meeting-room-busy' : ''; + meetingRoomClass += room.ErrorMessage ? ' meeting-room-error' : ''; + const meetingClass = room.ErrorMessage ? 'meeting-error' - : item.Busy + : room.Busy ? 'meeting-busy' : 'meeting-open'; - let statusText = item.ErrorMessage + let statusText = room.ErrorMessage ? fbConfig.board.statusError - : item.Busy + : room.Busy ? fbConfig.board.statusBusy : fbConfig.board.statusAvailable; @@ -70,45 +76,45 @@ class FlightboardRow extends Component {
-
-
+
+
{statusText}
-
- {item.Name} +
+ {room.Name}
-
- {timesPresent && item.Appointments[0].End >= now && +
+ {timesPresent && room.Appointments[0].End >= now &&
- + {nextUp} - - {item.Appointments[0].Subject} + + {room.Appointments[0].Subject}
}
-
+
{timesPresent ? - new Date(parseInt(item.Appointments[0].Start, 10)).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) + ' - ' + new Date(parseInt(item.Appointments[0].End, 10)).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) + new Date(parseInt(room.Appointments[0].Start, 10)).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) + ' - ' + new Date(parseInt(room.Appointments[0].End, 10)).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) : '' }
-
- {timesPresent && item.Appointments[0].End >= now && - item.Appointments[0].Organizer +
+ {timesPresent && room.Appointments[0].End >= now && + room.Appointments[0].Organizer }
- + @@ -124,7 +130,7 @@ class FlightboardRow extends Component { } FlightboardRow.propTypes = { - item: PropTypes.string, + room: PropTypes.string, now: PropTypes.instanceOf(Date), key: PropTypes.number, filter: PropTypes.string diff --git a/ui-react/src/components/single-room/Display.js b/ui-react/src/components/single-room/Display.js index 93dc7df..6f47a89 100644 --- a/ui-react/src/components/single-room/Display.js +++ b/ui-react/src/components/single-room/Display.js @@ -78,6 +78,14 @@ class Display extends Component { } })); } + else { + this.setState(prevState => ({ + roomDetails: { + ...prevState.roomDetails, + nextUp: '' + } + })); + } } } From 5c55c206104e977f25f9de730802abfbf4718044 Mon Sep 17 00:00:00 2001 From: r1bb3t Date: Thu, 26 Jul 2018 13:21:17 -0700 Subject: [PATCH 2/2] added lifecycle method to fix next up bug in flightboard --- ui-react/src/components/flightboard/FlightboardRow.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui-react/src/components/flightboard/FlightboardRow.js b/ui-react/src/components/flightboard/FlightboardRow.js index 21cc8d1..7082382 100644 --- a/ui-react/src/components/flightboard/FlightboardRow.js +++ b/ui-react/src/components/flightboard/FlightboardRow.js @@ -23,7 +23,7 @@ class FlightboardRow extends Component { this.setState({ timesPresent: true }); - + if (room.Busy) { this.setState({ nextUp: '' @@ -38,6 +38,10 @@ class FlightboardRow extends Component { } } + componentDidUpdate = () => { + this.getAppointmentTime(); + } + componentDidMount = () => { this.getAppointmentTime(); }