forked from vuestorefront/vue-storefront
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* provide changelog message * Move bottomVisible to core helper * remove bottomVisible from Category * Add new Module order-history
- Loading branch information
Benjamin Klein
committed
May 24, 2019
1 parent
1aa03f1
commit 9364eb6
Showing
7 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { isServer, bottomVisible } from '@vue-storefront/core/helpers' | ||
import MyOrder from '@vue-storefront/core/compatibility/components/blocks/MyAccount/MyOrder' | ||
|
||
export default { | ||
name: 'UserOrders', | ||
mixins: [MyOrder], | ||
data () { | ||
return { | ||
pagination: { | ||
perPage: 10, | ||
current: 0, | ||
enabled: false | ||
}, | ||
bottom: false, | ||
lazyLoadOrdersOnscroll: true | ||
} | ||
}, | ||
watch: { | ||
bottom (bottom) { | ||
if (bottom) { | ||
++this.pagination.current | ||
} | ||
} | ||
}, | ||
beforeMount () { | ||
if (!isServer && this.lazyLoadOrdersOnscroll) { | ||
window.addEventListener('scroll', () => { | ||
this.bottom = bottomVisible() | ||
}, {passive: true}) | ||
} | ||
}, | ||
computed: { | ||
ordersHistory () { | ||
let items = [] | ||
items = this.$store.state.user.orders_history.items | ||
if (!isServer && this.lazyLoadOrdersOnscroll) { | ||
items = this.paginate(items, this.pagination.perPage, this.pagination.current) | ||
} | ||
return items | ||
}, | ||
isHistoryEmpty () { | ||
return this.$store.state.user.orders_history.items.length < 1 | ||
} | ||
}, | ||
methods: { | ||
paginate (array, page_size, page_number) { | ||
return array.slice(0, (page_number + 1) * page_size); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createModule } from '@vue-storefront/core/lib/module' | ||
|
||
const KEY = 'order-history' | ||
export const OrderHistory = createModule({ | ||
key: KEY | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters