Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Add calendar view / export with reservation information #1360

Closed
8 tasks done
orenyk opened this issue Nov 18, 2015 · 20 comments
Closed
8 tasks done

Add calendar view / export with reservation information #1360

orenyk opened this issue Nov 18, 2015 · 20 comments

Comments

@orenyk
Copy link
Contributor

orenyk commented Nov 18, 2015

We've received the following feature request:

I have a question- Is it possible to see a monthly calendar view for the with a graphic representation of who has what out, and for which days? I’m thinking of the view that the Google Calendar has (screen attached). I’m hoping so, as it would make visualizing who has what (and when it is due) at a glance and easy to sort out.

This actually sounds like a great idea, although it might be a bit tricky to implement since we'd likely want to limit the equipment displayed in a given calendar. Also, keeping #1061 in mind, we probably don't want to write our own calendar display software as much as provide a calendar export API that can be accessed using current online standards (e.g. iCalendar format) for any one of our equipment hierarchies and then embed something like a Google Calendar view of that calendar on the various pages. I'd like this to be done in the next sprint and will try to take it on myself.

2015-12-10

While working on this I had an awesome idea - we should also offer time-based calendar views for operations purposes. An example could be either a week-long or month-long calendar with all of the reservations upcoming for that week - it might be a nice way to get a higher level view for inventory prep purposes, for example. Just a thought, and it should be fairly straightforward to implement if I write nice DRY code 😄.

2016-01-04

Checklist:

  • Implement controller concern to enable calendar views / export
    • Write tests!! (TDD if possible)
    • Implement HTML view of calendar
    • Implement iCal export of calendar for Google calendar
  • Implement hover with equipment item info if present
  • Implement color-coding by status or equipment item
  • Fix monkey-patches

Things to keep in mind:

  1. Make sure this can apply to nested resources
@orenyk orenyk self-assigned this Nov 18, 2015
@orenyk orenyk added this to the 5.6.0 milestone Nov 18, 2015
@caseywatts
Copy link
Collaborator

++iCal export sounds like a great way to get this feature
We can sidestep view concerns by just exposing the data that way :D

@orenyk
Copy link
Contributor Author

orenyk commented Nov 18, 2015

This should be useful.

@orenyk
Copy link
Contributor Author

orenyk commented Dec 10, 2015

working on this based on the branch from #1329 to use the dependency updates there

EDIT This technically makes this blocked on #1367

@orenyk
Copy link
Contributor Author

orenyk commented Dec 10, 2015

Ok, so I've been reading the Testing Rails book by Thoughtbot (thanks @jeminlee) and so I'm going to try and apply some of the patterns / lessons I've picked up in this feature. I'm also going to try to implement 100% TDD as a learning exercise. I've started setting up feature specs - I'm going to write a bunch of pending cases as a framework and then flesh them out one at a time. We're also going to want request specs for the API route, potentially view specs for the calendar partial, controller specs for the new calendar actions, and probably unit tests for the various models / PORO's that are written to support the iCal format. More to come!

@orenyk
Copy link
Contributor Author

orenyk commented Dec 11, 2015

Ok, got my first test done and am working with routing and controller concerns to reduce code duplication. I also spent a while looking into generating calendar views and it appears as though our best bet is the fullcalendar-rails gem, which is just a repackaging of the FullCalendar jQuery plugin for Rails. Technically it permits drag/drop of events in the calendar but I'm assuming we can disable that since it makes no sense in our use case. At the moment I'm thinking of looking at reservations +/- 6 months from the current day just to limit it somewhat, but I'd welcome feedback as to whether or not that makes sense.

Note that the passing of the current test does not, in any way, mean that the view has been properly set up - I was just spoofing the existence of a "calendar item" through a list, but we'll definitely have to figure out a proper layout with the appropriate UX elements (link back to the equipment, link to download iCal file, link to import to Google Calendar?, etc). We'll also have to figure out where to link to this view and how to authorize it (at the moment I'm thinking just admins and above, but this is also definitely up for discussion).

I just thought of something awesome - we could totally generate time-based calendar views as well, e.g. reservations for today, reservations for the next week, etc, that could be used for inventory prep or general operations purposes and would link directly to the relevant reservations, almost like a dashboard. I think we can make this work pretty easily, especially if most of code is modular - all that changes is which reservations we're displaying in the calendar. I'll add it to the main issue description.

Finally, I removed the blocked tag since I'm not currently blocked from working on it, but this will be blocked if #1367 isn't merged in by the time it goes into review.

@orenyk
Copy link
Contributor Author

orenyk commented Dec 11, 2015

Btw, note the following article about testing Controller Concerns.

@orenyk
Copy link
Contributor Author

orenyk commented Dec 18, 2015

Here's a great article on how to integrate FullCalendar into a Rails app.

@orenyk
Copy link
Contributor Author

orenyk commented Jan 5, 2016

Let's see if we can make some progress here :-)

@orenyk
Copy link
Contributor Author

orenyk commented Jan 5, 2016

Definitely getting somewhere (I've got FullCalendar up and running and it's pulling events from a JSON response to the calendar route, woo hoo!). Unfortunately, feature testing is going to be difficult since FullCalendar is all JS-based, and we currently don't have capybara-webkit set up. Looking into that now.

@orenyk
Copy link
Contributor Author

orenyk commented Jan 5, 2016

Set up JS testing (it's pretty straightforward), but ran into a funny testing bug. I was originally creating 2-day reservations (due date one day after start date) for testing, but since those can overlap a weekend they sometimes result in two cells for a single reservation (so testing for one cell per reservation can fail). That was fun to debug 😄.

Overall, the concern is really nice and modular, it should be trivial to add a /calendar and /calendar.json route to any resource as long as we define the required private methods. I also just confirmed that by default the calendar routes are restricted to admins and superusers based on our default ability.rb. I still have to expand the test suite to include controller specs and feature specs for all relevant resources. I also have to implement the iCal routes so we can potentially import to Google Calendar / other apps. I'm going to get back to #1378 and will return to this afterwards.

@orenyk
Copy link
Contributor Author

orenyk commented Jan 5, 2016

Whoops, the reserved_in_date_range scope I've been using only returns reserved reservations, but not those in the past or checked out. I believe I made a general-purpose date overlap scope in #1266, but we'll have to wait until that's merged into master and we rebase to use them.

@orenyk
Copy link
Contributor Author

orenyk commented Jan 5, 2016

I was going to implement color-coding events by equipment item but in the end I'm not sure how to generate a sufficiently large palette (although assigning colors to items as we iterate through the reservations with a hash would have been pretty cool), so I think we'll just go by status.

@orenyk
Copy link
Contributor Author

orenyk commented Jan 5, 2016

In case anyone was interested to see how it looks so far:

selection_072

@orenyk
Copy link
Contributor Author

orenyk commented Jan 10, 2016

Trying to do some testing; unfortunately since our concern requires some private methods to be defined we can't test it in an empty controller as advocated in the link above. Instead, I'm going to put together a shared example instead and we'll pull it into each of the controller spec files.

@orenyk
Copy link
Contributor Author

orenyk commented Jan 10, 2016

Started putting this together; it's a bit complicated and I'm trying to figure out how to write code that will work for all the various controllers. Done for tonight!

@orenyk
Copy link
Contributor Author

orenyk commented Jan 19, 2016

Ok, shared example for all controllers is working with a single spec (for now) and kinda nice, if I may say so myself. I rebased onto master to take advantage of the updated scopes from #1288 but it turns out I didn't write a generalized overlap scope (we just have the reserved_in_date_range. I might refactor that into an overlap scope and just add reserved to the end wherever it's currently being used, but we'll see. Back to this later!

@orenyk
Copy link
Contributor Author

orenyk commented Feb 11, 2016

Might have broken rubocop... not sure what's going on but will investigate.

@orenyk
Copy link
Contributor Author

orenyk commented Feb 11, 2016

Ok, when rebasing I (wrongly) deleted Gemfile.lock to resolve the merge conflict instead of checking out the copy from master and re-running bundle install to add the new gems. This updated a whole bunch of dependencies, apparently breaking rubocop. This has now been fixed 😄.

@orenyk
Copy link
Contributor Author

orenyk commented Feb 12, 2016

We've got an optional hover / tooltip (thanks Bootstrap) when a reservation is checked out and I've expanded the controller tests to handle both the JSON and HTML cases. I guess it's time for iCal!

@orenyk
Copy link
Contributor Author

orenyk commented Feb 12, 2016

iCal is working! Tried moving it to a separate class but that broke things (I think since we were trying to hijack the constructor). Just going to change save calendar start and due dates in the session (like the reports) and that should do it!

orenyk added a commit that referenced this issue Feb 12, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, and equipment
  items
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Feb 12, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, and equipment
  items
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Feb 12, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, and equipment
  items
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Feb 14, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, and equipment
  items
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Feb 14, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, and equipment
  items
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Feb 15, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, equipment items,
  and users
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Feb 16, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, equipment items,
  and users
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Feb 23, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, equipment items,
  and users
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Mar 1, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, equipment items,
  and users
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Mar 6, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, equipment items,
  and users
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Mar 8, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, equipment items,
  and users
- Fix routing issue with jQuery-UI-Bootstrap assets
orenyk added a commit that referenced this issue Mar 8, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, equipment items,
  and users
- Fix routing issue with jQuery-UI-Bootstrap assets
zeffman pushed a commit that referenced this issue Sep 18, 2016
Resolves #1360
- Add Calendarable controller concern to generate HTML, JSON, and
  iCalendar representations of all the reservations for a given
  resource
- Add calendarable routing concern and clean up config/routes.rb
- Add Reservation#end_date to find the last day for a reservation,
  status-dependent (with model specs)
- Add the associated controller specs as a shared example as well
  as feature specs for equipment models
- Add calendars for categories, equipment models, equipment items,
  and users
- Fix routing issue with jQuery-UI-Bootstrap assets

Add updated schema for Rails 4.2

Resolves #1517
- schema now has field limits, see issue for details

Clarify availability error messages

Closes #1242
   - change app/models/cart_validations.rb to tell
     maximum number of available items, pluralizing properly

Fix UI issues

Closes #1492
  - Change big-numbers mixin so font does not overflow table
  - Adjust equipment_model show table columns to align better
  - Add table_woo to CSS formatting to center rows vertically

Resolve issues with contact form

Resolves #1524
- add AppConfig.contact_email to correctly default to admin e-mail when
  no contact e-mail is set
- add validations for AppConfig.contact_link_location to ensure it is a
  valid e-mail if it's not blank
- update seed and application setup script to assign valid e-mails to
  contact_link_location by default, as well as update factories
- add specs

Add optional archival deactivation of equipment

Resolves #1384
- add autodeactivate_on_archive parameter to AppConfig
- move equipment item deactivation to a model method
- tweak ReservationsController#archive method to implement
  auto-deactivation
- add feature specs for reservation archiving
- add model specs for EquipmentItem#deactivate
- add controller specs for ReservationsController#archive with
  auto-deactivation
- FeatureHelpers#app_setup now deletes any pre-existing AppConfigs

Prevents duplicate items in search results

Resolves #933
- Flattens search results array before applying uniq
- Wrote test to check for duplicate results

Fix / replace availability calendar

Resolves #1498
- add FullCalendar-based availability calendar
- move availability calculations to private controller method
- add controller specs for availability
- remove legacy calendar code

Fix whenever / Capistrano integration

Resolves #1373
- use built-in whenever tasks

Fix view alignment of dates in reservation show

closes #1532
- minor edit in reservations show.html to remove wrapper around h4 headings
- p tag used to cause alignment problem

Remove Rails dependency from whenever.rb

Resolves #1542
- whoops

Fix rubocop error

Introduced in #1542, whoops again!

Request text is now shown after invalid cart edit

Resolves #1544
- moves request text assignment code to ReservationsHelper
- manually include ReservationsHelper in CatalogController

Update CHANGELOG for v6.0.0

Resolves #1362
- include changes in the v5.5.x releases

Update Travis status image in README

This was previously reflecting the status of the build from the most recently
pushed commit / PR, which is often red. To accurately reflect the health of the
project the status image will now only refer to builds from `master`.

Change default Heroku e-mail addon to Sendgrid

Resolves #1515
- update `devise_cas_authenticatable` to v1.7.1 to resolve logger issue

Clean up #1337
Resolves #1499
  - Include CsvExport in all relevant controllers
  - Add single category export

Overhaul availability

Resolves #1501
  - Availability methods all work as expected
  - Adds counter cache on equipment models for current overdue reservations
  - Reservation factory trait :past allows for creation of past
    reservations without skipping validations
  - New reservation model methods for counting reservations, attribute
    checking, and checking for overlapping

Seed script no longer generates reservations with impossible dates

Resolves #1229 and #1263
 - Seed script uses TimeHelpers to save reservations in the past,
   allowing validations to be run on them

Fix ElementNotFound feature test intermittent failure

Resolves #1514
  - Only create a second equipment model and item when necessary in
    feature specs
  - Replace nearly all AppConfig creations in tests with a mocked
    AppConfig
  - Get rid of most before(:all) callbacks
  - Minor refactor of a reservations controller spec

Update dependencies (May 2016)

Resolves #1553
- Highlights:
  - Update Ruby to 2.2.5
  - Update Devise to v4.1
  - Update Capybara to v2.7
- Email validators are now more permissive due to Devise update
- Capybara matchers no longer return hidden inputs by default
- Several new rubocop cops were implemented and dealt with

Update CHANGELOG for v6.1.0

Resolves #1548

Fix intermittent asset failure in specs

Resolves #1528
  - Mock relative root in application helper specs

Configure Hound CI

Resolves #1577

Add option for requests to block equipment availability

Resolves #1521

Refactor EquipmentModel Model spec

Resolves #1600

Add ESlint to Travis; only style check the diff

Resolves #1581
  - Adds 'rake check_style'
  - Fixes rubocop's TargetRubyVersion
  - Removes HoundCI config

Refactor EquipmentModels controller spec

Resolves #1587
 - Adds Mocker classes
 - Adds shared controller examples for successful and failed requests

Refactor periodic rake tasks to ActiveJobs

Resolves #1275
  - Add buttons to manually run periodic tasks
  - Moves all periodic tasks from rake to ActiveJob
  - Heavy refactoring of former rake tasks and their specs

Update ruby version in readme

Updated ruby version in readme (literally changed one character)

Refactor Reservation Model spec

Resolves #1554

Refactor EquipmentItems Controller spec

Resolves #1588

Refactor Reservations Controller Spec

Resolves #1586
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants