Fix bug with recipe books table

This commit is contained in:
Andrew Miner
2014-12-29 09:07:39 -08:00
parent 372a1e0063
commit 004320d052
9 changed files with 61 additions and 23 deletions
@@ -108,7 +108,7 @@ module.exports = class CraftingTableController extends BaseController
# Private Methods ##############################################################################
_craft: ->
if @model.catalog.findRecipes(@model.name).length > 0
if @model.catalog.hasRecipe @model.name
router.navigate "/item/#{encodeURIComponent(@model.name)}"
@model.craft()
else
@@ -118,7 +118,7 @@ module.exports = class CraftingTableController extends BaseController
onChanged = => @onNameFieldChanged()
@$nameField.autocomplete
source: @model.catalog.getRecipeNames()
source: @model.catalog.gatherNames()
delay: 0
minLength: 0
change: onChanged
@@ -16,13 +16,27 @@ module.exports = class RecipeBookController extends BaseController
options.templateName = 'recipe_book'
super options
# Event Methods ################################################################################
onEnabledChanged: ->
return unless @rendered
@model.enabled = @$(':checked').length > 0
# BaseController Overrides #####################################################################
onDidRender: ->
@$name = @$('td:nth-child(1) p')
@$description = @$('td:nth-child(2) p')
@$enabled = @$('td:nth-child(1) input')
@$name = @$('td:nth-child(2) p')
@$description = @$('td:nth-child(3) p')
super
refresh: ->
if @model.enabled then @$enabled.attr('checked', 'checked') else @$enabled.removeAttr('checked')
@$name.html "#{@model.modName} (#{@model.modVersion})"
@$description.html "#{@model.description}"
# Backbone.View Overrides ######################################################################
events:
'change input[type="checkbox"]': 'onEnabledChanged'