mirror of
https://github.com/friendica/friendica
synced 2025-04-25 13:10:11 +00:00
Improve contactgroupChangeMember() javascript function
- Add usage of new /group/123/add|remove/123 URL - Add checkbox revert in case of error
This commit is contained in:
parent
6376293218
commit
0a58e4c952
4 changed files with 20 additions and 6 deletions
|
@ -793,11 +793,25 @@ function profChangeMember(gid,cid) {
|
|||
});
|
||||
}
|
||||
|
||||
function contactgroupChangeMember(gid,cid) {
|
||||
function contactgroupChangeMember(checkbox, gid, cid) {
|
||||
let url;
|
||||
// checkbox.checked is the checkbox state after the click
|
||||
if (checkbox.checked) {
|
||||
url = 'group/' + gid + '/add/' + cid;
|
||||
} else {
|
||||
url = 'group/' + gid + '/remove/' + cid;
|
||||
}
|
||||
$('body').css('cursor', 'wait');
|
||||
$.get('contactgroup/' + gid + '/' + cid, function(data) {
|
||||
$('body').css('cursor', 'auto');
|
||||
$.post(url)
|
||||
.error(function () {
|
||||
// Restores previous state in case of error
|
||||
checkbox.checked = !checkbox.checked;
|
||||
})
|
||||
.always(function() {
|
||||
$('body').css('cursor', 'auto');
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkboxhighlight(box) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue