Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated vue apis #1636

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion _dev/apps/ui/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ initialize({

// import showdown extension
import '../showdown.js';
import '../src/utils/Filters';

// app.scss all the styles for the module
import '../src/assets/scss/app.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$t('smartShoppingCampaignCreation.inputDurationLabel1')
}} </span><br>
<span class="text-secondary">
{{ newCampaign.startDate | timeConverterToDate }}
{{ startDate }}
</span>
</b-col>
<b-col
Expand Down Expand Up @@ -74,7 +74,7 @@
{{ $t('smartShoppingCampaignCreation.inputBudgetFeedback') }}
</dt>
<dd class="text-secondary mb-2">
{{ newCampaign.dailyBudget|formatPrice(newCampaign.currencyCode) }}
{{ dailyBudget }}
</dd>
</dl>
<p>
Expand Down Expand Up @@ -111,6 +111,8 @@ import PsModal from '@/components/commons/ps-modal.vue';
import SegmentGenericParams from '@/utils/SegmentGenericParams';
import compareYears from '@/utils/CompareYears';
import {changeCountryNameToCode} from '@/utils/Countries';
import {timeConverterToDate} from '@/utils/Dates';
import {formatPrice} from '@/utils/Price';

export default defineComponent({
name: 'SSCCreationPopinRecap',
Expand Down Expand Up @@ -149,16 +151,25 @@ export default defineComponent({
dimensionName() {
return this.$store.state.campaigns.dimensionChosen.name;
},
startDate(): string {
return timeConverterToDate(this.newCampaign.startDate);
},
endDate() {
if (this.newCampaign.endDate) {
const isThereAnEndDate = compareYears(this.newCampaign.endDate);

return isThereAnEndDate
? this.$options.filters.timeConverterToDate(this.newCampaign.endDate)
? timeConverterToDate(this.newCampaign.endDate)
: null;
}
return '-';
},
dailyBudget(): string {
return formatPrice(
this.newCampaign.dailyBudget,
this.newCampaign.currencyCode,
);
},
},

methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ export default defineComponent({
?.currencyCode;
},
currencySymbol(): string {
return this.$options.filters.formatPrice(0, this.currency).replace(/[\s.,0]*/g, '');
return formatPrice(0, this.currency).replace(/[\s.,0]*/g, '');
},
finalCampaignFilters() {
// IMPORTANT: Do not send the filters property if the campaign has unhandled filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ import CampaignStatus, {CampaignStatusToggle} from '@/enums/reporting/CampaignSt
import compareYears from '@/utils/CompareYears';
import {CampaignPerformanceObject, CampaignStatusPayload} from '@/store/modules/campaigns/state';
import {timeConverterToDate} from '@/utils/Dates';
import {formatPrice} from '../../utils/Price';
import {formatPrice} from '@/utils/Price';
import SegmentGenericParams from '@/utils/SegmentGenericParams';
import AlertLowBudget from './alert-low-budget.vue';
import {changeCountriesCodesToNames} from '@/utils/Countries';

export default defineComponent({
name: 'CampaignTableListRow',
Expand Down Expand Up @@ -130,7 +131,7 @@ export default defineComponent({
return this.$t('campaigns.dateLabel.from', {startDate: timeConverterToDate(this.campaign.startDate)});
},
campaignCountryName() {
return this.$options.filters.changeCountriesCodesToNames([this.campaign.targetCountry])[0];
return changeCountriesCodesToNames([this.campaign.targetCountry])[0];
},
currencyCode(): string {
return this.campaign.currencyCode || this.$store.getters['googleAds/GET_GOOGLE_ADS_ACCOUNT_CHOSEN']?.currencyCode;
Expand Down
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import KpiType from '@/enums/reporting/KpiType';
import ChartCanvas from '@/components/chart/chart-canvas.vue';
import {Kpis, DailyResultTypes} from '@/store/modules/campaigns/state';
import {timeConverterToDate} from '@/utils/Dates';
import {formatPrice} from '@/utils/Price';
import {externalTooltipHandler} from '@/utils/ChartTooltip';

const skipped = (
Expand Down Expand Up @@ -215,7 +216,7 @@ export default defineComponent({
|| type === KpiType.COSTS;
},
getFormattedValue(value: string|number|Point|null) {
return this.$options.filters.formatPrice(value, this.currencyCode);
return formatPrice(value, this.currencyCode);
},
},
});
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 @@ -209,6 +209,7 @@ import SelectCountry from '../commons/select-country.vue';
import SegmentGenericParams from '@/utils/SegmentGenericParams';
import {GoogleAccountContext} from '@/store/modules/accounts/state';
import BannerAds from '../commons/banner-ads.vue';
import {changeCountryCodeToName} from '@/utils/Countries';

export default defineComponent({
name: 'GoogleAdsAccountPopinNew',
Expand Down Expand Up @@ -261,13 +262,13 @@ export default defineComponent({
saveCountrySelected(value) {
this.newAccountInfos.country = value;
},
defaultCountry() {
defaultCountry(): string {
if (!this.$store.state.app.psxMtgWithGoogleDefaultShopCountry) {
return '';
}
return this.$options.filters.changeCountriesCodesToNames(
[this.$store.state.app.psxMtgWithGoogleDefaultShopCountry],
)[0];
return changeCountryCodeToName(
this.$store.state.app.psxMtgWithGoogleDefaultShopCountry,
);
},
},
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
</ul>
</template>

<script>
<script lang="ts">
import {
SyncHystoryType,
} from '@/enums/product-feed/sync-history.ts';
import {timeConverterToDate, timeConverterToHour} from '@/utils/Dates';

export default {
props: {
Expand Down Expand Up @@ -40,7 +41,7 @@ export default {
),
description: this.$i18n.t(
'productFeedPage.syncSummary.syncHistory.subtitle.happenedOnDate',
{date: this.$options.filters.timeConverterToDate(this.syncInfos.lastUpdatedAt)},
{date: timeConverterToDate(this.syncInfos.lastUpdatedAt)},
),
icon: 'change_circle',
},
Expand All @@ -56,8 +57,8 @@ export default {
),
description: this.$i18n.t(
'productFeedPage.syncSummary.syncHistory.subtitle.willHappenOnDate', [
this.$options.filters.timeConverterToDate(this.syncInfos.nextJobAt),
this.$options.filters.timeConverterToHour(this.syncInfos.nextJobAt),
timeConverterToDate(this.syncInfos.nextJobAt),
timeConverterToHour(this.syncInfos.nextJobAt),
]),
icon: 'schedule',
},
Expand All @@ -72,7 +73,7 @@ export default {
description: this.$i18n.t(
'productFeedPage.syncSummary.syncHistory.subtitle.happenedOnDate',
{
date: this.$options.filters.timeConverterToDate(
date: timeConverterToDate(
this.syncInfos.lastUpdatedAt ?? this.syncInfos.jobEndedAt,
),
},
Expand All @@ -86,9 +87,9 @@ export default {
),
description: this.$i18n.t(
'productFeedPage.syncSummary.syncHistory.subtitle.error', [
this.$options.filters.timeConverterToDate(this.syncInfos.lastUpdatedAt
timeConverterToDate(this.syncInfos.lastUpdatedAt
?? this.syncInfos.jobEndedAt),
this.$options.filters.timeConverterToHour(this.syncInfos.lastUpdatedAt
timeConverterToHour(this.syncInfos.lastUpdatedAt
?? this.syncInfos.jobEndedAt),
],
),
Expand All @@ -106,7 +107,7 @@ export default {
),
description: this.$i18n.t(
'productFeedPage.syncSummary.syncHistory.subtitle.happenedOnDate',
{date: this.$options.filters.timeConverterToDate(this.syncInfos.lastUpdatedAt)},
{date: timeConverterToDate(this.syncInfos.lastUpdatedAt)},
),
icon: 'check_circle',
lineColor: 'info',
Expand All @@ -117,7 +118,7 @@ export default {
),
description: this.$i18n.t(
'productFeedPage.syncSummary.syncHistory.subtitle.happenedOnDate',
{date: this.$options.filters.timeConverterToDate(this.syncInfos.jobEndedAt)},
{date: timeConverterToDate(this.syncInfos.jobEndedAt)},
),
icon: 'check_circle',
lineColor: 'info',
Expand All @@ -128,8 +129,8 @@ export default {
),
description: this.$i18n.t(
'productFeedPage.syncSummary.syncHistory.subtitle.willHappenOnDate', [
this.$options.filters.timeConverterToDate(this.syncInfos.nextJobAt),
this.$options.filters.timeConverterToHour(this.syncInfos.nextJobAt),
timeConverterToDate(this.syncInfos.nextJobAt),
timeConverterToHour(this.syncInfos.nextJobAt),
],

),
Expand Down
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>
Loading