Aldaviva / floorplan

🗺️ Floorplan, seating chart, and employee directory for Blue Jeans.
167 stars 58 forks source link

Admin: adding a new user requires a second save and reload to get photo and ListPane working #3

Closed Aldaviva closed 11 years ago

Aldaviva commented 11 years ago

Steps to reproduce

  1. Fill out the form for a new person
  2. Select a photo
  3. Hit save

Expected result

Actual result

Aldaviva commented 11 years ago

Actual steps

  1. Hit save
  2. Model is persisted, row is added to ListPane, floorplan page shows new data correctly
  3. Photo begins uploading
  4. Photo finishes uploading
  5. ListPane row still has <img src="missing_photo.jpg"/> from before upload, so Editor.onPhotoUploadSuccess fails to update src
  6. Clicking row throws uncaught exception: TypeError: Cannot convert 'model.views.mapIcon' to object from Map.js:139: var activeEl = model.views.mapIcon.el;
Aldaviva commented 11 years ago

Proposed resolution

Aldaviva commented 11 years ago

Must upload model before photo because the photo upload depends on the model's server-generated ID.

New plan to fix missing photo being displayed

  1. Upload model first
  2. Upon successful photo upload, fire event on model: change:photo
  3. Views that render photos, such as ListPane:PersonRow and Map:PersonIcon are responsibly for listening for this event and rerendering with the correct image (may be tricky because of the max-age header we just added).