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

feat(prices): move owner & created info to a new History section #806

Merged
merged 3 commits into from
Sep 22, 2024
Merged
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
35 changes: 35 additions & 0 deletions src/components/HistoryCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<v-card :title="$t('Common.History')" data-name="history-card">
<v-card-text>
{{ getDateTimeFormatted(price.created) }} ({{ getRelativeDateTimeFormatted(price.created) }})
<span>- </span>
<a :href="getUserDetailUrl">{{ price.owner }}</a>
</v-card-text>
</v-card>
</template>

<script>
import utils from '../utils.js'

export default {
props: {
price: {
type: Object,
required: true
}
},
computed: {
getUserDetailUrl() {
return `/users/${this.price.owner}`
}
},
methods: {
getDateTimeFormatted(dateTimeString) {
return utils.offDateTime(dateTimeString)
},
getRelativeDateTimeFormatted(dateTimeString) {
return utils.prettyRelativeDateTime(dateTimeString, 'short')
},
}
}
</script>
4 changes: 0 additions & 4 deletions src/components/PriceFooterRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
<v-row style="margin-top:0;">
<v-col cols="11">
<LocationChip v-if="!hidePriceLocation" class="mr-1" :location="price.location" :locationId="price.location_id" :readonly="readonly" />
<UserChip class="mr-1" :username="price.owner" :readonly="readonly" />
<DateChip class="mr-1" :date="price.date" :readonly="readonly" />
<ProofChip v-if="price.proof && !hidePriceProof" class="mr-1" :proof="price.proof" />
<RelativeDateTimeChip :dateTime="price.created" />
</v-col>
</v-row>

Expand All @@ -18,10 +16,8 @@ import { defineAsyncComponent } from 'vue'
export default {
components: {
LocationChip: defineAsyncComponent(() => import('../components/LocationChip.vue')),
UserChip: defineAsyncComponent(() => import('../components/UserChip.vue')),
DateChip: defineAsyncComponent(() => import('../components/DateChip.vue')),
ProofChip: defineAsyncComponent(() => import('../components/ProofChip.vue')),
RelativeDateTimeChip: defineAsyncComponent(() => import('../components/RelativeDateTimeChip.vue')),
PriceActionMenuButton: defineAsyncComponent(() => import('../components/PriceActionMenuButton.vue')),
},
props: {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"FilterLocationWithPriceCountHide": "Hide locations with prices",
"FilterUserWithPriceCountHide": "Hide contributors with prices",
"Help": "Help",
"History": "History",
"Image": "Image",
"LinkCopySuccess": "Link copied",
"LocationCount": "{count} locations",
Expand Down
10 changes: 10 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ function prettyDateTime(dateTimeString) {
return new Intl.DateTimeFormat(navigator.language, {dateStyle: 'short', timeStyle: 'short'}).format(date)
}

/**
* input: '2023-12-25T17:08:19.021410+01:00'
* output: 'December 25, 2023, 8:19:02 CEST'
*/
function offDateTime(dateTimeString) {
const date = new Date(dateTimeString)
return new Intl.DateTimeFormat(navigator.language, {dateStyle: 'long', timeStyle: 'medium'}).format(date)
}

/**
* https://johnresig.com/blog/javascript-pretty-date/
* input: '2023-12-25T17:08:19.021410+01:00'
Expand Down Expand Up @@ -360,6 +369,7 @@ export default {
currentDate,
prettyDate,
prettyDateTime,
offDateTime,
prettyRelativeDateTime,
dateType,
getCategoryName,
Expand Down
10 changes: 8 additions & 2 deletions src/views/PriceDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<PriceCard v-if="price" :price="price" :product="price.product" />
</v-col>
</v-row>
<v-row v-if="price">
<v-col cols="12" sm="6">
<HistoryCard :price="price" />
</v-col>
</v-row>
</template>

<script>
Expand All @@ -12,7 +17,8 @@ import api from '../services/api'

export default {
components: {
PriceCard: defineAsyncComponent(() => import('../components/PriceCard.vue'))
PriceCard: defineAsyncComponent(() => import('../components/PriceCard.vue')),
HistoryCard: defineAsyncComponent(() => import('../components/HistoryCard.vue')),
},
data() {
return {
Expand All @@ -32,7 +38,7 @@ export default {
this.price = data
this.loading = false
})
}
},
}
}
</script>
Loading