Skip to content

Commit 83a98f1

Browse files
author
kovacevic
committed
refactored routing
1 parent 64a2ecf commit 83a98f1

File tree

3 files changed

+56
-10
lines changed

3 files changed

+56
-10
lines changed

Diff for: src/router/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const routes: Array<RouteRecordRaw> = [
2121
name: 'catalogue',
2222
component: () =>
2323
import(
24-
/* webpackChunkName: "catalogue" */ '@/views/catalogue/Catalogue.vue'
24+
/* webpackChunkName: "catalogue" */ '@/views/item/Catalogue.vue'
2525
),
2626
},
2727
{

Diff for: src/views/catalogue/Catalogues.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
catalogue.name
2222
}}</ion-label>
2323
<ion-badge color="secondary" slot="end">{{
24-
catalogue.items.length
24+
catalogue.itemCount
2525
}}</ion-badge>
2626
<ion-buttons slot="end">
2727
<ion-button @click="clickedOptions(catalogue)">
@@ -140,7 +140,7 @@ export default {
140140
CRDCatalogue.value = {
141141
id: '',
142142
name: '',
143-
items: [],
143+
itemCount: 0,
144144
};
145145
setOptionsOpen(false);
146146
setModalOpen(true);

Diff for: src/views/catalogue/Catalogue.vue renamed to src/views/item/Catalogue.vue

+53-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
</ion-header>
1111
<ion-content :fullscreen="true">
1212
<ion-toolbar>
13-
<ion-searchbar @ionInput="filterDisplayedItems($event.target.value)"></ion-searchbar>
13+
<ion-searchbar
14+
@ionInput="filterDisplayedItems($event.target.value)"
15+
></ion-searchbar>
1416
</ion-toolbar>
1517
<ion-list>
1618
<ion-list-header>
@@ -20,7 +22,25 @@
2022
<ion-label>{{ item.name }}</ion-label>
2123
</ion-item>
2224
</ion-list>
25+
<ion-infinite-scroll
26+
@ionInfinite="infiteLoadItems($event)"
27+
threshold="100px"
28+
id="infinite-scroll"
29+
>
30+
<ion-infinite-scroll-content
31+
loading-spinner="bubbles"
32+
loading-text="Loading more data..."
33+
>
34+
</ion-infinite-scroll-content>
35+
</ion-infinite-scroll>
2336
</ion-content>
37+
38+
<ion-loading
39+
:is-open="catalogueLoading || itemsLoading"
40+
message="Please wait..."
41+
:duration="1000"
42+
>
43+
</ion-loading>
2444
</ion-page>
2545
</template>
2646

@@ -38,11 +58,15 @@ import {
3858
IonTitle,
3959
IonListHeader,
4060
IonBackButton,
61+
IonLoading,
62+
IonInfiniteScroll,
63+
IonInfiniteScrollContent,
4164
} from '@ionic/vue';
4265
43-
import { useCatalogue } from '@/composables/useCatalogue';
66+
import { useItem } from '@/composables/useItem';
4467
import { onMounted } from '@vue/runtime-core';
4568
import router from '@/router';
69+
import { useCatalogue } from '@/composables/useCatalogue';
4670
4771
export default {
4872
name: 'Catalogue',
@@ -58,26 +82,48 @@ export default {
5882
IonContent,
5983
IonPage,
6084
IonListHeader,
85+
IonLoading,
6186
IonBackButton,
87+
IonInfiniteScroll,
88+
IonInfiniteScrollContent,
6289
},
6390
setup() {
91+
const {
92+
runWrappedGetItems,
93+
filterDisplayedItems,
94+
itemsLoading,
95+
displayedItems,
96+
itemFilter,
97+
page,
98+
infiteLoadItems,
99+
} = useItem();
100+
64101
const {
65102
selectedCatalogue,
66103
getCatalogue,
67-
displayedItems,
68-
filterDisplayedItems,
104+
catalogueLoading,
69105
} = useCatalogue();
70106
71107
onMounted(async () => {
72108
try {
73-
const routeID = router.currentRoute.value.params.id as string;
74-
await getCatalogue(routeID);
109+
const catalogueID = router.currentRoute.value.params.id as string;
110+
await getCatalogue(catalogueID);
111+
itemFilter.value = { catalogue: catalogueID };
112+
await runWrappedGetItems();
75113
} catch (error) {
76114
console.log(error);
77115
}
78116
});
117+
79118
80-
return { selectedCatalogue, filterDisplayedItems, displayedItems };
119+
return {
120+
selectedCatalogue,
121+
catalogueLoading,
122+
itemsLoading,
123+
filterDisplayedItems,
124+
displayedItems,
125+
infiteLoadItems,
126+
};
81127
},
82128
};
83129
</script>

0 commit comments

Comments
 (0)