osb/spark/resources/assets/js/settings/teams/pending-invitations.js

68 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-11-03 05:26:07 +00:00
module.exports = {
/**
* The component's data.
*/
data() {
return {
invitations: []
};
},
/**
* The component has been created by Vue.
*/
created() {
this.getPendingInvitations();
},
methods: {
/**
* Get the pending invitations for the user.
*/
getPendingInvitations() {
axios.get('/settings/invitations/pending')
.then(response => {
this.invitations = response.data;
});
},
/**
* Accept the given invitation.
*/
accept(invitation) {
axios.post(`/settings/invitations/${invitation.id}/accept`)
.then(() => {
Bus.$emit('updateTeams');
this.getPendingInvitations();
});
this.removeInvitation(invitation);
},
/**
* Reject the given invitation.
*/
reject(invitation) {
axios.post(`/settings/invitations/${invitation.id}/reject`)
.then(() => {
this.getPendingInvitations();
});
this.removeInvitation(invitation);
},
/**
* Remove the given invitation from the list.
*/
removeInvitation(invitation) {
this.invitations = _.reject(this.invitations, i => i.id === invitation.id);
}
}
};