diff --git a/webapp/components/Comment.vue b/webapp/components/Comment.vue index 4796dd783..a20d49cf7 100644 --- a/webapp/components/Comment.vue +++ b/webapp/components/Comment.vue @@ -9,12 +9,14 @@ + @@ -47,6 +49,31 @@ export default { }, dateTime: { type: [Date, String], default: null }, }, + data() { + return { + menuModalsData: { + delete: { + titleIdent: 'delete.comment.title', + messageIdent: 'delete.comment.message', + messageParams: { + name: this.$filters.truncate(this.comment.contentExcerpt, 30), + }, + buttons: { + confirm: { + icon: 'trash', + textIdent: 'delete.submit', + callback: this.deleteCommentCallback, + }, + cancel: { + icon: 'close', + textIdent: 'delete.cancel', + callback: () => {}, + }, + }, + }, + }, + } + }, computed: { ...mapGetters({ user: 'auth/user', diff --git a/webapp/components/ContentMenu.vue b/webapp/components/ContentMenu.vue index 6b83b0bb9..935526867 100644 --- a/webapp/components/ContentMenu.vue +++ b/webapp/components/ContentMenu.vue @@ -43,7 +43,13 @@ export default { return value.match(/(contribution|comment|organization|user)/) }, }, - callbacks: { type: Object, required: true }, + modalsData: { + type: Object, + required: false, + // default: () => { + // return {} + // }, + }, }, computed: { routes() { @@ -145,7 +151,7 @@ export default { data: { type: this.resourceType, resource: this.resource, - callbacks: this.callbacks, + modalsData: this.modalsData, }, }) }, diff --git a/webapp/components/Modal.vue b/webapp/components/Modal.vue index 317b5007a..946e4de0e 100644 --- a/webapp/components/Modal.vue +++ b/webapp/components/Modal.vue @@ -6,7 +6,6 @@ :id="data.resource.id" :type="data.type" :name="name" - :callbacks="data.callbacks" @close="close" /> @@ -63,7 +61,7 @@ export default { switch (this.data.type) { case 'user': return name - case 'contribution': + case 'contribution': // REFACTORING: In DeleteModal – Already replaced "title" by "this.menuModalsData.delete.messageParams". return title case 'comment': return author && author.name diff --git a/webapp/components/Modal/DeleteModal.vue b/webapp/components/Modal/DeleteModal.vue index 63703b8c6..280407f5d 100644 --- a/webapp/components/Modal/DeleteModal.vue +++ b/webapp/components/Modal/DeleteModal.vue @@ -10,10 +10,18 @@

@@ -30,7 +38,7 @@ export default { props: { name: { type: String, default: '' }, type: { type: String, required: true }, - callbacks: { type: Object, required: true }, + modalData: { type: Object, required: true }, id: { type: String, required: true }, }, data() { @@ -42,18 +50,15 @@ export default { }, computed: { title() { - return this.$t(`delete.${this.type}.title`) + return this.$t(this.modalData.titleIdent) }, message() { - const name = this.$filters.truncate(this.name, 30) - return this.$t(`delete.${this.type}.message`, { name }) + return this.$t(this.modalData.messageIdent, this.modalData.messageParams) }, }, methods: { async cancel() { - if (this.callbacks.cancel) { - await this.callbacks.cancel() - } + await this.modalData.buttons.cancel.callback() this.isOpen = false setTimeout(() => { this.$emit('close') @@ -62,9 +67,7 @@ export default { async confirm() { this.loading = true try { - if (this.callbacks.confirm) { - await this.callbacks.confirm() - } + await this.modalData.buttons.confirm.callback() this.success = true setTimeout(() => { this.isOpen = false diff --git a/webapp/components/Modal/DisableModal.vue b/webapp/components/Modal/DisableModal.vue index 988ecc8af..df07ca924 100644 --- a/webapp/components/Modal/DisableModal.vue +++ b/webapp/components/Modal/DisableModal.vue @@ -21,7 +21,6 @@ export default { props: { name: { type: String, default: '' }, type: { type: String, required: true }, - callbacks: { type: Object, required: true }, id: { type: String, required: true }, }, data() { @@ -42,9 +41,8 @@ export default { }, methods: { async cancel() { - if (this.callbacks.cancel) { - await this.callbacks.cancel() - } + // TODO: Use the "modalData" structure introduced in "DeleteModal" and refactor this here. Be aware that all the Jest tests have to be refactored as well !!! + // await this.modalData.buttons.cancel.callback() this.isOpen = false setTimeout(() => { this.$emit('close') @@ -52,9 +50,8 @@ export default { }, async confirm() { try { - if (this.callbacks.confirm) { - await this.callbacks.confirm() - } + // TODO: Use the "modalData" structure introduced in "DeleteModal" and refactor this here. Be aware that all the Jest tests have to be refactored as well !!! + // await this.modalData.buttons.confirm.callback() await this.$apollo.mutate({ mutation: gql` mutation($id: ID!) { diff --git a/webapp/components/Modal/ReportModal.vue b/webapp/components/Modal/ReportModal.vue index f556c9e6e..882ed024a 100644 --- a/webapp/components/Modal/ReportModal.vue +++ b/webapp/components/Modal/ReportModal.vue @@ -10,9 +10,7 @@