From 1c75feae601b753f1dd30a15c49794c9de1a05fb Mon Sep 17 00:00:00 2001 From: Jiayi Zheng Date: Wed, 7 Dec 2016 21:50:46 +0100 Subject: Move delete button for status into a component --- src/components/delete_button/delete_button.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/components/delete_button/delete_button.js (limited to 'src/components/delete_button/delete_button.js') diff --git a/src/components/delete_button/delete_button.js b/src/components/delete_button/delete_button.js new file mode 100644 index 00000000..5f824899 --- /dev/null +++ b/src/components/delete_button/delete_button.js @@ -0,0 +1,16 @@ +const DeleteButton = { + props: [ 'status' ], + methods: { + deleteStatus () { + const confirmed = confirm('Do you really want to delete this status?') + if (confirmed) { + this.$store.dispatch('deleteStatus', { id: this.status.id }) + } + } + }, + computed: { + canDelete () { return this.status.user.rights.delete_others_notice || this.status.user.id == this.$store.state.users.currentUser.id } + } +} + +export default DeleteButton -- cgit v1.2.3-70-g09d2 From c24e44a8f22be1620b103b75ebd255cd610e143e Mon Sep 17 00:00:00 2001 From: Jiayi Zheng Date: Thu, 8 Dec 2016 20:26:05 +0100 Subject: Fixes user right check --- src/components/delete_button/delete_button.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/components/delete_button/delete_button.js') diff --git a/src/components/delete_button/delete_button.js b/src/components/delete_button/delete_button.js index 5f824899..990c32ad 100644 --- a/src/components/delete_button/delete_button.js +++ b/src/components/delete_button/delete_button.js @@ -9,7 +9,8 @@ const DeleteButton = { } }, computed: { - canDelete () { return this.status.user.rights.delete_others_notice || this.status.user.id == this.$store.state.users.currentUser.id } + currentUser () { return this.$store.state.users.currentUser }, + canDelete () { return this.currentUser.delete_others_notice || this.status.user.id == this.currentUser.id } } } -- cgit v1.2.3-70-g09d2 From d98f73092152734e5d3f7322b059232d08caae9b Mon Sep 17 00:00:00 2001 From: Jiayi Zheng Date: Mon, 19 Dec 2016 17:03:02 +0100 Subject: Fixes currentUser rights --- src/components/delete_button/delete_button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/delete_button/delete_button.js') diff --git a/src/components/delete_button/delete_button.js b/src/components/delete_button/delete_button.js index 990c32ad..726509d0 100644 --- a/src/components/delete_button/delete_button.js +++ b/src/components/delete_button/delete_button.js @@ -10,7 +10,7 @@ const DeleteButton = { }, computed: { currentUser () { return this.$store.state.users.currentUser }, - canDelete () { return this.currentUser.delete_others_notice || this.status.user.id == this.currentUser.id } + canDelete () { return this.currentUser.rights.delete_others_notice || this.status.user.id == this.currentUser.id } } } -- cgit v1.2.3-70-g09d2