mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +00:00
Send a request to the server to cancel membership request.
This commit is contained in:
parent
561a3e9342
commit
89df9f0315
@ -6,128 +6,143 @@
|
|||||||
|
|
||||||
ComunicWeb.components.groups.interface = {
|
ComunicWeb.components.groups.interface = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a group
|
* Create a group
|
||||||
*
|
*
|
||||||
* @param {String} name The name of the group to create
|
* @param {String} name The name of the group to create
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
create: function(name, callback){
|
create: function(name, callback){
|
||||||
|
|
||||||
//Perform a request over the API
|
//Perform a request over the API
|
||||||
var apiURI = "groups/create";
|
var apiURI = "groups/create";
|
||||||
var params = {
|
var params = {
|
||||||
name: name
|
name: name
|
||||||
};
|
};
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about a group
|
* Get information about a group
|
||||||
*
|
*
|
||||||
* @param {Number} id The ID of the target group
|
* @param {Number} id The ID of the target group
|
||||||
* @param {Function} callback Callback
|
* @param {Function} callback Callback
|
||||||
*/
|
*/
|
||||||
getInfo: function(id, callback){
|
getInfo: function(id, callback){
|
||||||
//Perform the request over the API
|
//Perform the request over the API
|
||||||
var apiURI = "groups/get_info";
|
var apiURI = "groups/get_info";
|
||||||
var params = {
|
var params = {
|
||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get advanced information about a group
|
* Get advanced information about a group
|
||||||
*
|
*
|
||||||
* @param {Number} id The ID of the target group
|
* @param {Number} id The ID of the target group
|
||||||
* @param {Function} callback Callback
|
* @param {Function} callback Callback
|
||||||
*/
|
*/
|
||||||
getAdvancedInfo: function(id, callback){
|
getAdvancedInfo: function(id, callback){
|
||||||
//Perform the request over the API
|
//Perform the request over the API
|
||||||
var apiURI = "groups/get_advanced_info";
|
var apiURI = "groups/get_advanced_info";
|
||||||
var params = {
|
var params = {
|
||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the settings of a group
|
* Get the settings of a group
|
||||||
*
|
*
|
||||||
* @param {Number} id The ID of the target group
|
* @param {Number} id The ID of the target group
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
getSettings: function(id, callback){
|
getSettings: function(id, callback){
|
||||||
//Perform the request over the API
|
//Perform the request over the API
|
||||||
var apiURI = "groups/get_settings";
|
var apiURI = "groups/get_settings";
|
||||||
var params = {
|
var params = {
|
||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set (update) the settings of a group
|
* Set (update) the settings of a group
|
||||||
*
|
*
|
||||||
* @param {Number} id The ID of the target group
|
* @param {Number} id The ID of the target group
|
||||||
* @param {Object} settings The new settings to apply to
|
* @param {Object} settings The new settings to apply to
|
||||||
* the group
|
* the group
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
setSettings: function(id, settings, callback){
|
setSettings: function(id, settings, callback){
|
||||||
//Perform the request over the API
|
//Perform the request over the API
|
||||||
var apiURI = "groups/set_settings";
|
var apiURI = "groups/set_settings";
|
||||||
settings.id = id;
|
settings.id = id;
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, settings, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, settings, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload a new group logo
|
* Upload a new group logo
|
||||||
*
|
*
|
||||||
* @param {Number} id The ID of the target group
|
* @param {Number} id The ID of the target group
|
||||||
* @param {FormData} data The form data that contains the
|
* @param {FormData} data The form data that contains the
|
||||||
* new logo (parameter name : logo)
|
* new logo (parameter name : logo)
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
uploadLogo: function(id, data, callback){
|
uploadLogo: function(id, data, callback){
|
||||||
//Perform the request over the API
|
//Perform the request over the API
|
||||||
var apiURI = "groups/upload_logo";
|
var apiURI = "groups/upload_logo";
|
||||||
data.append("id", id);
|
data.append("id", id);
|
||||||
ComunicWeb.common.api.makeFormDatarequest(apiURI, data, true, callback);
|
ComunicWeb.common.api.makeFormDatarequest(apiURI, data, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete user logo
|
* Delete user logo
|
||||||
*
|
*
|
||||||
* @param {Number} id The ID of the target group
|
* @param {Number} id The ID of the target group
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
deleteLogo: function(id, callback){
|
deleteLogo: function(id, callback){
|
||||||
//Perform the request over the API
|
//Perform the request over the API
|
||||||
var apiURI = "groups/delete_logo";
|
var apiURI = "groups/delete_logo";
|
||||||
var params = {
|
var params = {
|
||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Respond to a group invitation
|
* Respond to a group invitation
|
||||||
*
|
*
|
||||||
* @param {Number} id The ID of the target group
|
* @param {Number} id The ID of the target group
|
||||||
* @param {Boolean} accept Specify whether the invitation was
|
* @param {Boolean} accept Specify whether the invitation was
|
||||||
* accepted or not
|
* accepted or not
|
||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
respondInvitation: function(id, accept, callback) {
|
respondInvitation: function(id, accept, callback) {
|
||||||
//Perform the request over the API
|
//Perform the request over the API
|
||||||
var apiURI = "groups/respond_invitation";
|
var apiURI = "groups/respond_invitation";
|
||||||
var params = {
|
var params = {
|
||||||
id: id,
|
id: id,
|
||||||
accept: accept
|
accept: accept
|
||||||
};
|
};
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel a membership request
|
||||||
|
*
|
||||||
|
* @param {Number} id The ID of the target group
|
||||||
|
* @param {Function} callback
|
||||||
|
*/
|
||||||
|
cancelRequest: function(id, callback){
|
||||||
|
//Perform the request over the API
|
||||||
|
var apiURI = "groups/cancel_request";
|
||||||
|
var params = {
|
||||||
|
id: id
|
||||||
|
};
|
||||||
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
@ -20,6 +20,24 @@ ComunicWeb.pages.groups.sections.membershipBlock = {
|
|||||||
type: "div"
|
type: "div"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh current component information
|
||||||
|
*/
|
||||||
|
refresh_component = function(){
|
||||||
|
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);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//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({
|
||||||
@ -75,6 +93,10 @@ ComunicWeb.pages.groups.sections.membershipBlock = {
|
|||||||
*/
|
*/
|
||||||
var respondInvitation = function(accept){
|
var respondInvitation = function(accept){
|
||||||
|
|
||||||
|
//Hide the buttons
|
||||||
|
acceptInvitation.style.visibility = "hidden";
|
||||||
|
rejectInvitation.style.visibility = "hidden";
|
||||||
|
|
||||||
//Perform the request over the server
|
//Perform the request over the server
|
||||||
ComunicWeb.components.groups.interface.respondInvitation(info.id, accept, function(result){
|
ComunicWeb.components.groups.interface.respondInvitation(info.id, accept, function(result){
|
||||||
|
|
||||||
@ -83,18 +105,7 @@ ComunicWeb.pages.groups.sections.membershipBlock = {
|
|||||||
notify("An error occurred while trying to respond to the invitation!", "danger");
|
notify("An error occurred while trying to respond to the invitation!", "danger");
|
||||||
|
|
||||||
//Refresh the component
|
//Refresh the component
|
||||||
emptyElem(container);
|
refresh_component();
|
||||||
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);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -118,6 +129,40 @@ ComunicWeb.pages.groups.sections.membershipBlock = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check if the user send a membership request
|
||||||
|
if(info.membership == "pending"){
|
||||||
|
|
||||||
|
var requestedContainer = createElem2({
|
||||||
|
appendTo: container,
|
||||||
|
type: "span",
|
||||||
|
innerHTML: "<i class='fa fa-clock-o'></i> Requested "
|
||||||
|
});
|
||||||
|
add_space(container);
|
||||||
|
|
||||||
|
//Add a link to cancel the request
|
||||||
|
var cancelLink = createElem2({
|
||||||
|
appendTo: requestedContainer,
|
||||||
|
type: "span",
|
||||||
|
class: "a",
|
||||||
|
innerHTML: "Cancel"
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelLink.addEventListener("click", function(e){
|
||||||
|
cancelLink.style.visibility = "hidden";
|
||||||
|
|
||||||
|
//Cancel the request
|
||||||
|
ComunicWeb.components.groups.interface.cancelRequest(info.id, function(result){
|
||||||
|
|
||||||
|
if(result.error)
|
||||||
|
notify("An error occurred while trying to cancel membership request!", "danger");
|
||||||
|
|
||||||
|
refresh_component();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user