mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Can update friends post authorization status.
This commit is contained in:
parent
d2240934a9
commit
6faa10c51a
@ -39,4 +39,8 @@
|
||||
.personnal-friends-list .friend .friends-actions {
|
||||
display: inline-block;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.personnal-friends-list .friend .friends-actions .btn {
|
||||
width: 100px;
|
||||
}
|
@ -65,6 +65,27 @@ ComunicWeb.components.friends.interface = {
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the posts text authorization status of a friend
|
||||
*
|
||||
* @param {number} friendID The ID of the target friend
|
||||
* @param {boolean} allow TRUE if the user can post texts / FALSE else
|
||||
* @param {function} callback
|
||||
*/
|
||||
set_can_post_texts: function(friendID, allow, callback){
|
||||
|
||||
//Prepare API request
|
||||
var apiURI = "friends/set_can_post_texts";
|
||||
var params = {
|
||||
friendID: friendID,
|
||||
allow: allow
|
||||
};
|
||||
|
||||
//Perform API request
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove a user from the friend list
|
||||
*
|
||||
|
@ -142,13 +142,12 @@ ComunicWeb.components.friends.ui = {
|
||||
followButton.setAttribute("data-set-following", "true");
|
||||
}
|
||||
else {
|
||||
followButton.innerHTML = "Following";
|
||||
followButton.innerHTML = "<i class='fa fa-check'></i> Following";
|
||||
followButton.setAttribute("data-set-following", "false");
|
||||
}
|
||||
|
||||
add_space(actionsOnFriendArea);
|
||||
|
||||
//Check if the user can post text on user page
|
||||
followButton.onclick = function(){
|
||||
|
||||
//Check if the request is to follow or not the user
|
||||
@ -170,6 +169,40 @@ ComunicWeb.components.friends.ui = {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//Check if the user can post text on user page
|
||||
var postTextsButton = createElem2({
|
||||
appendTo: actionsOnFriendArea,
|
||||
type: "button",
|
||||
class: "btn btn-primary"
|
||||
});
|
||||
|
||||
if(friend.canPostTexts){
|
||||
postTextsButton.innerHTML = "<i class='fa fa-check'></i> Post Texts";
|
||||
postTextsButton.setAttribute("data-allow-post-texts", "false");
|
||||
}
|
||||
else {
|
||||
postTextsButton.innerHTML = "Post Texts";
|
||||
postTextsButton.setAttribute("data-allow-post-texts", "true");
|
||||
}
|
||||
|
||||
//Make the button lives
|
||||
postTextsButton.onclick = function(){
|
||||
|
||||
//Check out if we have to allow or disallow texts post
|
||||
var allow_post = this.getAttribute("data-allow-post-texts") == "true";
|
||||
|
||||
//Update the status
|
||||
ComunicWeb.components.friends.interface.set_can_post_texts(friendID, allow_post, function(r){
|
||||
|
||||
if(r.error)
|
||||
ComunicWeb.common.notificationSystem.showNotification("Could not update posts creation status !", "danger");
|
||||
|
||||
//Update friendship informations
|
||||
ComunicWeb.components.friends.actions.refresh_single_personnal(friendID, friendContener);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user