Fix bug where deep links don't compute
This commit is contained in:
@@ -12,6 +12,7 @@ append styles
|
|||||||
style #mocha-stats { position: absolute; top: 9em; }
|
style #mocha-stats { position: absolute; top: 9em; }
|
||||||
|
|
||||||
block content
|
block content
|
||||||
|
|
||||||
#mocha
|
#mocha
|
||||||
|
|
||||||
append scripts
|
append scripts
|
||||||
|
|||||||
@@ -23,12 +23,13 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
|
|
||||||
@_parser = new InventoryParser
|
@_parser = new InventoryParser
|
||||||
|
|
||||||
@model.catalog.on Event.change, => @onCatalogChanged()
|
@model.modPack.on Event.change, => @onModPackChanged()
|
||||||
|
|
||||||
# Event Methods ################################################################################
|
# Event Methods ################################################################################
|
||||||
|
|
||||||
onCatalogChanged: ->
|
onModPackChanged: ->
|
||||||
return unless @rendered
|
return unless @rendered
|
||||||
|
@model.modPack.enableBooksForRecipe @$nameField.val()
|
||||||
@_updateNameAutocomplete()
|
@_updateNameAutocomplete()
|
||||||
@_craft()
|
@_craft()
|
||||||
|
|
||||||
@@ -49,8 +50,11 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
@model.name = @$nameField.val()
|
@model.name = @$nameField.val()
|
||||||
@_craft()
|
@_craft()
|
||||||
|
|
||||||
|
# @$nameField.blur()
|
||||||
|
|
||||||
onNameFieldFocused: ->
|
onNameFieldFocused: ->
|
||||||
return unless @rendered
|
return unless @rendered
|
||||||
|
@$nameField.val ""
|
||||||
@$nameField.autocomplete 'search'
|
@$nameField.autocomplete 'search'
|
||||||
|
|
||||||
onNameFieldKeyPress: (event)->
|
onNameFieldKeyPress: (event)->
|
||||||
@@ -114,7 +118,7 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
# Private Methods ##############################################################################
|
# Private Methods ##############################################################################
|
||||||
|
|
||||||
_craft: ->
|
_craft: ->
|
||||||
if @model.catalog.hasRecipe @model.name
|
if @model.modPack.hasRecipe @model.name
|
||||||
router.navigate "/item/#{encodeURIComponent(@model.name)}"
|
router.navigate "/item/#{encodeURIComponent(@model.name)}"
|
||||||
else
|
else
|
||||||
router.navigate "/item"
|
router.navigate "/item"
|
||||||
@@ -126,7 +130,7 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
onChanged = => @onNameFieldChanged()
|
onChanged = => @onNameFieldChanged()
|
||||||
|
|
||||||
@$nameField.autocomplete
|
@$nameField.autocomplete
|
||||||
source: @model.catalog.gatherNames()
|
source: @model.modPack.gatherNames()
|
||||||
delay: 0
|
delay: 0
|
||||||
minLength: 0
|
minLength: 0
|
||||||
change: onChanged
|
change: onChanged
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
# BaseController Overrides #####################################################################
|
# BaseController Overrides #####################################################################
|
||||||
|
|
||||||
onDidRender: ->
|
onDidRender: ->
|
||||||
@catalogController = @addChild ModPackController, '.view__mod_pack', model:@model.catalog
|
@modPackController = @addChild ModPackController, '.view__mod_pack', model:@model.modPack
|
||||||
@tableController = @addChild CraftingTableController, '.view__crafting_table', model:@model.table
|
@tableController = @addChild CraftingTableController, '.view__crafting_table', model:@model.table
|
||||||
super
|
super
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ Inventory = require './inventory'
|
|||||||
|
|
||||||
module.exports = class CraftingPlan
|
module.exports = class CraftingPlan
|
||||||
|
|
||||||
constructor: (@catalog, includingTools)->
|
constructor: (@modPack, includingTools)->
|
||||||
if not @catalog then throw new Error 'catalog is required'
|
if not @modPack then throw new Error 'modPack is required'
|
||||||
@includingTools = if includingTools then true else false
|
@includingTools = if includingTools then true else false
|
||||||
@clear()
|
@clear()
|
||||||
|
|
||||||
@@ -51,9 +51,9 @@ module.exports = class CraftingPlan
|
|||||||
return unless targetItem?
|
return unless targetItem?
|
||||||
logger.debug "Processing targetItem: #{targetItem}"
|
logger.debug "Processing targetItem: #{targetItem}"
|
||||||
|
|
||||||
return if @catalog.isRawMaterial targetItem.name
|
return if @modPack.isRawMaterial targetItem.name
|
||||||
|
|
||||||
recipes = @catalog.gatherRecipes targetItem.name
|
recipes = @modPack.gatherRecipes targetItem.name
|
||||||
return if not recipes.length > 0
|
return if not recipes.length > 0
|
||||||
|
|
||||||
recipe = recipes[0]
|
recipe = recipes[0]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Inventory = require './inventory'
|
|||||||
module.exports = class CraftingTable extends BaseModel
|
module.exports = class CraftingTable extends BaseModel
|
||||||
|
|
||||||
constructor: (attributes={}, options={})->
|
constructor: (attributes={}, options={})->
|
||||||
if not attributes.catalog? then throw new Error "attributes.catalog is required"
|
if not attributes.modPack? then throw new Error "attributes.modPack is required"
|
||||||
attributes.name ?= null
|
attributes.name ?= null
|
||||||
attributes.quantity ?= 1
|
attributes.quantity ?= 1
|
||||||
attributes.includingTools ?= false
|
attributes.includingTools ?= false
|
||||||
@@ -26,16 +26,16 @@ module.exports = class CraftingTable extends BaseModel
|
|||||||
# Public Methods ###############################################################################
|
# Public Methods ###############################################################################
|
||||||
|
|
||||||
craft: ->
|
craft: ->
|
||||||
if not @catalog.hasRecipe @name
|
if not @modPack.hasRecipe @name
|
||||||
@plan = null
|
@plan = null
|
||||||
return
|
return
|
||||||
|
|
||||||
toolPhrase = if @includingTools then ' includingTools' else ''
|
toolPhrase = if @includingTools then ' includingTools' else ''
|
||||||
logger.verbose "calculating build plan for #{@quantity} #{@name}#{toolPhrase} with inventory: #{@have}"
|
logger.verbose "calculating build plan for #{@quantity} #{@name}#{toolPhrase} with inventory: #{@have}"
|
||||||
|
|
||||||
@catalog.enableBooksForRecipe @name
|
@modPack.enableBooksForRecipe @name
|
||||||
|
|
||||||
plan = new CraftingPlan @catalog, @includingTools
|
plan = new CraftingPlan @modPack, @includingTools
|
||||||
plan.includingTools = @includingTools
|
plan.includingTools = @includingTools
|
||||||
plan.craft @name, @quantity, @have
|
plan.craft @name, @quantity, @have
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ ModPack = require './mod_pack'
|
|||||||
module.exports = class ItemPage extends BaseModel
|
module.exports = class ItemPage extends BaseModel
|
||||||
|
|
||||||
constructor: (attributes={}, options={})->
|
constructor: (attributes={}, options={})->
|
||||||
attributes.catalog ?= new ModPack
|
attributes.modPack ?= new ModPack
|
||||||
attributes.table ?= new CraftingTable catalog:attributes.catalog
|
attributes.table ?= new CraftingTable modPack:attributes.modPack
|
||||||
super attributes, options
|
super attributes, options
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
//-
|
|
||||||
//- Crafting Guide - test.jade
|
|
||||||
//-
|
|
||||||
//- Copyright (c) 2014 by Redwood Labs
|
|
||||||
//- All rights reserved.
|
|
||||||
//-
|
|
||||||
|
|
||||||
p Hello world!
|
|
||||||
Reference in New Issue
Block a user