Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Multiday events #197

Merged
merged 32 commits into from
Jul 25, 2016
Merged

Multiday events #197

merged 32 commits into from
Jul 25, 2016

Conversation

asavin
Copy link
Contributor

@asavin asavin commented Jul 13, 2016

giphy 10

Motivation

Currently it is only possible to specify datetime of the event. With this change we are introducing ability to specify start datetime and end datetime. Events spanning multiple days will have those days displayed in the UI (under Today list).

designing_in_cross-functional_teams___red_badger

  • Event stays in “Upcoming” list, using the first day of event for order.
  • When the first day of event is today, move to “Today” list. Still showing the same date range
  • When the last day of event is gone, move to “past” list. Use the last day of event for order.
  • Tests
  • Gif added

@asavin asavin added the WIP label Jul 13, 2016
@@ -1,4 +1,5 @@
// Displays date bubble
/* eslint-disable max-len */
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to fix the error than to disable the rule.

Also this component looks like a better fit for a function rather than a class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think you can fix line length with multiline strings, can you?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can wrap a string over multiple lines with either + or \.

Also this is an expression which is easier to wrap. I think it should be built by a function rather than inline like this. Really hard to read between the template strings, use of this.props, and the ternary operator.

Copy link
Contributor

@lpil lpil Jul 14, 2016

Choose a reason for hiding this comment

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

if (displayDateRange) {
  return `${startDate} ${startMonth} ${startYear} - ${endDate} ${endMonth} ${endYear}`
} else {
  return `${startDate} ${startMonth} ${startYear}`;
}

I think this is much clearer and breaks no linting rules

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Choose a reason for hiding this comment

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

You could go one further and use this.props.ISODate or whatever the field is called, along with format and use the in-built tokens


DateBubble.propTypes = {
startDateTime: PropTypes.shape(dateShape),
endDateTime: PropTypes.shape(dateShape),
Copy link
Contributor

Choose a reason for hiding this comment

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

These look required to me?

@@ -77,7 +84,7 @@ export default class EventsController {
.then((response) => response.json())
.then((events) => {
res.send({ list: events.data.allEvents.sort((a, b) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we could use our pathOr(['...]), that we have used in badger brain to access these nested object keys. Just thinking of a scenario where someone changes the query and doesn't actually query for the startDateTime but yet we try access the .iso key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's a bit of premature optimization - this is a client and it knows what it just requested

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh you mean in case startDateTime is null? Maybe.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. Basically whenever I see a.b.c.d.e these days I want to use pathOr

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally should be built in :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm putting this one on hold for now - at the moment if startDateTime is missing, the whole site will explode. We should handle this in a clever way, probably on BB level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be addressed as part of a separate PR.

startDateTime,
endDateTime,
}) => {
let displayDateContent = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be cleaner if we put this in its' own function

}) => (
<div>
{
event.externalLinks || event.internalLinks ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to do this inside the child component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah probably. There's also potential for refactoring in a way of only passing down elements of the event and not the whole event.

? <TagsList
tags={event.tags}
tagsLinkPath="about-us/events" />
: null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we need to update to React 15 in order to get that null returns working without warnings.

} else {
displayDateContent =
`${startDateTime.date} ${startDateTime.monthSym} ${startDateTime.year}`;
} else { // eslint-disable-line no-else-return
Copy link
Contributor

Choose a reason for hiding this comment

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

Obey the style guide instead of turning off the linter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What are my options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nvm, fixed

@AndrewBestbier
Copy link
Contributor

Looks good :)

@asavin
Copy link
Contributor Author

asavin commented Jul 25, 2016

@AndrewBestbier merge merge!

@AndrewBestbier AndrewBestbier merged commit 18bd6c9 into master Jul 25, 2016
@AndrewBestbier AndrewBestbier deleted the multiday-events branch July 25, 2016 14:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants