mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Added Content Menu and Report Modal
This commit is contained in:
parent
cd83d35dc7
commit
01ad6a9822
104
components/ContentMenu.vue
Normal file
104
components/ContentMenu.vue
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<template>
|
||||||
|
<dropdown
|
||||||
|
class="post-menu"
|
||||||
|
:placement="placement"
|
||||||
|
offset="5"
|
||||||
|
>
|
||||||
|
<template
|
||||||
|
slot="default"
|
||||||
|
slot-scope="{toggleMenu}"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
class="post-menu-trigger"
|
||||||
|
href="#"
|
||||||
|
@click.prevent="toggleMenu()"
|
||||||
|
>
|
||||||
|
<ds-icon
|
||||||
|
v-if="placement.indexOf('top') === 0"
|
||||||
|
name="angle-up"
|
||||||
|
/>
|
||||||
|
<ds-icon
|
||||||
|
v-else
|
||||||
|
name="angle-down"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
|
<template
|
||||||
|
slot="popover"
|
||||||
|
slot-scope="{toggleMenu}"
|
||||||
|
>
|
||||||
|
<div class="post-menu-popover">
|
||||||
|
<ds-menu :routes="routes">
|
||||||
|
<ds-menu-item
|
||||||
|
slot="Navigation"
|
||||||
|
slot-scope="item"
|
||||||
|
:route="item.route"
|
||||||
|
:parents="item.parents"
|
||||||
|
@click.stop.prevent="openItem(item.route, toggleMenu)"
|
||||||
|
>
|
||||||
|
<ds-icon :name="item.route.icon" /> {{ item.route.name }}
|
||||||
|
</ds-menu-item>
|
||||||
|
</ds-menu>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Dropdown from '~/components/Dropdown'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
Dropdown
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
placement: { type: String, default: 'top-end' },
|
||||||
|
name: { type: String, required: true },
|
||||||
|
context: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
validator: value => {
|
||||||
|
return value.match(/(contribution|comment|organization|user)/)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
routes() {
|
||||||
|
let routes = [
|
||||||
|
{
|
||||||
|
name: this.$t('common.reportContent'),
|
||||||
|
callback: this.openReportDialog,
|
||||||
|
icon: 'flag'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
// if (this.isAdmin) {
|
||||||
|
// routes.push({
|
||||||
|
// name: this.$t('admin.name'),
|
||||||
|
// path: `/admin`,
|
||||||
|
// icon: 'shield'
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
return routes
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
openItem(route, toggleMenu) {
|
||||||
|
if (route.callback) {
|
||||||
|
route.callback()
|
||||||
|
} else {
|
||||||
|
this.$router.push(route.path)
|
||||||
|
}
|
||||||
|
toggleMenu()
|
||||||
|
},
|
||||||
|
openReportDialog() {
|
||||||
|
this.$store.commit('modal/SET_OPEN', {
|
||||||
|
name: 'report',
|
||||||
|
data: {
|
||||||
|
context: this.context,
|
||||||
|
name: this.name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -51,41 +51,10 @@
|
|||||||
<ds-icon name="comments" /> <small>{{ post.commentsCount }}</small>
|
<ds-icon name="comments" /> <small>{{ post.commentsCount }}</small>
|
||||||
</span>
|
</span>
|
||||||
<no-ssr>
|
<no-ssr>
|
||||||
<dropdown
|
<content-menu
|
||||||
class="post-menu"
|
context="contribution"
|
||||||
placement="top-end"
|
:name="post.title"
|
||||||
>
|
/>
|
||||||
<template
|
|
||||||
slot="default"
|
|
||||||
slot-scope="{toggleMenu}"
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
class="post-menu-trigger"
|
|
||||||
href="#"
|
|
||||||
@click.prevent="toggleMenu()"
|
|
||||||
>
|
|
||||||
<ds-icon name="angle-up" />
|
|
||||||
</a>
|
|
||||||
</template>
|
|
||||||
<template
|
|
||||||
slot="popover"
|
|
||||||
slot-scope="{toggleMenu}"
|
|
||||||
>
|
|
||||||
<div class="post-menu-popover">
|
|
||||||
<ds-menu :routes="routes">
|
|
||||||
<ds-menu-item
|
|
||||||
slot="Navigation"
|
|
||||||
slot-scope="item"
|
|
||||||
:route="item.route"
|
|
||||||
:parents="item.parents"
|
|
||||||
@click.native="toggleMenu"
|
|
||||||
>
|
|
||||||
<ds-icon :name="item.route.icon" /> {{ item.route.name }}
|
|
||||||
</ds-menu-item>
|
|
||||||
</ds-menu>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</dropdown>
|
|
||||||
</no-ssr>
|
</no-ssr>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -94,14 +63,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HcAuthor from '~/components/Author.vue'
|
import HcAuthor from '~/components/Author.vue'
|
||||||
import Dropdown from '~/components/Dropdown'
|
import ContentMenu from '~/components/ContentMenu'
|
||||||
import { randomBytes } from 'crypto'
|
import { randomBytes } from 'crypto'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'HcPostCard',
|
name: 'HcPostCard',
|
||||||
components: {
|
components: {
|
||||||
HcAuthor,
|
HcAuthor,
|
||||||
Dropdown
|
ContentMenu
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
post: {
|
post: {
|
||||||
@ -123,23 +92,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return excerpt
|
return excerpt
|
||||||
},
|
|
||||||
routes() {
|
|
||||||
let routes = [
|
|
||||||
{
|
|
||||||
name: this.$t('common.reportContent'),
|
|
||||||
path: `/profile/`,
|
|
||||||
icon: 'flag'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
// if (this.isAdmin) {
|
|
||||||
// routes.push({
|
|
||||||
// name: this.$t('admin.name'),
|
|
||||||
// path: `/admin`,
|
|
||||||
// icon: 'shield'
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
return routes
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
32
components/ReportModal.vue
Normal file
32
components/ReportModal.vue
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<template>
|
||||||
|
<ds-modal
|
||||||
|
:title="title"
|
||||||
|
:is-open="isOpen"
|
||||||
|
cancel-label="Cancel"
|
||||||
|
confirm-label="Send Report"
|
||||||
|
@close="close"
|
||||||
|
>
|
||||||
|
<p>Are you sure that you want to report the {{ data.context }} "<b>{{ data.name | truncate(30) }}</b>"?</p>
|
||||||
|
</ds-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
computed: {
|
||||||
|
data() {
|
||||||
|
return this.$store.getters['modal/data'] || {}
|
||||||
|
},
|
||||||
|
title() {
|
||||||
|
return `Report ${this.data.context}`
|
||||||
|
},
|
||||||
|
isOpen() {
|
||||||
|
return this.$store.getters['modal/open'] === 'report'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
close() {
|
||||||
|
this.$store.commit('modal/SET_OPEN', {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -72,6 +72,10 @@
|
|||||||
<nuxt />
|
<nuxt />
|
||||||
</div>
|
</div>
|
||||||
</ds-container>
|
</ds-container>
|
||||||
|
<report-modal />
|
||||||
|
<no-ssr>
|
||||||
|
<portal-target name="modal" />
|
||||||
|
</no-ssr>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -79,11 +83,13 @@
|
|||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import LocaleSwitch from '~/components/LocaleSwitch'
|
import LocaleSwitch from '~/components/LocaleSwitch'
|
||||||
import Dropdown from '~/components/Dropdown'
|
import Dropdown from '~/components/Dropdown'
|
||||||
|
import ReportModal from '~/components/ReportModal'
|
||||||
import seo from '~/components/mixins/seo'
|
import seo from '~/components/mixins/seo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Dropdown,
|
Dropdown,
|
||||||
|
ReportModal,
|
||||||
LocaleSwitch
|
LocaleSwitch
|
||||||
},
|
},
|
||||||
mixins: [seo],
|
mixins: [seo],
|
||||||
|
|||||||
@ -6,6 +6,14 @@
|
|||||||
class="post-card"
|
class="post-card"
|
||||||
>
|
>
|
||||||
<hc-author :post="post" />
|
<hc-author :post="post" />
|
||||||
|
<no-ssr>
|
||||||
|
<content-menu
|
||||||
|
style="float: right; display: inline-block; margin-top: -5rem;"
|
||||||
|
placement="bottom-end"
|
||||||
|
context="contribution"
|
||||||
|
:name="post.title"
|
||||||
|
/>
|
||||||
|
</no-ssr>
|
||||||
<ds-space margin-bottom="small" />
|
<ds-space margin-bottom="small" />
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<!-- eslint-disable vue/no-v-html -->
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
@ -112,6 +120,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
import ContentMenu from '~/components/ContentMenu'
|
||||||
import HcAuthor from '~/components/Author.vue'
|
import HcAuthor from '~/components/Author.vue'
|
||||||
import HcShoutButton from '~/components/ShoutButton.vue'
|
import HcShoutButton from '~/components/ShoutButton.vue'
|
||||||
|
|
||||||
@ -122,7 +131,8 @@ export default {
|
|||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
HcAuthor,
|
HcAuthor,
|
||||||
HcShoutButton
|
HcShoutButton,
|
||||||
|
ContentMenu
|
||||||
},
|
},
|
||||||
head() {
|
head() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -17,6 +17,14 @@
|
|||||||
class="profile-avatar"
|
class="profile-avatar"
|
||||||
size="120px"
|
size="120px"
|
||||||
/>
|
/>
|
||||||
|
<no-ssr>
|
||||||
|
<content-menu
|
||||||
|
style="float: right; display: inline-block; margin-top: -3.5rem; margin-right: -0.5rem;"
|
||||||
|
placement="bottom-start"
|
||||||
|
context="user"
|
||||||
|
:name="user.name"
|
||||||
|
/>
|
||||||
|
</no-ssr>
|
||||||
<ds-space margin="small">
|
<ds-space margin="small">
|
||||||
<ds-heading
|
<ds-heading
|
||||||
tag="h3"
|
tag="h3"
|
||||||
@ -251,6 +259,7 @@ import HcFollowButton from '~/components/FollowButton.vue'
|
|||||||
import HcCountTo from '~/components/CountTo.vue'
|
import HcCountTo from '~/components/CountTo.vue'
|
||||||
import HcBadges from '~/components/Badges.vue'
|
import HcBadges from '~/components/Badges.vue'
|
||||||
import HcLoadMore from '~/components/LoadMore.vue'
|
import HcLoadMore from '~/components/LoadMore.vue'
|
||||||
|
import ContentMenu from '~/components/ContentMenu'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -259,7 +268,8 @@ export default {
|
|||||||
HcFollowButton,
|
HcFollowButton,
|
||||||
HcCountTo,
|
HcCountTo,
|
||||||
HcBadges,
|
HcBadges,
|
||||||
HcLoadMore
|
HcLoadMore,
|
||||||
|
ContentMenu
|
||||||
},
|
},
|
||||||
transition: {
|
transition: {
|
||||||
name: 'slide-up',
|
name: 'slide-up',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user