Add a "report a problem" link in crafting plan

This commit is contained in:
Andrew Miner
2015-01-15 21:59:03 -08:00
parent d94bd39e52
commit 33b9214386
4 changed files with 69 additions and 17 deletions
+28 -13
View File
@@ -14,19 +14,6 @@ All rights reserved.
position: absolute; top: 5em; right: 2em; bottom: 0; left: 2em;
background: $color-background-panel;
.prev {
background: url('/images/arrow-left-disabled.png');
position: absolute; top: 50%; left: 1em; height: 8em; width: 4em;
@include transform(translateY(-50%));
&.enabled {
background: url('/images/arrow-left.png');
cursor: pointer;
&:hover { background: url('/images/arrow-left-hover.png'); }
}
}
.input {
position: absolute; top: 50%; left: 33%;
@include transform(translate(-50%, -50%));
@@ -85,5 +72,33 @@ All rights reserved.
&:hover { background: url('/images/arrow-right-hover.png'); }
}
}
.prev {
background: url('/images/arrow-left-disabled.png');
position: absolute; top: 50%; left: 1em; height: 8em; width: 4em;
@include transform(translateY(-50%));
&.enabled {
background: url('/images/arrow-left.png');
cursor: pointer;
&:hover { background: url('/images/arrow-left-hover.png'); }
}
}
.problem {
position: absolute; bottom: 1em; right: 1em;
a {
color: $color-gray-light;
cursor: pointer;
font-size: $font-size-normal;
text-decoration: underline;
&:hover {
color: $color-gray-medium;
}
}
}
}
}
@@ -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'
+22 -2
View File
@@ -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()
+2
View File
@@ -21,3 +21,5 @@
p.quantity
p.multiplier
.next
.problem
a report a problem