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

View File

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

View File

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

View File

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