mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Can respond to group invitations.
This commit is contained in:
parent
66392491b5
commit
561a3e9342
9
assets/css/pages/groups/sections/membershipBlock.css
Normal file
9
assets/css/pages/groups/sections/membershipBlock.css
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* Membership block stylesheet
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
|
||||||
|
.reject-group-invitation-link {
|
||||||
|
color: #f56954;
|
||||||
|
}
|
@ -112,4 +112,22 @@ ComunicWeb.components.groups.interface = {
|
|||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Respond to a group invitation
|
||||||
|
*
|
||||||
|
* @param {Number} id The ID of the target group
|
||||||
|
* @param {Boolean} accept Specify whether the invitation was
|
||||||
|
* accepted or not
|
||||||
|
* @param {Function} callback
|
||||||
|
*/
|
||||||
|
respondInvitation: function(id, accept, callback) {
|
||||||
|
//Perform the request over the API
|
||||||
|
var apiURI = "groups/respond_invitation";
|
||||||
|
var params = {
|
||||||
|
id: id,
|
||||||
|
accept: accept
|
||||||
|
};
|
||||||
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
@ -96,6 +96,6 @@ ComunicWeb.pages.groups.pages.forbidden = {
|
|||||||
|
|
||||||
//Append membership block (if the user is signed in)
|
//Append membership block (if the user is signed in)
|
||||||
if(signed_in())
|
if(signed_in())
|
||||||
ComunicWeb.pages.groups.sections.membershipBlock.display(result);
|
ComunicWeb.pages.groups.sections.membershipBlock.display(result, boxBody);
|
||||||
},
|
},
|
||||||
}
|
}
|
@ -6,42 +6,118 @@
|
|||||||
|
|
||||||
ComunicWeb.pages.groups.sections.membershipBlock = {
|
ComunicWeb.pages.groups.sections.membershipBlock = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display membership block
|
* Display membership block
|
||||||
*
|
*
|
||||||
* @param {Object} info Information about the membership
|
* @param {Object} info Information about the membership (= basic info about the group)
|
||||||
* @param {HTMLElement} target The target where the block will be applied
|
* @param {HTMLElement} target The target where the block will be applied
|
||||||
*/
|
*/
|
||||||
display: function(info, target){
|
display: function(info, target){
|
||||||
|
|
||||||
//Membership container
|
//Membership container
|
||||||
var container = createElem2({
|
var container = createElem2({
|
||||||
appendTo: target,
|
appendTo: target,
|
||||||
type: "div"
|
type: "div"
|
||||||
});
|
});
|
||||||
|
|
||||||
//Check if the user is an administrator / moderator / member
|
//Check if the user is an administrator / moderator / member
|
||||||
if(info.membership == "administrator")
|
if(info.membership == "administrator")
|
||||||
return createElem2({
|
return createElem2({
|
||||||
appendTo: container,
|
appendTo: container,
|
||||||
type: "span",
|
type: "span",
|
||||||
innerHTML: "<i class='fa fa-check'></i> Administrator"
|
innerHTML: "<i class='fa fa-check'></i> Administrator"
|
||||||
});
|
});
|
||||||
|
|
||||||
if(info.membership == "moderator")
|
if(info.membership == "moderator")
|
||||||
return createElem2({
|
return createElem2({
|
||||||
appendTo: container,
|
appendTo: container,
|
||||||
type: "span",
|
type: "span",
|
||||||
innerHTML: "<i class='fa fa-check'></i> Moderator"
|
innerHTML: "<i class='fa fa-check'></i> Moderator"
|
||||||
});
|
});
|
||||||
|
|
||||||
if(info.membership == "member")
|
if(info.membership == "member")
|
||||||
return createElem2({
|
return createElem2({
|
||||||
appendTo: container,
|
appendTo: container,
|
||||||
type: "span",
|
type: "span",
|
||||||
innerHTML: "<i class='fa fa-check'></i> Member"
|
innerHTML: "<i class='fa fa-check'></i> Member"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Check if the user has been invited
|
||||||
|
if(info.membership == "invited"){
|
||||||
|
var invitedContainer = createElem2({
|
||||||
|
appendTo: container,
|
||||||
|
type: "span",
|
||||||
|
innerHTML: "<i class='fa fa-question'></i> Invited "
|
||||||
|
});
|
||||||
|
|
||||||
}
|
//Offer the user to accept the invitation
|
||||||
|
var acceptInvitation = createElem2({
|
||||||
|
appendTo: invitedContainer,
|
||||||
|
type: "span",
|
||||||
|
class: "a",
|
||||||
|
innerHTML: "Accept"
|
||||||
|
});
|
||||||
|
|
||||||
|
add_space(invitedContainer);
|
||||||
|
|
||||||
|
//Offer the user to reject
|
||||||
|
var rejectInvitation = createElem2({
|
||||||
|
appendTo: invitedContainer,
|
||||||
|
type: "span",
|
||||||
|
class: "a reject-group-invitation-link",
|
||||||
|
innerHTML: "Reject"
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Respond to a group invitation
|
||||||
|
*
|
||||||
|
* @param {Boolean} accept Set whether the invation was accepted or not
|
||||||
|
*/
|
||||||
|
var respondInvitation = function(accept){
|
||||||
|
|
||||||
|
//Perform the request over the server
|
||||||
|
ComunicWeb.components.groups.interface.respondInvitation(info.id, accept, function(result){
|
||||||
|
|
||||||
|
//Check for errors
|
||||||
|
if(result.error)
|
||||||
|
notify("An error occurred while trying to respond to the invitation!", "danger");
|
||||||
|
|
||||||
|
//Refresh the component
|
||||||
|
emptyElem(container);
|
||||||
|
ComunicWeb.components.groups.interface.getInfo(info.id, function(result){
|
||||||
|
|
||||||
|
//Check for errors
|
||||||
|
if(result.error)
|
||||||
|
return notify("Could not refresh membership information!", "danger");
|
||||||
|
|
||||||
|
//Display the component again
|
||||||
|
ComunicWeb.pages.groups.sections.membershipBlock.display(result, container);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Accept invitation
|
||||||
|
acceptInvitation.addEventListener("click", function(e){
|
||||||
|
//Accept the invitation
|
||||||
|
respondInvitation(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
//Reject invitation
|
||||||
|
rejectInvitation.addEventListener("click", function(e){
|
||||||
|
|
||||||
|
ComunicWeb.common.messages.confirm("Do you really want to reject this invitation ?", function(r){
|
||||||
|
if(!r) return;
|
||||||
|
|
||||||
|
//Reject the invitation
|
||||||
|
respondInvitation(false);
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
@ -226,6 +226,7 @@ class Dev {
|
|||||||
|
|
||||||
//Groups sections
|
//Groups sections
|
||||||
"css/pages/groups/sections/header.css",
|
"css/pages/groups/sections/header.css",
|
||||||
|
"css/pages/groups/sections/membershipBlock.css",
|
||||||
|
|
||||||
|
|
||||||
//Settings page
|
//Settings page
|
||||||
|
Loading…
Reference in New Issue
Block a user