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: #2648 outings view count #3816

Draft
wants to merge 2 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
14 changes: 14 additions & 0 deletions src/components/generics/icons/IconViewCount.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<fa-icon icon="eye" :fixed-width="fixedWidth" />
</template>

<script>
export default {
props: {
fixedWidth: {
type: Boolean,
default: false,
},
},
};
</script>
2 changes: 2 additions & 0 deletions src/js/constants/documentsProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@
{ "id": "date_start", "properties": { "url": "date", "required": false } },
{ "id": "dates", "properties": { "url": "date", "required": false } },
{ "id": "disable_comments" },
{ "id": "disable_view_count" },
{ "id": "view_count" },
{ "id": "elevation_access", "properties": { "url": "oparka" } },
{
"id": "elevation_down_snow",
Expand Down
7 changes: 7 additions & 0 deletions src/js/constants/fieldsProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@
"type": "boolean",
"default": false
},
"disable_view_count": {
"type": "boolean",
"default": false
},
"view_count": {
"type": "number"
},
"durations": {
"values": "route_duration_types",
"multiple": true,
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@
},
"difficulties_height": "Difficulties start altitude",
"disable_comments": "Disable comments",
"disable_view_count": "Disable view count",
"view_count": "views",
"durations": "Durations",
"durations (days)": "duration (days)",
"easy": {
Expand Down
2 changes: 2 additions & 0 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@
},
"difficulties_height": "Altitude du début des difficultés",
"disable_comments": "Désactiver les commentaires",
"disable_view_count": "Désactiver le compteur de vues",
"view_count": "vues",
"draft": {
"quality_types": "ébauche"
},
Expand Down
23 changes: 22 additions & 1 deletion src/views/document/utils/boxes/ToolBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
<span>{{ quality.i18nName }}</span> {{ quality.i18nValue }}
</div>

<div class="view-count" v-if="viewCount">
<icon-view-count fixed-width></icon-view-count>
{{ viewCount.value }} <span>{{ viewCount.i18nName }}</span>
</div>

<tool-box-button
v-if="isEditable"
:to="{ name: documentType + '-edit', params: { id: document.document_id, lang: lang } }"
Expand Down Expand Up @@ -177,6 +182,7 @@

<script>
import IconQuality from '../../../../components/generics/icons/IconQuality.vue';
import IconViewCount from '../../../../components/generics/icons/IconViewCount.vue';
import DeleteDocumentWindow from '../windows/DeleteDocumentWindow';
import DeleteLocaleWindow from '../windows/DeleteLocaleWindow';
import MergeDocumentWindow from '../windows/MergeDocumentWindow';
Expand All @@ -203,6 +209,7 @@ export default {
LicenseBox,
AssociatedDocuments,
IconQuality,
IconViewCount,
AssociationsWindow,
DeleteLocaleWindow,
DeleteDocumentWindow,
Expand Down Expand Up @@ -269,6 +276,20 @@ export default {
};
},

viewCount() {
const fields = constants.objectDefinitions[this.documentType].fields;
const value = this.document[fields.view_count.name];
const isValue = value !== null && value !== undefined;
if (!fields.view_count || !isValue) {
return;
}
return {
...fields.view_count,
value,
i18nName: this.$gettext(fields.view_count.name),
};
},

fundraiser() {
return getFundraiser(this.document);
},
Expand Down Expand Up @@ -418,7 +439,7 @@ export default {
content: ' \2022 '; /* \2022 is bull */
}

.quality {
.quality .view-count {
span:nth-of-type(1) {
@include colon;
}
Expand Down
3 changes: 3 additions & 0 deletions src/views/wiki/edition/OutingEditionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
/>
<form-field :document="document" :field="fields.disable_comments" />
</div>
<div class="columns">
<form-field :document="document" :field="fields.disable_view_count" />
</div>
</form-section>

<form-section
Expand Down
Loading