A component for displaying and modifying a WAStoreCart. Intended to be embedded rather than called. The parent must provide a cart instance with #cart:. Displays a list of items in the cart, and allows individual items to be removed. Used by WAStoreFillCart.
ProtoObjectObjectWAPresenterWAComponentWAStoreCartView
| cart |
| instance | class |
|---|---|
| accessing rendering | no messages
|
| cart |
|---|
| accessing |
|---|
| cart: aCart |
cart _ aCart |
| rendering |
|---|
| renderContentOn: html |
cart hasItems ifFalse: [^ self]. html divNamed: 'cart' with: [ html small: [html bold: 'Your cart:']. html table: [ cart countsAndItems do: [:assoc | self renderRowForCount: assoc key of: assoc value on: html ]. html spacerRow. html tableRowWith: '' with: '' with: [html bold: cart totalPrice printStringAsCents]. ] ] |
| renderRowForCount: aNumber of: anItem on: html |
| countString |
countString _ (aNumber = 1) ifTrue: [''] ifFalse: ['(', aNumber asString, ') '].
html
tableRowWith: [html anchorWithAction: [cart remove: anItem] text: '-']
with: countString, anItem title
with: (aNumber * anItem price) printStringAsCents
|