Skip to content

Commit

Permalink
fix: fix page scroll bug in CostReportDetailPage & change currencyMon…
Browse files Browse the repository at this point in the history
…eyFormatter option (#3046)

* fix: fix page scroll bug in CostReportDetailPage

* feat: fix options of numberFormatterOption

* fix: remove min-height of DataTable
  • Loading branch information
sulmoJ authored Jan 30, 2024
1 parent 330790c commit a2bf878
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions apps/web/src/common/pages/CostReportDetailPage.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script setup lang="ts">
import type { ComputedRef } from 'vue';
import {
computed, reactive, ref,
} from 'vue';
import { computed, reactive, ref } from 'vue';
import { useRouter } from 'vue-router/composables';
import { PLink, PDataTable } from '@spaceone/design-system';
Expand Down Expand Up @@ -66,7 +64,10 @@ interface State {
totalCost: ComputedRef<number>;
data?: AnalyzeResponse<CostReportDataAnalyzeResult>|undefined;
chartData: ComputedRef<ChartData[]>;
numberFormatterOption: ComputedRef<Intl.NumberFormatOptions>;
}
const props = withDefaults(defineProps<Props>(), {
accessToken: undefined,
costReportId: undefined,
Expand Down Expand Up @@ -101,6 +102,7 @@ const state = reactive<State>({
fill: storeState.providers[d.provider]?.color,
},
})) ?? []),
numberFormatterOption: computed(() => ({ currency: state.currency, style: 'decimal', notation: 'standard' })),
});
const originDataState = reactive({
Expand Down Expand Up @@ -358,17 +360,20 @@ const setMetaTag = () => {
const viewportEl = document.querySelector('head meta[name="viewport"]');
if (viewportEl) viewportEl.attributes.content.value = 'width=928';
};
const setBodyTag = () => {
const setRootTagStyle = () => {
const htmlEl = document.querySelector('html');
const bodyEl = document.querySelector('body');
const appEl = document.querySelector('#app');
if (bodyEl) bodyEl.style.height = 'auto';
if (appEl) appEl.style.height = 'auto';
if (htmlEl) {
htmlEl.style.height = 'unset';
htmlEl.style.overflow = 'auto';
}
if (bodyEl) bodyEl.style.height = 'unset';
if (appEl) appEl.style.height = 'unset';
};
(async () => {
state.loading = true;
setMetaTag();
setBodyTag();
const isSucceeded = await initStatesByUrlSSOToken();
if (!isSucceeded) return;
await fetchReportData();
Expand All @@ -386,6 +391,8 @@ const setBodyTag = () => {
await setI18nLocale(props.language);
state.loading = false;
drawChart();
setMetaTag();
setRootTagStyle();
})();
</script>
Expand Down Expand Up @@ -423,7 +430,7 @@ const setBodyTag = () => {
<div class="total-value-wrapper">
<div class="total-cost">
<span class="currency-symbol">{{ CURRENCY_SYMBOL[state.currency] }}</span>
<span class="total-text">{{ currencyMoneyFormatter(state.totalCost, {currency:state.currency, style: 'decimal'}) }}</span>
<span class="total-text">{{ currencyMoneyFormatter(state.totalCost, state.numberFormatterOption) }}</span>
</div>
<div class="currency-value">
{{ state.currency }}
Expand Down Expand Up @@ -487,7 +494,7 @@ const setBodyTag = () => {
</div>
</template>
<template #col-amount-format="{value}">
{{ currencyMoneyFormatter(value, {currency:state.currency, style: 'decimal'}) }}
{{ currencyMoneyFormatter(value, state.numberFormatterOption) }}
</template>
</p-data-table>
</div>
Expand All @@ -502,7 +509,7 @@ const setBodyTag = () => {
:key="idx"
>
<table-header :title="storeState.providers[provider]?.label"
:sub-total="currencyMoneyFormatter(tableState.costByProductData[provider].subtotal, {currency:state.currency, style: 'decimal'})"
:sub-total="currencyMoneyFormatter(tableState.costByProductData[provider].subtotal, state.numberFormatterOption)"
:provider-icon-src="storeState.providers[provider]?.icon"
/>
<p-data-table :fields="tableState.costByProductFields"
Expand All @@ -515,7 +522,7 @@ const setBodyTag = () => {
class="budget-summary-table"
>
<template #col-amount-format="{value}">
{{ currencyMoneyFormatter(value, {currency:state.currency, style: 'decimal'}) }}
{{ currencyMoneyFormatter(value, state.numberFormatterOption) }}
</template>
</p-data-table>
</div>
Expand All @@ -533,7 +540,7 @@ const setBodyTag = () => {
:disable-hover="true"
>
<template #col-amount-format="{value}">
{{ currencyMoneyFormatter(value, {currency:state.currency, style: 'decimal'}) }}
{{ currencyMoneyFormatter(value, state.numberFormatterOption) }}
</template>
</p-data-table>
</div>
Expand All @@ -547,7 +554,7 @@ const setBodyTag = () => {
:key="idx"
>
<table-header :title="provider"
:sub-total="currencyMoneyFormatter(tableState.costByServiceAccountData[provider]?.subtotal, {currency:state.currency, style: 'decimal'})"
:sub-total="currencyMoneyFormatter(tableState.costByServiceAccountData[provider]?.subtotal,state.numberFormatterOption)"
:provider="storeState.providers[provider]?.label"
:provider-icon-src="storeState.providers[provider]?.icon"
/>
Expand All @@ -561,7 +568,7 @@ const setBodyTag = () => {
class="budget-summary-table"
>
<template #col-amount-format="{value}">
{{ currencyMoneyFormatter(value, {currency:state.currency, style: 'decimal'}) }}
{{ currencyMoneyFormatter(value, state.numberFormatterOption) }}
</template>
</p-data-table>
</div>
Expand All @@ -576,6 +583,13 @@ const setBodyTag = () => {
margin-bottom: 0.75rem;
}

/* custom design-system component - p-data-table */
:deep() {
.p-data-table {
min-height: unset;
}
}

.body {
@apply flex justify-center bg-white;
font-size: 0.9625rem;
Expand Down

0 comments on commit a2bf878

Please sign in to comment.