First real version of item detail page
* Split the InventoryTable view/controller out from the existing inventory view/controller. This is a simpler component which only includes the table itself, and not the scrollbox, panel or header used on the crafting page. * Create the FullRecipe view/controller to represent the expanded version of a recipe shown on the item page (as compared to the terser version on the crafting page). * Rename the existing Recipe view/controller to MinimalRecipe to avoid confusing the two. * Refactor the CSS for the Stack view/controller so that it can be shared between the Inventory and InventoryTable views. * Incorporate all these new controllers into the item page and hook up the necessary model logic to drive them.
This commit is contained in:
@@ -7,7 +7,7 @@ All rights reserved.
|
||||
|
||||
BaseModel = require './base_model'
|
||||
CraftingPlan = require './crafting_plan'
|
||||
Event = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -25,21 +25,10 @@ module.exports = class ItemPage extends BaseModel
|
||||
Object.defineProperties this,
|
||||
craftingRawMaterials: {get:-> @_plan.need}
|
||||
craftingSteps: {get:-> @_plan.steps}
|
||||
similarItems: {get:=> @getSimilarItems()}
|
||||
primaryRecipe: {get:-> @_primaryRecipe}
|
||||
|
||||
# Property Methods #############################################################################
|
||||
|
||||
findSimilarItems: ->
|
||||
return null unless @item?.modVersion?
|
||||
|
||||
result = []
|
||||
@item.modVersion.eachItemInGroup @item.group, (item)=>
|
||||
return if item is @item
|
||||
result.push item
|
||||
|
||||
return null unless result.length > 0
|
||||
return result
|
||||
|
||||
findComponentInItems: ->
|
||||
return null unless @item?
|
||||
|
||||
@@ -56,6 +45,17 @@ module.exports = class ItemPage extends BaseModel
|
||||
return null unless result.length > 0
|
||||
return result
|
||||
|
||||
findSimilarItems: ->
|
||||
return null unless @item?.modVersion?
|
||||
|
||||
result = []
|
||||
@item.modVersion.eachItemInGroup @item.group, (item)=>
|
||||
return if item is @item
|
||||
result.push item
|
||||
|
||||
return null unless result.length > 0
|
||||
return result
|
||||
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_updateCraftingPlan: ->
|
||||
@@ -63,4 +63,9 @@ module.exports = class ItemPage extends BaseModel
|
||||
|
||||
if @item?
|
||||
@_plan.want.add @item.slug
|
||||
@_plan.craft()
|
||||
@_plan.craft()
|
||||
|
||||
if @_plan.steps.length > 0
|
||||
@_primaryRecipe = @_plan.steps[@_plan.steps.length - 1].recipe
|
||||
else
|
||||
@_primaryRecipe = null
|
||||
|
||||
Reference in New Issue
Block a user