diff options
| author | mo <mo.khan@gmail.com> | 2017-10-07 15:33:33 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2017-10-07 15:33:33 -0600 |
| commit | 0a40d930732ee933c9bd6acd5aca21cae8e26717 (patch) | |
| tree | 3814f9d7b6c245e064161c4a901e5ed9a22e31a2 /app/assets | |
| parent | 6e36c75f480be84dc904a2e37dffb3642cc95356 (diff) | |
Diffstat (limited to 'app/assets')
4 files changed, 12 insertions, 32 deletions
diff --git a/app/assets/javascripts/cakeside.js.coffee b/app/assets/javascripts/cakeside.js.coffee index c4066663..dfaa97f2 100644 --- a/app/assets/javascripts/cakeside.js.coffee +++ b/app/assets/javascripts/cakeside.js.coffee @@ -21,36 +21,13 @@ window.csx = xhr.setRequestHeader "Authorization", "Token token=#{data.access_token}" csx.Application = new Marionette.Application() - csx.Application.addRegions - content_region: '#backbone-content' - + csx.Application.addRegions(content_region: '#backbone-content') csx.Application.addInitializer (options) -> - new csx.Routers.CakesRouter - controller: new csx.Controllers.My.CakesController() - new csx.Routers.TutorialsRouter - controller: new csx.Controllers.My.TutorialsController() - new csx.Routers.DashboardRouter - controller: new csx.Controllers.My.DashboardController() - new csx.Routers.ProfileRouter - controller: new csx.Controllers.My.ProfileController() - + new csx.Routers.CakesRouter(controller: new csx.Controllers.My.CakesController()) + new csx.Routers.TutorialsRouter(controller: new csx.Controllers.My.TutorialsController()) + new csx.Routers.DashboardRouter(controller: new csx.Controllers.My.DashboardController()) + new csx.Routers.ProfileRouter(controller: new csx.Controllers.My.ProfileController()) csx.Application.on 'start', -> if Backbone.history Backbone.history.start() - - @cakes = new csx.Collections.CakesCollection() - - csx.Application.reqres.setHandler 'CakesRepository', => - @cakes - @photos_cache = {} - csx.Application.reqres.setHandler 'PhotosRepository', (cake_id) => - if @photos_cache[cake_id] - @photos_cache[cake_id] - else - photos = new csx.Collections.PhotosCollection(cake_id: cake_id) - @photos_cache[cake_id] = photos - photos.fetch(reset: true) - photos - - @cakes.fetch(reset: true).done -> - csx.Application.start() + csx.Application.start() diff --git a/app/assets/javascripts/controllers/my/cakes_controller.js.coffee b/app/assets/javascripts/controllers/my/cakes_controller.js.coffee index 9e8ec495..009fe596 100644 --- a/app/assets/javascripts/controllers/my/cakes_controller.js.coffee +++ b/app/assets/javascripts/controllers/my/cakes_controller.js.coffee @@ -2,7 +2,7 @@ class csx.Controllers.My.CakesController extends Marionette.Controller views: csx.Views.My.Cakes initialize: (options) -> @content_region = csx.Application.content_region - @cakes = csx.Application.request('CakesRepository') + @cakes = csx.Collections.Creation index: -> @selectTab() diff --git a/app/assets/javascripts/models/cake.js.coffee b/app/assets/javascripts/models/cake.js.coffee index 7df33ee2..7712ac7b 100644 --- a/app/assets/javascripts/models/cake.js.coffee +++ b/app/assets/javascripts/models/cake.js.coffee @@ -14,7 +14,8 @@ class csx.Models.Cake extends Backbone.Model return "Category can't be blank" unless attributes.category_id photos: -> - csx.Application.request('PhotosRepository', @id) + cake_id = @id + new Backbone.Collection(csx.Collections.Photo.filter((photo) => photo.get("cake_id") == cake_id)) public_url: -> "#{window.location.origin}/creations/#{@get('slug')}" @@ -25,3 +26,5 @@ class csx.Models.Cake extends Backbone.Model class csx.Collections.CakesCollection extends Backbone.Collection model: csx.Models.Cake url: '/api/v1/cakes' + +csx.Models.Creation = csx.Models.Cake diff --git a/app/assets/javascripts/views/my/photos/new_modal_view.js.coffee b/app/assets/javascripts/views/my/photos/new_modal_view.js.coffee index 1218b2e9..5a016b89 100644 --- a/app/assets/javascripts/views/my/photos/new_modal_view.js.coffee +++ b/app/assets/javascripts/views/my/photos/new_modal_view.js.coffee @@ -11,7 +11,7 @@ class csx.Views.My.Photos.NewModalView extends Marionette.ItemView constructor: (options) -> super(options) - @collection = csx.Application.request('PhotosRepository', options.cake.id) + @collection = csx.Collections.Photo @cake = options.cake @model = new @collection.model(cake_id: @cake.id) |
