-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2956 from Hackbard/feature/2810-order-history-module
- Loading branch information
Showing
10 changed files
with
87 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { isBottomVisible } from '@vue-storefront/core/helpers' | ||
|
||
/** | ||
* By implementing this mixin add "onBottomScroll" mthod in component. | ||
* It will be invoked when view reach the bottom. | ||
*/ | ||
export default { | ||
mounted () { | ||
const scrollHandler = () => { | ||
if (isBottomVisible()) { | ||
this.onBottomScroll() | ||
} | ||
} | ||
document.addEventListener('scroll', scrollHandler) | ||
this.$once('hook:destroyed', () => { | ||
document.removeEventListener('scroll', scrollHandler) | ||
}) | ||
} | ||
} |
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,32 @@ | ||
import MyOrders from '@vue-storefront/core/compatibility/components/blocks/MyAccount/MyOrders' | ||
import { mapGetters } from 'vuex'; | ||
import onBottomScroll from '@vue-storefront/core/mixins/onBottomScroll' | ||
|
||
export default { | ||
name: 'UserOrders', | ||
mixins: [MyOrders, onBottomScroll], | ||
data () { | ||
return { | ||
pagination: { | ||
perPage: 10, | ||
current: 1, | ||
enabled: false | ||
}, | ||
lazyLoadOrdersOnScroll: true | ||
} | ||
}, | ||
computed: { | ||
ordersHistory () { | ||
let items = this.getOrdersHistory | ||
if (this.lazyLoadOrdersOnScroll) { | ||
items = items.slice(0, (this.pagination.perPage + 1) * this.pagination.current) | ||
} | ||
return items | ||
} | ||
}, | ||
methods: { | ||
onBottomScroll () { | ||
++this.pagination.current | ||
} | ||
} | ||
} |
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