Can update friends post authorization status.

This commit is contained in:
Pierre 2018-03-11 16:46:18 +01:00
parent d2240934a9
commit 6faa10c51a
3 changed files with 60 additions and 2 deletions

View File

@ -40,3 +40,7 @@
display: inline-block;
width: 250px;
}
.personnal-friends-list .friend .friends-actions .btn {
width: 100px;
}

View File

@ -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
*

View File

@ -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);
});
}
}