From 8d7fd5d25c06664ae7b4a31d99367425c3de2e04 Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Sat, 31 Jan 2015 20:53:09 -0800 Subject: [PATCH] Add "remove" button to inventory view --- src/css/templates/inventory.scss | 4 - src/css/templates/stack.scss | 22 + src/design/remove.graffle | 589 ++++++++++++++++++ src/images/remove-hover.png | Bin 0 -> 921 bytes src/images/remove.png | Bin 0 -> 853 bytes .../controllers/inventory_controller.coffee | 3 +- .../controllers/stack_controller.coffee | 25 +- src/scripts/models/item_page.coffee | 1 - src/templates/stack.jade | 3 +- 9 files changed, 637 insertions(+), 10 deletions(-) create mode 100644 src/design/remove.graffle create mode 100644 src/images/remove-hover.png create mode 100644 src/images/remove.png diff --git a/src/css/templates/inventory.scss b/src/css/templates/inventory.scss index 5e98534ff..35e4f6e70 100644 --- a/src/css/templates/inventory.scss +++ b/src/css/templates/inventory.scss @@ -95,9 +95,5 @@ All rights reserved. td.action { width: 4em; - - button { - width: 4em; - } } } diff --git a/src/css/templates/stack.scss b/src/css/templates/stack.scss index e72e81234..852741fda 100644 --- a/src/css/templates/stack.scss +++ b/src/css/templates/stack.scss @@ -24,4 +24,26 @@ All rights reserved. display: inline; font-size: $font-size-normal; } + + .action { + text-align: right; + + button.remove { + opacity: 0; + position: relative; width: 1.8em; height: 1.8em; + background: url('/images/remove.png') no-repeat center; + border: 0; + outline: none; + + &:hover { + background: url('/images/remove-hover.png') no-repeat center; + } + } + } + + &:hover { + button.remove { + opacity: 1; + } + } } diff --git a/src/design/remove.graffle b/src/design/remove.graffle new file mode 100644 index 000000000..9e20ec3bb --- /dev/null +++ b/src/design/remove.graffle @@ -0,0 +1,589 @@ + + + + + ApplicationVersion + + com.omnigroup.OmniGraffle.MacAppStore + 139.18 + + CreationDate + 2015-02-01 04:20:02 +0000 + Creator + Andrew Miner + GraphDocumentVersion + 8 + GuidesLocked + NO + GuidesVisible + YES + ImageCounter + 1 + LinksVisible + NO + MagnetsVisible + NO + MasterSheets + + ModificationDate + 2015-02-01 04:35:56 +0000 + Modifier + Andrew Miner + NotesVisible + NO + OriginVisible + NO + PageBreaks + NO + PrintInfo + + NSBottomMargin + + float + 41 + + NSHorizonalPagination + + coded + BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG + + NSLeftMargin + + float + 18 + + NSPaperSize + + size + {611.99998474121094, 792} + + NSPrintReverseOrientation + + int + 0 + + NSRightMargin + + float + 18 + + NSTopMargin + + float + 18 + + + ReadOnly + NO + Sheets + + + ActiveLayerIndex + 0 + AutoAdjust + + BackgroundGraphic + + Bounds + {{0, 0}, {100, 100}} + Class + SolidGraphic + ID + 2 + Style + + shadow + + Draws + NO + + stroke + + Draws + NO + + + + BaseZoom + 0 + CanvasOrigin + {0, 0} + CanvasSize + {100, 100} + ColumnAlign + 1 + ColumnSpacing + 36 + DisplayScale + 1 pt = 1 px + GraphicsList + + + Bounds + {{20.000000769986293, 41.000000769986251}, {60, 18}} + Class + ShapedGraphic + ID + 7 + Magnets + + {-0.59628479784302701, -1.1925696134567261} + {1.9868215517249155e-08, -1.3333333730697632} + {0.59628487781105122, -1.1925696134567261} + {1.1925696134567261, -0.59628480672836304} + {1.3333333730697632, 1.5894572413799324e-07} + {1.1925696134567261, 0.59628473564567486} + {0.59628465308492196, 1.1925697326660156} + {0, 1.3333333730697632} + {-0.5962849488937394, 1.1925696134567261} + {-1.1925697326660156, 0.5962844398368361} + {-1.3333333730697632, -6.3578289655197295e-07} + {-1.1925696134567261, -0.59628480672836304} + + Rotation + 45 + Shape + Rectangle + Style + + shadow + + Draws + NO + + stroke + + Draws + NO + + + + + Bounds + {{20, 41}, {60, 18}} + Class + ShapedGraphic + ID + 6 + Magnets + + {-0.59628479784302701, -1.1925696134567261} + {1.9868215517249155e-08, -1.3333333730697632} + {0.59628487781105122, -1.1925696134567261} + {1.1925696134567261, -0.59628480672836304} + {1.3333333730697632, 1.5894572413799324e-07} + {1.1925696134567261, 0.59628473564567486} + {0.59628465308492196, 1.1925697326660156} + {0, 1.3333333730697632} + {-0.5962849488937394, 1.1925696134567261} + {-1.1925697326660156, 0.5962844398368361} + {-1.3333333730697632, -6.3578289655197295e-07} + {-1.1925696134567261, -0.59628480672836304} + + Rotation + 315 + Shape + Rectangle + Style + + shadow + + Draws + NO + + stroke + + Draws + NO + + + + + Bounds + {{5, 5}, {90, 90}} + Class + ShapedGraphic + ID + 3 + Magnets + + {-0.59628479784302701, -1.1925696134567261} + {1.9868215517249155e-08, -1.3333333730697632} + {0.59628487781105122, -1.1925696134567261} + {1.1925696134567261, -0.59628480672836304} + {1.3333333730697632, 1.5894572413799324e-07} + {1.1925696134567261, 0.59628473564567486} + {0.59628465308492196, 1.1925697326660156} + {0, 1.3333333730697632} + {-0.5962849488937394, 1.1925696134567261} + {-1.1925697326660156, 0.5962844398368361} + {-1.3333333730697632, -6.3578289655197295e-07} + {-1.1925696134567261, -0.59628480672836304} + + Shape + Circle + Style + + fill + + Color + + b + 0.152527 + g + 0.118533 + r + 0.744739 + + + shadow + + Draws + NO + + stroke + + Draws + NO + + + + + GridInfo + + GridSpacing + 2 + MajorGridSpacing + 5 + ShowsGrid + YES + + HPages + 1 + KeepToScale + + Layers + + + Lock + NO + Name + Layer 1 + Print + YES + View + YES + + + LayoutInfo + + Animate + NO + circoMinDist + 18 + circoSeparation + 0.0 + layoutEngine + dot + neatoSeparation + 0.0 + twopiSeparation + 0.0 + + Orientation + 2 + PrintOnePage + + RowAlign + 1 + RowSpacing + 36 + SheetTitle + Canvas 1 + UniqueID + 1 + VPages + 1 + + + ActiveLayerIndex + 0 + AutoAdjust + + BackgroundGraphic + + Bounds + {{0, 0}, {100, 100}} + Class + SolidGraphic + ID + 2 + Style + + shadow + + Draws + NO + + stroke + + Draws + NO + + + + BaseZoom + 0 + CanvasOrigin + {0, 0} + CanvasSize + {100, 100} + ColumnAlign + 1 + ColumnSpacing + 36 + DisplayScale + 1 pt = 1 px + GraphicsList + + + Bounds + {{20.000000769986293, 41.000000769986251}, {60, 18}} + Class + ShapedGraphic + ID + 7 + Magnets + + {-0.59628479784302701, -1.1925696134567261} + {1.9868215517249155e-08, -1.3333333730697632} + {0.59628487781105122, -1.1925696134567261} + {1.1925696134567261, -0.59628480672836304} + {1.3333333730697632, 1.5894572413799324e-07} + {1.1925696134567261, 0.59628473564567486} + {0.59628465308492196, 1.1925697326660156} + {0, 1.3333333730697632} + {-0.5962849488937394, 1.1925696134567261} + {-1.1925697326660156, 0.5962844398368361} + {-1.3333333730697632, -6.3578289655197295e-07} + {-1.1925696134567261, -0.59628480672836304} + + Rotation + 45 + Shape + Rectangle + Style + + shadow + + Draws + NO + + stroke + + Draws + NO + + + + + Bounds + {{20, 41}, {60, 18}} + Class + ShapedGraphic + ID + 6 + Magnets + + {-0.59628479784302701, -1.1925696134567261} + {1.9868215517249155e-08, -1.3333333730697632} + {0.59628487781105122, -1.1925696134567261} + {1.1925696134567261, -0.59628480672836304} + {1.3333333730697632, 1.5894572413799324e-07} + {1.1925696134567261, 0.59628473564567486} + {0.59628465308492196, 1.1925697326660156} + {0, 1.3333333730697632} + {-0.5962849488937394, 1.1925696134567261} + {-1.1925697326660156, 0.5962844398368361} + {-1.3333333730697632, -6.3578289655197295e-07} + {-1.1925696134567261, -0.59628480672836304} + + Rotation + 315 + Shape + Rectangle + Style + + shadow + + Draws + NO + + stroke + + Draws + NO + + + + + Bounds + {{5, 5}, {90, 90}} + Class + ShapedGraphic + ID + 3 + Magnets + + {-0.59628479784302701, -1.1925696134567261} + {1.9868215517249155e-08, -1.3333333730697632} + {0.59628487781105122, -1.1925696134567261} + {1.1925696134567261, -0.59628480672836304} + {1.3333333730697632, 1.5894572413799324e-07} + {1.1925696134567261, 0.59628473564567486} + {0.59628465308492196, 1.1925697326660156} + {0, 1.3333333730697632} + {-0.5962849488937394, 1.1925696134567261} + {-1.1925697326660156, 0.5962844398368361} + {-1.3333333730697632, -6.3578289655197295e-07} + {-1.1925696134567261, -0.59628480672836304} + + Shape + Circle + Style + + fill + + Color + + b + 0.356563 + g + 0.300364 + r + 0.987799 + + + shadow + + Draws + NO + + stroke + + Color + + b + 0.152527 + g + 0.118533 + r + 0.744739 + + + + + + GridInfo + + GridSpacing + 2 + MajorGridSpacing + 5 + ShowsGrid + YES + + HPages + 1 + KeepToScale + + Layers + + + Lock + NO + Name + Layer 1 + Print + YES + View + YES + + + LayoutInfo + + Animate + NO + circoMinDist + 18 + circoSeparation + 0.0 + layoutEngine + dot + neatoSeparation + 0.0 + twopiSeparation + 0.0 + + Orientation + 2 + PrintOnePage + + RowAlign + 1 + RowSpacing + 36 + SheetTitle + Canvas 2 + UniqueID + 2 + VPages + 1 + + + SmartAlignmentGuidesActive + YES + SmartDistanceGuidesActive + YES + UseEntirePage + + WindowInfo + + CurrentSheet + 1 + ExpandedCanvases + + Frame + {{427, 0}, {2133, 1417}} + ListView + + OutlineWidth + 142 + RightSidebar + + ShowRuler + + Sidebar + + SidebarWidth + 120 + VisibleRegion + {{-74, -29}, {249.75, 159.375}} + Zoom + 8 + ZoomValues + + + Canvas 1 + 8 + 1.9099999666213989 + + + Canvas 2 + 8 + 1 + + + + + diff --git a/src/images/remove-hover.png b/src/images/remove-hover.png new file mode 100644 index 0000000000000000000000000000000000000000..5cb7747b977c577b39435f210e9f4b300416d7d5 GIT binary patch literal 921 zcmV;K17`e*P)CjYboV`V)8~Uib@! zDBcmZQmPUPL4~%E(st+g%}#4I#-xir@+FgbQP3jTTua;Gb;Uaae?Q>xXt1eyxcnMZ zynwR@d=85%55>z6>_FicIGfV!Z3IVkh&?mAO{11 z0atDS;UNaenT5X(>#}Dy*08_M5ZJSZhMh@Cd5Az5=prx<^z|E%NC4-D_yxqcehbKC zfR8aCKo_&RvYd^y z*enn_$B1f8Qv;dB*7lCF0h4C?9i2)m)hBWpm|qZwYMS^iE&<<{#XMhFo0MsBWvC?S(FfGX?O06XQYqy0!{-9JV35nBgRrw_uqkmI|C@qRc>ds??e73e$qLRnE z4?z5rnCA*>Tv&Yj^O~8qF10Uo;u8#mhZ=s*)D@0fJ%CWdhXNqBA6Y5=c+45D2f?xr;(b6HfuzLzKGp zy-BlUe7dHl(onZaw6xT&In>X3AGNr0I5WU-ntWzcskQ+zczyecMxL3Sz-VtqIW-eK zc(8s$&HGbRt0^OU;(CU%hv}x~J|nxZV)Nz=y_@JKHhA++G?`2rYTlz2;)zK#H`lFN zontvy4-?N*sPH^d9X zK!n}XbB5i;t7aj+Nh=r)`5amdfltB1zjRtxUxbttc`!8cq>mDV`_c<7#KpfEY# zK8?rwg{38%vhSRqgBRVaD=@dVz}(z~4vxK`gse=)HZ;w~bG;>z1qQ52`HC{lY1-fv zDeGYsD*F8)C|2qx;mx(%ir)Of!hpnufNz6WD8vb=5tV4uIhjNqf~Xh_{HlDg%S*6! zb|4=PDzBIm+Bs>w~I-TIpo6O zdt#=-*r(%h8edu4^0KT6(XOHL$lA`1 zSZw1=$`)n)1L@5zF4_;xn?#kvMkhxi8$=&%7a2>AZQckt1MXc&CXP48J33Pm1Kx?l z>j@uHBPB!c(CCj0_j>XY9=FOFZ(}x*m@Di0R$YjfD25V#n2e!k3Gows^M%FOP8JP+ fVz6mU<6rR?jNRk_ISP0D00000NkvXXu0mjf>ztEE literal 0 HcmV?d00001 diff --git a/src/scripts/controllers/inventory_controller.coffee b/src/scripts/controllers/inventory_controller.coffee index c9f140f0a..caf1fcefa 100644 --- a/src/scripts/controllers/inventory_controller.coffee +++ b/src/scripts/controllers/inventory_controller.coffee @@ -120,7 +120,6 @@ module.exports = class InventoryController extends BaseController super refresh: -> - display = if @editable then 'block' else 'none' @$editPanel.css display:(if @editable then 'table-row' else 'none') @$toolbar.css display:(if @editable then 'block' else 'none') @$scrollbox.css bottom:(if @editable then @$toolbar.height() else '0') @@ -135,6 +134,7 @@ module.exports = class InventoryController extends BaseController @_stackControllers = [] @model.each (stack)=> options = + editable: @editable imageLoader: @imageLoader model: stack modPack: @modPack @@ -167,6 +167,7 @@ module.exports = class InventoryController extends BaseController # Private Methods ############################################################################## _removeStack: (stack)-> + @model.remove stack.slug, stack.quantity _updateNameAutocomplete: -> onChanged = => @onNameFieldChanged() diff --git a/src/scripts/controllers/stack_controller.coffee b/src/scripts/controllers/stack_controller.coffee index ec5015409..57ad2d392 100644 --- a/src/scripts/controllers/stack_controller.coffee +++ b/src/scripts/controllers/stack_controller.coffee @@ -15,25 +15,44 @@ module.exports = class StackController extends BaseController constructor: (options={})-> if not options.model? then throw new Error 'options.model is required' if not options.modPack? then throw new Error 'options.modPack is required' - options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png' - options.templateName = 'stack' + + options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png' + options.editable ?= false + options.onRemove ?= (stack)-> # do nothing + options.templateName = 'stack' super options + @editable = options.editable @modPack = options.modPack + @onRemove = options.onRemove @_imageLoader = options.imageLoader + # Event Methods ################################################################################ + + onRemoveClicked: -> + @onRemove @model + # BaseController Overrides ##################################################################### onDidRender: -> @$image = @$('.icon img') @$nameField = @$('.name p') @$quantityField = @$('.quantity p') + @$removeButton = @$('button.remove') super refresh: -> display = @modPack.findItemDisplay @model.slug + @_imageLoader.load display.iconUrl, @$image @$nameField.html display.itemName @$quantityField.html @model.quantity - @_imageLoader.load display.iconUrl, @$image + @$removeButton.css display:(if @editable then 'inherit' else 'none') + super + + # Backbone.View Overrides ###################################################################### + + events: -> + return _.extend super, + 'click button.remove': 'onRemoveClicked' diff --git a/src/scripts/models/item_page.coffee b/src/scripts/models/item_page.coffee index e45380c0e..92ea09ec1 100644 --- a/src/scripts/models/item_page.coffee +++ b/src/scripts/models/item_page.coffee @@ -31,7 +31,6 @@ module.exports = class ItemPage extends BaseModel # Private Methods ############################################################################## _consumeParams: -> - logger.debug "consuming params: #{util.inspect(@params)}" return unless @params? @plan.want.clear() diff --git a/src/templates/stack.jade b/src/templates/stack.jade index eae820eaf..1adffb769 100644 --- a/src/templates/stack.jade +++ b/src/templates/stack.jade @@ -9,4 +9,5 @@ tr.view__stack td.quantity: p td.icon: img(src='') td.name: p - td.action   + td.action + button.remove