mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 12:25:16 +00:00
Retrieve group settings on the API
This commit is contained in:
@ -54,9 +54,12 @@ ComunicWeb.pages.groups.main = {
|
||||
}
|
||||
|
||||
//Check which page to open
|
||||
if(page == "group"){
|
||||
if(page == "group")
|
||||
ComunicWeb.pages.groups.pages.group.open(groupID, target);
|
||||
}
|
||||
|
||||
else if(page == "settings")
|
||||
ComunicWeb.pages.groups.pages.settings.open(groupID, target);
|
||||
|
||||
|
||||
//Unrecognized page
|
||||
else
|
||||
|
@ -21,7 +21,7 @@ ComunicWeb.pages.groups.pages.group = {
|
||||
if(result.error){
|
||||
|
||||
//Check the code of the error
|
||||
if(result.error.code == 404){
|
||||
if(result.error.code == 401){
|
||||
need_auth;//TODO : implement
|
||||
}
|
||||
|
||||
|
87
assets/js/pages/groups/pages/settings.js
Normal file
87
assets/js/pages/groups/pages/settings.js
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Page settings
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.pages.groups.pages.settings = {
|
||||
|
||||
/**
|
||||
* Open group settings page
|
||||
*
|
||||
* @param {Number} id The ID of the settings page
|
||||
* @param {HTMLElement} target The target of the page
|
||||
*/
|
||||
open: function(id, target){
|
||||
|
||||
//Create settings container
|
||||
var settingsContainer = createElem2({
|
||||
appendTo: target,
|
||||
type: "div",
|
||||
class: "group-settings-container col-md-6"
|
||||
});
|
||||
|
||||
//Add title
|
||||
createElem2({
|
||||
appendTo: settingsContainer,
|
||||
type: "h2",
|
||||
class: "title",
|
||||
innerHTML: "Group settings"
|
||||
});
|
||||
|
||||
//Display loading message
|
||||
var loadingMsg = ComunicWeb.common.messages.createCalloutElem(
|
||||
"Loading",
|
||||
"Please wait while we retrieve the settings of the page...",
|
||||
"info");
|
||||
settingsContainer.appendChild(loadingMsg);
|
||||
|
||||
//Get the settings of the page
|
||||
ComunicWeb.components.groups.interface.getSettings(id, function(result){
|
||||
|
||||
//Remove loading message
|
||||
loadingMsg.remove();
|
||||
|
||||
//Check for error
|
||||
if(result.error){
|
||||
|
||||
//Check if the user is not authorized to access the page
|
||||
if(result.error.code == 401){
|
||||
//The user is not authorized to see this page
|
||||
settingsContainer.appendChild(ComunicWeb.common.messages.createCalloutElem(
|
||||
"Access forbidden",
|
||||
"You are not authorized to access these information !",
|
||||
"danger"
|
||||
));
|
||||
}
|
||||
|
||||
//Else the page was not found
|
||||
else {
|
||||
settingsContainer.remove();
|
||||
ComunicWeb.common.error.pageNotFound({}, target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
//Display settings pages
|
||||
ComunicWeb.pages.groups.pages.settings.display(id, result, target);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Display page settings
|
||||
*
|
||||
* @param {Number} id The ID of the target page
|
||||
* @param {Object} settings The settings of the page
|
||||
* @param {HTMLElement} target The target of the page
|
||||
*/
|
||||
display: function(id, settings, target){
|
||||
|
||||
alert(settings);
|
||||
|
||||
},
|
||||
}
|
@ -71,6 +71,20 @@ ComunicWeb.pages.groups.sections.header = {
|
||||
type: "div",
|
||||
innerHTML: '<i class="fa fa-group"></i> '+ info.number_members+' members'
|
||||
});
|
||||
|
||||
//If the user is an admin, add a link to configure the page
|
||||
if(signed_in() && info.membership == "administrator"){
|
||||
|
||||
var settingsLink = createElem2({
|
||||
appendTo: secondColumn,
|
||||
type: "div",
|
||||
class: "a",
|
||||
innerHTML: " <i class='fa fa-gear'></i>Settings"
|
||||
});
|
||||
settingsLink.addEventListener("click", function(e){
|
||||
openPage("groups/" + info.id + "/settings");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
};
|
Reference in New Issue
Block a user