Skip to content

Commit

Permalink
Remove use of and
Browse files Browse the repository at this point in the history
  • Loading branch information
Quetzacoalt91 committed Jan 3, 2024
1 parent d450006 commit 68d53f6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ describe('CampaignTableList', () => {
expect(wrapper.findComponent(tablePageControlsVue).exists()).toBe(true);
expect(wrapper.vm.activePage).toBe(1);

await wrapper.vm.$root.$emit('changePage', 3);
await wrapper.findComponent(tablePageControlsVue).vm.$emit('changePage', 3);

expect(wrapper.vm.activePage).toBe(3);
});
Expand All @@ -427,7 +427,7 @@ describe('CampaignTableList', () => {
expect(wrapper.findComponent(tablePageControlsVue).exists()).toBe(true);
expect(wrapper.vm.totalPages).toBe(13);

await wrapper.vm.$root.$emit('changeLimit', 50);
await wrapper.findComponent(tablePageControlsVue).vm.$emit('changeLimit', 50);

expect(wrapper.vm.totalPages).toBe(3);
});
Expand All @@ -445,10 +445,10 @@ describe('CampaignTableList', () => {

expect(campaignsListAction).toHaveBeenCalledTimes(1);

await wrapper.vm.$root.$emit('changeLimit', 50);
await wrapper.findComponent(tablePageControlsVue).vm.$emit('changeLimit', 50);
expect(campaignsListAction).toHaveBeenCalledTimes(2);

await wrapper.vm.$root.$emit('changePage', 3);
await wrapper.findComponent(tablePageControlsVue).vm.$emit('changePage', 3);
expect(campaignsListAction).toHaveBeenCalledTimes(3);
});
});
Expand Down
8 changes: 2 additions & 6 deletions _dev/apps/ui/src/components/campaign/campaign-table-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
:total-pages="totalPages"
:active-page="activePage"
:selected-filter-quantity-to-show="pageSize"
@changeLimit="changeLimit"
@changePage="changePageTo"
/>
</b-card-body>
</b-card>
Expand Down Expand Up @@ -248,15 +250,9 @@ export default defineComponent({
},
},
mounted() {
this.$root.$on('changeLimit', this.changeLimit);
this.$root.$on('changePage', this.changePageTo);
this.fetchCampaigns();
this.$store.dispatch('campaigns/GET_DIMENSIONS_FILTERS', null);
},
beforeDestroy() {
this.$root.$off('changeLimit', this.changeLimit);
this.$root.$off('changePage', this.changePageTo);
},
googleUrl,
CampaignTypes,
});
Expand Down
28 changes: 16 additions & 12 deletions _dev/apps/ui/src/components/commons/page-number-selector.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<template>
<div class="ps_gs-table-controls__go-to d-flex align-items-center">
<span class="flex-shrink-0">{{ $t('productFeedPage.approvalTable.goToLabel') }}</span>
<b-form-input
class="ml-2 maxw-sm-72 flex-grow-0"
type="text"
size="sm"
pattern="[0-9]*"
v-model.number="nbPageToGo"
/>
<b-form @submit.prevent="goToPage">
<b-form-input
class="ml-2 maxw-sm-72 flex-grow-0"
type="text"
size="sm"
pattern="[0-9]*"
v-model.number="nbPageToGo"
/>
</b-form>
<b-button
variant="primary"
class="ml-2"
Expand All @@ -19,18 +21,20 @@
</div>
</template>

<script>
export default {
<script lang="ts">
import {defineComponent} from 'vue';
export default defineComponent({
name: 'PageNumberSelector',
data() {
return {
nbPageToGo: null,
nbPageToGo: null as number|null,
};
},
methods: {
goToPage() {
this.$root.$emit('changePage', this.nbPageToGo);
this.$emit('changePage', this.nbPageToGo);
},
},
};
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
methods: {
onChangeLimit(limitChosen) {
this.selectedFilterQuantityToShow = limitChosen;
this.$root.$emit('changeLimit', Number(limitChosen));
this.$emit('changeLimit', Number(limitChosen));
},
},
Expand Down
17 changes: 11 additions & 6 deletions _dev/apps/ui/src/components/commons/table-page-controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
>
<ResultNumberSelector
:selected-filter-quantity-to-show="selectedFilterQuantityToShow"
@changeLimit="$emit('changeLimit', $event)"
/>

<nav
Expand All @@ -30,15 +31,19 @@
class="mb-0"
/>
</nav>
<PageNumberSelector v-if="needPageSelector" />
<PageNumberSelector
v-if="needPageSelector"
@changePage="goToPage($event)"
/>
</div>
</template>

<script>
<script lang="ts">
import {defineComponent} from 'vue';
import PageNumberSelector from './page-number-selector.vue';
import ResultNumberSelector from './result-number-selector.vue';
export default {
export default defineComponent({
name: 'TableControls',
components: {
PageNumberSelector,
Expand Down Expand Up @@ -66,11 +71,11 @@ export default {
},
},
methods: {
goToPage(page) {
goToPage(page: number) {
if (page > 0 && page <= this.totalPages) {
this.$root.$emit('changePage', page);
this.$emit('changePage', page);
}
},
},
};
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
:total-pages="totalPages"
:active-page="activePage+1"
:selected-filter-quantity-to-show="pageSize"
@changeLimit="pageChanged"
@changePage="limitChanged"
/>
</b-card-body>
</b-card>
Expand Down Expand Up @@ -212,12 +214,6 @@ export default defineComponent({
},
mounted() {
this.getIssues();
this.$root.$on('changePage', this.pageChanged);
this.$root.$on('changeLimit', this.limitChanged);
},
beforeDestroy() {
this.$root.$off('changePage', this.pageChanged);
this.$root.$off('changeLimit', this.limitChanged);
},
});
</script>

0 comments on commit 68d53f6

Please sign in to comment.