Add a "report a problem" link in crafting plan
This commit is contained in:
@@ -9,6 +9,7 @@ BaseController = require './base_controller'
|
||||
CraftingGridController = require './crafting_grid_controller'
|
||||
{Duration} = require '../constants'
|
||||
ImageLoader = require './image_loader'
|
||||
InventoryParser = require '../models/inventory_parser'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -32,6 +33,12 @@ module.exports = class CraftingTableController extends BaseController
|
||||
onPrevClicked: ->
|
||||
@model.step -= 1
|
||||
|
||||
onReportProblem: ->
|
||||
parser = new InventoryParser @modPack
|
||||
itemList = parser.unparse @model.plan.want
|
||||
message = "When I was on step #{@model.step + 1} of making:\n\n#{itemList}\nI noticed that...\n"
|
||||
global.feedbackController.enterFeedback message
|
||||
|
||||
# BaseController Overrides #####################################################################
|
||||
|
||||
onDidRender: ->
|
||||
@@ -45,6 +52,7 @@ module.exports = class CraftingTableController extends BaseController
|
||||
@$outputLink = @$('.output a')
|
||||
@$outputQuantity = @$('.quantity')
|
||||
@$prev = @$('.prev')
|
||||
@$problemControl = @$('.problem')
|
||||
@$title = @$('h2 p')
|
||||
@$tool = @$('.tool p')
|
||||
|
||||
@@ -85,10 +93,17 @@ module.exports = class CraftingTableController extends BaseController
|
||||
@$multiplier.html ''
|
||||
|
||||
@$el.tooltip show:{delay:Duration.slow, duration:Duration.fast}
|
||||
|
||||
if not (@model.hasSteps and global.feedbackController?)
|
||||
@$problemControl.hide duration:Duration.fast
|
||||
else
|
||||
@$problemControl.show duration:Duration.normal
|
||||
|
||||
super
|
||||
|
||||
# Backbone.View Overrides ######################################################################
|
||||
|
||||
events:
|
||||
'click .next': 'onNextClicked'
|
||||
'click .prev': 'onPrevClicked'
|
||||
'click .next': 'onNextClicked'
|
||||
'click .prev': 'onPrevClicked'
|
||||
'click .problem a': 'onReportProblem'
|
||||
|
||||
@@ -5,15 +5,23 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
Inventory = require './inventory'
|
||||
Item = require './item'
|
||||
Inventory = require './inventory'
|
||||
Item = require './item'
|
||||
StringBuilder = require './string_builder'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class InventoryParser
|
||||
|
||||
constructor: (modPack=null)->
|
||||
@modPack = modPack
|
||||
|
||||
# Class Methods ################################################################################
|
||||
|
||||
@ITEM_REGEX = /^([0-9]+)(.*)$/
|
||||
|
||||
# Public Methods ###############################################################################
|
||||
|
||||
parse: (data, inventory=null)->
|
||||
inventory ?= new Inventory
|
||||
return inventory if not data? or data.length is 0
|
||||
@@ -28,3 +36,15 @@ module.exports = class InventoryParser
|
||||
inventory.add _.slugify(name), quantity
|
||||
|
||||
return inventory
|
||||
|
||||
unparse: (inventory)->
|
||||
if not @modPack? then throw new Error 'this.modPack is needed to unparse'
|
||||
|
||||
builder = new StringBuilder
|
||||
for item in inventory.toList()
|
||||
if _.isString item
|
||||
builder.line @modPack.findName item
|
||||
else
|
||||
builder.line item[0], ' ', @modPack.findName item[1]
|
||||
|
||||
return builder.toString()
|
||||
Reference in New Issue
Block a user