Can send a request on the API to delete group logo.

This commit is contained in:
Pierre HUBERT 2018-07-04 14:07:16 +02:00
parent eb69734a38
commit 1d92a5bf1c
3 changed files with 55 additions and 1 deletions

View File

@ -27,5 +27,6 @@
.group-settings-container .group-logo-settings-img { .group-settings-container .group-logo-settings-img {
width: 150px; width: 150px;
margin: auto; margin: auto;
margin-bottom: 10px;
display: block; display: block;
} }

View File

@ -95,6 +95,21 @@ ComunicWeb.components.groups.interface = {
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
*
* @param {Number} id The ID of the target group
* @param {Function} callback
*/
deleteLogo: function(id, callback){
//Perform the request over the API
var apiURI = "groups/delete_logo";
var params = {
id: id
};
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
},
}; };

View File

@ -192,6 +192,7 @@ ComunicWeb.pages.groups.pages.settings = {
src: settings.icon_url src: settings.icon_url
}); });
//Add a button to update the group logo //Add a button to update the group logo
var updateGroupLogoLabel = createElem2({ var updateGroupLogoLabel = createElem2({
appendTo: groupLogoSettingsContainer, appendTo: groupLogoSettingsContainer,
@ -236,5 +237,42 @@ ComunicWeb.pages.groups.pages.settings = {
}); });
}); });
//Add a button to delete the account image
add_space(groupLogoSettingsContainer);
var deleteLogoBtn = createElem2({
appendTo: groupLogoSettingsContainer,
type: "div",
class: "btn btn-sm btn-danger",
innerHTML: "Delete logo"
});
deleteLogoBtn.addEventListener("click", function(e){
//Ask user confirmation
ComunicWeb.common.messages.confirm("Do you really want to delete group logo ? This operation can not be reverted !", function(c){
//Check if the user rejected the request
if(!c) return;
//Forward the request on the server
ComunicWeb.components.groups.interface.deleteLogo(id, function(result){
//Check for errors
if(result.error)
return notify("An error occurred while trying to delete group logo!", "danger");
//Success
notify("The group logo has been successfully deleted!", "success");
//Apply new group logo
groupLogo.src = result.url;
});
});
});
}, },
} }