Update URL param handling for new site

This commit is contained in:
Andrew Miner
2015-01-10 09:40:50 -08:00
parent f01d367024
commit fa29b77746
5 changed files with 30 additions and 22 deletions
+16
View File
@@ -16,6 +16,22 @@ module.exports = class ItemPage extends BaseModel
constructor: (attributes={}, options={})->
attributes.modPack ?= new ModPack
attributes.params ?= null
attributes.plan ?= new CraftingPlan modPack:attributes.modPack
attributes.table ?= new CraftingTable plan:attributes.plan
super attributes, options
@modPack.on 'change', => @_consumeParams()
# Private Methods ##############################################################################
_consumeParams: ->
return unless @params?.name?
item = @modPack.findItemByName @params.name, includeDisabled:true
return unless item? and item.isCraftable
quantity = if @params.quantity? then parseInt(@params.quantity) else 1
@plan.want.add item.slug, quantity
@params = null