Refactor context => resourceType

@appinteractive `context` is probably the broadest term you can think
of. If possible avoid and prefer a descriptive name.
This commit is contained in:
Robert Schäfer 2019-03-10 13:36:44 +01:00
parent 3b7308c7ef
commit 0b9ad5c395
4 changed files with 19 additions and 18 deletions

View File

@ -55,7 +55,7 @@ export default {
itemId: { type: String, required: true }, itemId: { type: String, required: true },
name: { type: String, required: true }, name: { type: String, required: true },
isOwner: { type: Boolean, default: false }, isOwner: { type: Boolean, default: false },
context: { resourceType: {
type: String, type: String,
required: true, required: true,
validator: value => { validator: value => {
@ -67,7 +67,7 @@ export default {
routes() { routes() {
let routes = [] let routes = []
if (this.isOwner && this.context === 'contribution') { if (this.isOwner && this.resourceType === 'contribution') {
routes.push({ routes.push({
name: this.$t(`contribution.edit`), name: this.$t(`contribution.edit`),
path: this.$router.resolve({ path: this.$router.resolve({
@ -79,7 +79,7 @@ export default {
icon: 'edit' icon: 'edit'
}) })
} }
if (this.isOwner && this.context === 'comment') { if (this.isOwner && this.resourceType === 'comment') {
routes.push({ routes.push({
name: this.$t(`comment.edit`), name: this.$t(`comment.edit`),
callback: () => { callback: () => {
@ -91,21 +91,25 @@ export default {
if (!this.isOwner) { if (!this.isOwner) {
routes.push({ routes.push({
name: this.$t(`report.${this.context}.title`), name: this.$t(`report.${this.resourceType}.title`),
callback: this.openReportDialog, callback: () => {
this.openModal('report')
},
icon: 'flag' icon: 'flag'
}) })
} }
if (!this.isOwner && this.isModerator) { if (!this.isOwner && this.isModerator) {
routes.push({ routes.push({
name: this.$t(`disable.${this.context}.title`), name: this.$t(`disable.${this.resourceType}.title`),
callback: () => {}, callback: () => {
this.openModal('disable')
},
icon: 'eye-slash' icon: 'eye-slash'
}) })
} }
if (this.isOwner && this.context === 'user') { if (this.isOwner && this.resourceType === 'user') {
routes.push({ routes.push({
name: this.$t(`settings.data.name`), name: this.$t(`settings.data.name`),
// eslint-disable-next-line vue/no-side-effects-in-computed-properties // eslint-disable-next-line vue/no-side-effects-in-computed-properties
@ -128,18 +132,15 @@ export default {
} }
toggleMenu() toggleMenu()
}, },
openReportDialog() { openModal(dialog) {
this.$store.commit('modal/SET_OPEN', { this.$store.commit('modal/SET_OPEN', {
name: 'report', name: dialog,
data: { data: {
context: this.context, type: this.resourceType,
id: this.itemId, id: this.itemId,
name: this.name name: this.name
} }
}) })
},
openDisableDialog() {
this.$toast.error('NOT IMPLEMENTED!')
} }
} }
} }

View File

@ -52,7 +52,7 @@
</span> </span>
<no-ssr> <no-ssr>
<content-menu <content-menu
context="contribution" resource-type="contribution"
:item-id="post.id" :item-id="post.id"
:name="post.title" :name="post.title"
:is-owner="isAuthor" :is-owner="isAuthor"

View File

@ -13,7 +13,7 @@
<no-ssr> <no-ssr>
<content-menu <content-menu
placement="bottom-end" placement="bottom-end"
context="contribution" resource-type="contribution"
:item-id="post.id" :item-id="post.id"
:name="post.title" :name="post.title"
:is-owner="isAuthor(post.author.id)" :is-owner="isAuthor(post.author.id)"
@ -100,7 +100,7 @@
<no-ssr> <no-ssr>
<content-menu <content-menu
placement="bottom-end" placement="bottom-end"
context="comment" resource-type="comment"
style="float-right" style="float-right"
:item-id="comment.id" :item-id="comment.id"
:name="comment.author.name" :name="comment.author.name"

View File

@ -20,7 +20,7 @@
<no-ssr> <no-ssr>
<content-menu <content-menu
placement="bottom-end" placement="bottom-end"
context="user" resource-type="user"
:item-id="user.id" :item-id="user.id"
:name="user.name" :name="user.name"
:is-owner="myProfile" :is-owner="myProfile"