Skip to content

Commit

Permalink
minor changes to make sure that the mocked up request data for the cu…
Browse files Browse the repository at this point in the history
…stomer form still works with the model and UI
  • Loading branch information
ifandelse committed Aug 16, 2011
1 parent d7afc4f commit bc92f70
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion ShortOrderExample/client/customer/js-app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ postal.subscribe("menu.get", function(data) {
menuViewModel.isVisible = ko.observable(true);
if(menuViewModel.items()) {
menuViewModel.items().forEach(function(item) {
item.pricePerUnit((item.pricePerUnit()).toFixed(2));
item.dispPricePerUnit = ko.dependentObservable(function() {
return (item.pricePerUnit()).toFixed(2);
}, item);
item.addMenuItem = function() {
postal.publish("order.items.add", ko.mapping.toJS(item));
}
Expand Down
8 changes: 4 additions & 4 deletions ShortOrderExample/client/customer/js-app/request.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// Set up mock requests
amplify.request.define(FETCH_MENU, function(settings){
var fakeMenu = [
{ id: 0, description: "Burger", pricePerUnit: (1.00).toFixed(2), imageUrl: "/img/burger.png" },
{ id: 1, description: "Fries", pricePerUnit: (.50).toFixed(2), imageUrl: "/img/fries.png" },
{ id: 2, description: "Drink", pricePerUnit: (1.25).toFixed(2), imageUrl: "/img/drink.png" },
{ id: 3, description: "Milkshake", pricePerUnit: (2.00).toFixed(2), imageUrl: "/img/shake.png" },
{ id: 0, description: "Burger", pricePerUnit: 1, imageUrl: "/img/burger.png" },
{ id: 1, description: "Fries", pricePerUnit: .5, imageUrl: "/img/fries.png" },
{ id: 2, description: "Drink", pricePerUnit: 1.25, imageUrl: "/img/drink.png" },
{ id: 3, description: "Milkshake", pricePerUnit: 2, imageUrl: "/img/shake.png" },
];
settings.success(fakeMenu);
});
Expand Down
2 changes: 1 addition & 1 deletion ShortOrderExample/client/customer/templates/menuItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="menu-row">
<div>
Price:&nbsp;$
<span data-bind-menu="text: pricePerUnit"></span>
<span data-bind-menu="text: dispPricePerUnit"></span>
<input type="button" value="+" class="menu-action-add" data-bind-menu="click: addMenuItem ">
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ShortOrderExample/init.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ writeIfMissing = ( item ) ->
"Could not save item " +
id +
" because " +
JSON.stringify err )
err )
else
console.log( " Saved item " + id + ". Yay!" )
)
Expand Down

0 comments on commit bc92f70

Please sign in to comment.