Fix bug with selecting an item from inventory list
When selecting an item, it would formerly just update the text of the name field without adding the item. The fix is to make it add the item automatically.
This commit is contained in:
@@ -54,6 +54,15 @@ module.exports = class InventoryController extends BaseController
|
|||||||
onClearButtonClicked: ->
|
onClearButtonClicked: ->
|
||||||
@model.clear()
|
@model.clear()
|
||||||
|
|
||||||
|
onItemSelected: ->
|
||||||
|
func = =>
|
||||||
|
@onNameFieldChanged()
|
||||||
|
@onAddButtonClicked()
|
||||||
|
@$nameField.autocomplete 'search'
|
||||||
|
|
||||||
|
setTimeout func, 10 # needed to allow the autocomplete to finish
|
||||||
|
return true
|
||||||
|
|
||||||
onNameFieldBlur: ->
|
onNameFieldBlur: ->
|
||||||
item = @modPack.findItemByName @$nameField.val()
|
item = @modPack.findItemByName @$nameField.val()
|
||||||
@$nameField.val if item? then item.name else ''
|
@$nameField.val if item? then item.name else ''
|
||||||
@@ -151,6 +160,7 @@ module.exports = class InventoryController extends BaseController
|
|||||||
|
|
||||||
_updateNameAutocomplete: ->
|
_updateNameAutocomplete: ->
|
||||||
onChanged = => @onNameFieldChanged()
|
onChanged = => @onNameFieldChanged()
|
||||||
|
onSelected = => @onItemSelected()
|
||||||
|
|
||||||
@$nameField.autocomplete
|
@$nameField.autocomplete
|
||||||
source: @modPack.gatherRecipeNames()
|
source: @modPack.gatherRecipeNames()
|
||||||
@@ -158,7 +168,7 @@ module.exports = class InventoryController extends BaseController
|
|||||||
minLength: 0
|
minLength: 0
|
||||||
change: onChanged
|
change: onChanged
|
||||||
close: onChanged
|
close: onChanged
|
||||||
select: onChanged
|
select: onSelected
|
||||||
|
|
||||||
_updateButtonState: ->
|
_updateButtonState: ->
|
||||||
if @model.isEmpty then @$clearButton.attr('disabled', 'disabled') else @$clearButton.removeAttr('disabled')
|
if @model.isEmpty then @$clearButton.attr('disabled', 'disabled') else @$clearButton.removeAttr('disabled')
|
||||||
|
|||||||
Reference in New Issue
Block a user