Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. ###
  2. COLLECTIONS
  3. ###
  4.  
  5. @Comparisons = new Meteor.Collection 'comparisons'
  6. @Items = new Meteor.Collection 'items'
  7.  
  8. ###
  9. ROUTER:setup
  10. ###
  11.  
  12. Router.configure
  13. layoutTemplate: 'layout'
  14. loadingTemplate: 'loading'
  15. notfoundTemplate: 'notFound'
  16.  
  17. ###
  18. ROUTER:routing
  19. ###
  20.  
  21. Router.route '/',
  22. name: 'home'
  23. template: 'comparisonsList'
  24.  
  25. Router.route '/create/:_id',
  26. name: 'create'
  27. template: 'createComparison'
  28. data: ->
  29. currentItem = @params._id
  30. Items.findOne
  31. _id: currentItem
  32.  
  33.  
  34. if Meteor.isClient
  35.  
  36. Template.addComparison.events
  37. "click .addComparison": (e) ->
  38. id = Items.insert
  39. title: "Enter a title for this description"
  40. fields: [
  41. { name: "Enter a name for this attribute", weight: 1 }
  42. ]
  43. createdAt: new Date
  44. createdBy: Meteor.userId()
  45. console.log id
  46. Router.go 'create', _id: id
  47.  
  48.  
  49. Template.createComparison.helpers
  50. attributes: ->
  51. console.log this.fields
  52. currentItem = @_id
  53. currentUser = Meteor.userId()
  54. Items.findOne
  55. _id: currentItem
  56. createdBy: currentUser
  57.  
  58. debugThis: ->
  59. console.log this
  60.  
  61. Template.createComparison.events
  62. "click .addAttribute": (e) ->
  63. e.preventDefault()
  64. currentItem = @_id
  65. currentUser = Meteor.userId()
  66.  
  67. Items.update { _id: currentItem }, $push: fields: { name: "Enter a name for this attribute", weight: 1 }
  68.  
  69. "click .saveComparison": (e) ->
  70. e.preventDefault()
  71.  
  72. ###
  73. args = []
  74. title = $(e.currentTarget).find('#title')
  75.  
  76. $(e.currentTarget).find('.comparisonAttribute').each ->
  77. val = $(this).val()
  78. args.push val
  79.  
  80. ###
  81. "click .cancelComparison": (e) ->
  82. e.preventDefault()
  83. Router.go 'home'
  84.  
  85. "click .removeAttribute": (e) ->
  86. e.preventDefault()
  87. ###
  88. current = Session.get 'attributesArray'
  89. current.pop()
  90. Session.set 'attributesArray', current
  91. ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement