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" "when": "3.7.8"
} }
} }
@@ -166,21 +166,21 @@ module.exports = class CraftPageController extends PageController
controller.markComplete @model.have controller.markComplete @model.have
_isAddingToolsPossible: (controller)-> _isAddingToolsPossible: (controller)->
tools = controller.model.recipe.tools tools = (item for itemId, item of controller.model.recipe.tools)
return false unless tools.length > 0 return false unless tools.length > 0
have = @model.have have = @model.have
want = @model.want want = @model.want
for stack in tools for item in tools
return false if @model.have.contains stack.item.id return false if @model.have.contains item
return false if @model.want.contains stack.item.id return false if @model.want.contains item
return true return true
_isStepCompletable: (controller)-> _isStepCompletable: (controller)->
wantsOutput = @model.want.contains controller.model.recipe.output.item.id userWantsItem = @model.want.contains controller.model.recipe.output.item
return wantsOutput return not userWantsItem
_refreshOutdated: -> _refreshOutdated: ->
if @model.isOutdated if @model.isOutdated
@@ -43,11 +43,12 @@ module.exports = class StepController extends BaseController
# Event Methods ################################################################################ # Event Methods ################################################################################
onCompleteButtonClicked: (event)-> onCompleteButtonClicked: (event)->
return if @$completeButton.hasClass 'disabled' return false if @$completeButton.hasClass 'disabled'
tracker.trackEvent c.tracking.category.craft, 'mark-complete', null, @model.count tracker.trackEvent c.tracking.category.craft, 'mark-complete', null, @model.count
@onComplete this @onComplete this
onShowToolPlan: (event)-> onShowToolPlan: (event)->
return false if @$toolButton.hasClass 'disabled'
tracker.trackEvent c.tracking.category.navigate, 'show-tool-plan', @$toolButton.attr 'target' tracker.trackEvent c.tracking.category.navigate, 'show-tool-plan', @$toolButton.attr 'target'
return true return true
@@ -97,13 +98,13 @@ module.exports = class StepController extends BaseController
events: -> events: ->
return _.extend super, return _.extend super,
'click .button.complete': 'onCompleteButtonClicked' 'click .button.complete': 'onCompleteButtonClicked'
'click a.button.tool': 'onShowToolPlan' 'click .button.tool': 'onShowToolPlan'
# Private Methods ############################################################################## # Private Methods ##############################################################################
_refreshToolButton: -> _refreshToolButton: ->
inventory = new Inventory inventory = new Inventory
for itemId, item in @model.recipe.tools for itemId, item of @model.recipe.tools
inventory.add item inventory.add item
inventoryText = inventory.toUrlString() inventoryText = inventory.toUrlString()