Skip to content

Commit

Permalink
Merge cec0fae into 8a3776f
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Dec 13, 2018
2 parents 8a3776f + cec0fae commit 7e50fe3
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/guides/place-my-order.md
Expand Up @@ -808,7 +808,7 @@ donejs add supermodel order
Like the restaurant model, the URL is `/api/orders` and the id property is `_id`. To select menu items, we need to add some additional functionality to `src/models/order.js`:

@sourceref ../../guides/place-my-order/steps/create-data/order.js
@highlight 4-26,34-55,only
@highlight 4-25,34-55,only

Here we define an `ItemsList` which allows us to toggle menu items and check if they are already in the order. We set up ItemsList as the Value of the items property of an order so we can use its has function and toggle directly in the template. We also set a default value for status and a getter for calculating the order total which adds up all the item prices. We also create another `<order-model>` tag to load orders in the order history template later.

Expand Down Expand Up @@ -863,7 +863,7 @@ can-connect makes it very easy to implement real-time functionality. It is capab
Update `src/models/order.js` to use [QueryLogic.makeEnum](https://canjs.com/doc/can-query-logic.makeEnum.html) so that we can declare all of the possible values for an order's `status`.

@sourceref ../../guides/place-my-order/steps/real-time/order-model.js
@highlight 1,28,43-44,only
@highlight 1,27,42-43,only

### Update the template

Expand Down Expand Up @@ -894,7 +894,7 @@ npm install steal-socket.io@4 --save
Update `src/models/order.js` to use socket.io to update the Order model in real-time:

@sourceref ../../guides/place-my-order/steps/real-time/order.js
@highlight 3,73-77,only
@highlight 3,72-76,only

That's it. If we now open the [order page](http://localhost:8080/order-history) we see some already completed default orders. Keeping the page open and placing a new order from another browser or device will update our order page automatically.

Expand Down
1 change: 1 addition & 0 deletions guides/place-my-order/steps/additional/details.component
Expand Up @@ -50,6 +50,7 @@
</view>
<script type="view-model">
import { DefineMap } from 'can';
import Restaurant from '~/models/restaurant';

export default DefineMap.extend("PmoRestaurantDetailsVM", {
// EXTERNAL STATEFUL PROPERTIES
Expand Down
3 changes: 1 addition & 2 deletions guides/place-my-order/steps/create-data/order.js
Expand Up @@ -8,8 +8,7 @@ const Item = DefineMap.extend({
});

const ItemsList = DefineList.extend({
'#': Item
}, {
'#': Item,
has: function(item) {
return this.indexOf(item) !== -1;
},
Expand Down
2 changes: 1 addition & 1 deletion guides/place-my-order/steps/create-dependent/list.js
Expand Up @@ -29,7 +29,7 @@ const RestaurantList = Component.extend({
return null;
}

return City.getList({ state });
return City.getList({ filter: { state } });
},
city: {
type: 'string',
Expand Down
4 changes: 2 additions & 2 deletions guides/place-my-order/steps/create-test/list-test.js
Expand Up @@ -22,7 +22,7 @@ QUnit.asyncTest('loads all states', function() {

QUnit.asyncTest('setting a state loads its cities', function() {
var vm = new ViewModel();
var expectedCities = cityStore.getList({ state: "CA" }).data;
var expectedCities = cityStore.getList({ filter: { state: "CA" } }).data;

QUnit.equal(vm.cities, null, '');
vm.state = 'CA';
Expand All @@ -34,7 +34,7 @@ QUnit.asyncTest('setting a state loads its cities', function() {

QUnit.asyncTest('changing a state resets city', function() {
var vm = new ViewModel();
var expectedCities = cityStore.getList({ state : "CA" }).data;
var expectedCities = cityStore.getList({ filter: { state : "CA" } }).data;

QUnit.equal(vm.cities, null, '');
vm.state = 'CA';
Expand Down
3 changes: 1 addition & 2 deletions guides/place-my-order/steps/real-time/order-model.js
Expand Up @@ -8,8 +8,7 @@ const Item = DefineMap.extend({
});

const ItemsList = DefineList.extend({
'#': Item
}, {
'#': Item,
has: function(item) {
return this.indexOf(item) !== -1;
},
Expand Down
3 changes: 1 addition & 2 deletions guides/place-my-order/steps/real-time/order.js
Expand Up @@ -9,8 +9,7 @@ const Item = DefineMap.extend({
});

const ItemsList = DefineList.extend({
'#': Item
}, {
'#': Item,
has: function(item) {
return this.indexOf(item) !== -1;
},
Expand Down
2 changes: 0 additions & 2 deletions guides/place-my-order/steps/switch-between/index.stache
Expand Up @@ -17,8 +17,6 @@
<div class="loading"></div>
{{/if}}

<h1>The <strong>{{this.routeData.page}}</strong> page</h1>

{{#eq(this.env.NODE_ENV, "production")}}
<script src="{{joinBase('steal.production.js')}}"></script>
{{else}}
Expand Down

0 comments on commit 7e50fe3

Please sign in to comment.