Add "Used as Tool to Make" section on item detail
This commit is contained in:
@@ -170,3 +170,5 @@ module.exports = (grunt)->
|
|||||||
grunt.registerTask 'build', [ 'copy', 'sass:main', 'jade', 'browserify', 'exorcise' ]
|
grunt.registerTask 'build', [ 'copy', 'sass:main', 'jade', 'browserify', 'exorcise' ]
|
||||||
|
|
||||||
grunt.registerTask 'dist', ['clean', 'build', 'sass:dist', 'rename:scripts', 'uglify']
|
grunt.registerTask 'dist', ['clean', 'build', 'sass:dist', 'rename:scripts', 'uglify']
|
||||||
|
|
||||||
|
grunt.registerTask 'full-watch', ['clean', 'build', 'watch']
|
||||||
|
|||||||
@@ -30,31 +30,37 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
|
|
||||||
super options
|
super options
|
||||||
|
|
||||||
@_imageLoader = options.imageLoader
|
@imageLoader = options.imageLoader
|
||||||
@_itemSlug = options.itemSlug
|
@_itemSlug = options.itemSlug
|
||||||
@_modPack = options.modPack
|
@modPack = options.modPack
|
||||||
|
|
||||||
@_modPack.on Event.change, => @tryRefresh()
|
@modPack.on Event.change, => @tryRefresh()
|
||||||
|
|
||||||
# BaseController Overrides #####################################################################
|
# BaseController Overrides #####################################################################
|
||||||
|
|
||||||
onDidRender: ->
|
onDidRender: ->
|
||||||
@_similarItemsController = @addChild ItemGroupController, '.similar .view__item_group',
|
@_usedAsToolToMakeController = @addChild ItemGroupController, '.usedAsToolToMake .view__item_group',
|
||||||
imageLoader: @_imageLoader
|
imageLoader: @imageLoader
|
||||||
modPack: @_modPack
|
modPack: @modPack
|
||||||
@_usedToMakeController = @addChild ItemGroupController, '.usedToMake .view__item_group',
|
|
||||||
imageLoader: @_imageLoader
|
|
||||||
modPack: @_modPack
|
|
||||||
|
|
||||||
@$byline = @$('.byline')
|
@_similarItemsController = @addChild ItemGroupController, '.similar .view__item_group',
|
||||||
@$bylineLink = @$('.byline a')
|
imageLoader: @imageLoader
|
||||||
@$craftingPlanLink = @$('a.craftingPlan')
|
modPack: @modPack
|
||||||
@$name = @$('h1.name')
|
|
||||||
@$recipeContainer = @$('.recipes .panel')
|
@_usedToMakeController = @addChild ItemGroupController, '.usedToMake .view__item_group',
|
||||||
@$recipesSection = @$('.recipes')
|
imageLoader: @imageLoader
|
||||||
@$similarSection = @$('.similar')
|
modPack: @modPack
|
||||||
@$titleImage = @$('.titleImage img')
|
|
||||||
@$usedToMakeSection = @$('.usedToMake')
|
@$usedAsToolToMakeSection = @$('.usedAsToolToMake')
|
||||||
|
@$byline = @$('.byline')
|
||||||
|
@$bylineLink = @$('.byline a')
|
||||||
|
@$craftingPlanLink = @$('a.craftingPlan')
|
||||||
|
@$name = @$('h1.name')
|
||||||
|
@$recipeContainer = @$('.recipes .panel')
|
||||||
|
@$recipesSection = @$('.recipes')
|
||||||
|
@$similarSection = @$('.similar')
|
||||||
|
@$titleImage = @$('.titleImage img')
|
||||||
|
@$usedToMakeSection = @$('.usedToMake')
|
||||||
super
|
super
|
||||||
|
|
||||||
refresh: ->
|
refresh: ->
|
||||||
@@ -62,10 +68,10 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
@_resolveItemSlug()
|
@_resolveItemSlug()
|
||||||
|
|
||||||
if @model.item?
|
if @model.item?
|
||||||
display = @_modPack.findItemDisplay @model.item.slug
|
display = @modPack.findItemDisplay @model.item.slug
|
||||||
@$craftingPlanLink.attr href:display.craftingUrl
|
@$craftingPlanLink.attr href:display.craftingUrl
|
||||||
@$craftingPlanLink.fadeIn duration:Duration.fast
|
@$craftingPlanLink.fadeIn duration:Duration.fast
|
||||||
@_imageLoader.load display.iconUrl, @$titleImage
|
@imageLoader.load display.iconUrl, @$titleImage
|
||||||
@$name.html display.itemName
|
@$name.html display.itemName
|
||||||
|
|
||||||
@$el.slideDown duration:Duration.normal
|
@$el.slideDown duration:Duration.normal
|
||||||
@@ -75,6 +81,7 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
@_refreshByline()
|
@_refreshByline()
|
||||||
@_refreshRecipes()
|
@_refreshRecipes()
|
||||||
@_refreshSimilarItems()
|
@_refreshSimilarItems()
|
||||||
|
@_refreshUsedAsToolToMake()
|
||||||
@_refreshUsedToMake()
|
@_refreshUsedToMake()
|
||||||
|
|
||||||
super
|
super
|
||||||
@@ -88,6 +95,15 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
|
|
||||||
# Private Methods ##############################################################################
|
# Private Methods ##############################################################################
|
||||||
|
|
||||||
|
_refreshUsedAsToolToMake: ->
|
||||||
|
@_usedAsToolToMakeController.title = 'Used as Tool to Make'
|
||||||
|
|
||||||
|
@_usedAsToolToMakeController.model = @model.findToolForRecipes()
|
||||||
|
if @_usedAsToolToMakeController.model?
|
||||||
|
@$usedAsToolToMakeSection.slideDown duration:Duration.normal
|
||||||
|
else
|
||||||
|
@$usedAsToolToMakeSection.slideUp duration:Duration.normal
|
||||||
|
|
||||||
_refreshByline: ->
|
_refreshByline: ->
|
||||||
mod = @model.item?.modVersion?.mod
|
mod = @model.item?.modVersion?.mod
|
||||||
if mod?.name?.length > 0
|
if mod?.name?.length > 0
|
||||||
@@ -117,7 +133,7 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
for recipe in @model.findRecipes()
|
for recipe in @model.findRecipes()
|
||||||
controller = @_recipeControllers[index]
|
controller = @_recipeControllers[index]
|
||||||
if not controller?
|
if not controller?
|
||||||
controller = new FullRecipeController imageLoader:@_imageLoader, modPack:@_modPack, model:recipe
|
controller = new FullRecipeController imageLoader:@imageLoader, modPack:@modPack, model:recipe
|
||||||
@_recipeControllers.push controller
|
@_recipeControllers.push controller
|
||||||
controller.render()
|
controller.render()
|
||||||
@$recipeContainer.append controller.$el
|
@$recipeContainer.append controller.$el
|
||||||
@@ -145,4 +161,4 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
@$similarSection.slideUp duration:Duration.normal
|
@$similarSection.slideUp duration:Duration.normal
|
||||||
|
|
||||||
_resolveItemSlug: ->
|
_resolveItemSlug: ->
|
||||||
@model.item = @_modPack.findItem @_itemSlug, includeDisabled:true
|
@model.item = @modPack.findItem @_itemSlug, includeDisabled:true
|
||||||
|
|||||||
@@ -21,19 +21,7 @@ module.exports = class ItemPage extends BaseModel
|
|||||||
# Property Methods #############################################################################
|
# Property Methods #############################################################################
|
||||||
|
|
||||||
findComponentInItems: ->
|
findComponentInItems: ->
|
||||||
return null unless @item?
|
return @_findRecipesMatching (recipe)=> recipe.requires @item.slug
|
||||||
|
|
||||||
result = {}
|
|
||||||
@modPack.eachMod (mod)=>
|
|
||||||
mod.eachRecipe (recipe)=>
|
|
||||||
if recipe.requires @item.slug
|
|
||||||
outputItem = @modPack.findItem recipe.itemSlug, includeDisabled:true
|
|
||||||
result[outputItem.slug] = outputItem
|
|
||||||
|
|
||||||
result = _.values result
|
|
||||||
return null unless result.length > 0
|
|
||||||
|
|
||||||
return result.sort (a, b)-> a.compareTo b
|
|
||||||
|
|
||||||
findSimilarItems: ->
|
findSimilarItems: ->
|
||||||
return null unless @item?.modVersion?
|
return null unless @item?.modVersion?
|
||||||
@@ -47,3 +35,23 @@ module.exports = class ItemPage extends BaseModel
|
|||||||
|
|
||||||
findRecipes: ->
|
findRecipes: ->
|
||||||
return @modPack.findRecipes @item?.slug, [], alwaysFromOwningMod:true
|
return @modPack.findRecipes @item?.slug, [], alwaysFromOwningMod:true
|
||||||
|
|
||||||
|
findToolForRecipes: ->
|
||||||
|
return @_findRecipesMatching (recipe)=> recipe.requiresTool @item.slug
|
||||||
|
|
||||||
|
# Private Methods ##############################################################################
|
||||||
|
|
||||||
|
_findRecipesMatching: (callback)->
|
||||||
|
return null unless @item?
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
@modPack.eachMod (mod)=>
|
||||||
|
mod.eachRecipe (recipe)=>
|
||||||
|
if callback(recipe)
|
||||||
|
outputItem = @modPack.findItem recipe.itemSlug, includeDisabled:true
|
||||||
|
result[outputItem.slug] = outputItem
|
||||||
|
|
||||||
|
result = _.values result
|
||||||
|
return null unless result.length > 0
|
||||||
|
|
||||||
|
return result.sort (a, b)-> a.compareTo b
|
||||||
@@ -115,6 +115,11 @@ module.exports = class Recipe extends BaseModel
|
|||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
requiresTool: (itemSlug)->
|
||||||
|
for stack in @tools
|
||||||
|
if stack.itemSlug.matches itemSlug
|
||||||
|
return true
|
||||||
|
|
||||||
# Property Methods #############################################################################
|
# Property Methods #############################################################################
|
||||||
|
|
||||||
getSlug: ->
|
getSlug: ->
|
||||||
|
|||||||
@@ -20,5 +20,6 @@
|
|||||||
.panel
|
.panel
|
||||||
|
|
||||||
.usedToMake: .view__item_group
|
.usedToMake: .view__item_group
|
||||||
|
.usedAsToolToMake: .view__item_group
|
||||||
.similar: .view__item_group
|
.similar: .view__item_group
|
||||||
.plan
|
.plan
|
||||||
Reference in New Issue
Block a user