Ensure step helper buttons work

fixes #288
This commit is contained in:
Andrew Miner
2017-07-11 09:26:09 -07:00
parent b8a2dae9f2
commit 33479051c8
4 changed files with 2927 additions and 10 deletions
+2917
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -48,4 +48,3 @@
"when": "3.7.8"
}
}
@@ -166,21 +166,21 @@ module.exports = class CraftPageController extends PageController
controller.markComplete @model.have
_isAddingToolsPossible: (controller)->
tools = controller.model.recipe.tools
tools = (item for itemId, item of controller.model.recipe.tools)
return false unless tools.length > 0
have = @model.have
want = @model.want
for stack in tools
return false if @model.have.contains stack.item.id
return false if @model.want.contains stack.item.id
for item in tools
return false if @model.have.contains item
return false if @model.want.contains item
return true
_isStepCompletable: (controller)->
wantsOutput = @model.want.contains controller.model.recipe.output.item.id
return wantsOutput
userWantsItem = @model.want.contains controller.model.recipe.output.item
return not userWantsItem
_refreshOutdated: ->
if @model.isOutdated
@@ -43,11 +43,12 @@ module.exports = class StepController extends BaseController
# Event Methods ################################################################################
onCompleteButtonClicked: (event)->
return if @$completeButton.hasClass 'disabled'
return false if @$completeButton.hasClass 'disabled'
tracker.trackEvent c.tracking.category.craft, 'mark-complete', null, @model.count
@onComplete this
onShowToolPlan: (event)->
return false if @$toolButton.hasClass 'disabled'
tracker.trackEvent c.tracking.category.navigate, 'show-tool-plan', @$toolButton.attr 'target'
return true
@@ -97,13 +98,13 @@ module.exports = class StepController extends BaseController
events: ->
return _.extend super,
'click .button.complete': 'onCompleteButtonClicked'
'click a.button.tool': 'onShowToolPlan'
'click .button.tool': 'onShowToolPlan'
# Private Methods ##############################################################################
_refreshToolButton: ->
inventory = new Inventory
for itemId, item in @model.recipe.tools
for itemId, item of @model.recipe.tools
inventory.add item
inventoryText = inventory.toUrlString()