From d0812e2d85dfa92db6ab514f02fbb16bed676d29 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 15 Mar 2021 16:43:40 +0100 Subject: [PATCH] Can respond to group invitation from sidebar --- assets/css/components/sidebar.css | 11 ++++++++++ assets/js/components/groups/interface.js | 6 ++++-- assets/js/components/sidebar/main.js | 26 +++++++++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/assets/css/components/sidebar.css b/assets/css/components/sidebar.css index fc2ad351..f1e5dd41 100644 --- a/assets/css/components/sidebar.css +++ b/assets/css/components/sidebar.css @@ -104,6 +104,17 @@ body.sidebar-collapse .main-sidebar .memberships-list li:hover .subinfo { } +.main-sidebar .memberships-list .btn-xs { + padding-top: 0px; + padding-bottom: 0px; + height: 1.35em; + width: 3em; + line-height: 1; + display: inline-flex; + align-items: center; + justify-content: center; +} + /** * Conversations entries */ diff --git a/assets/js/components/groups/interface.js b/assets/js/components/groups/interface.js index 65bb1344..7ca30c31 100644 --- a/assets/js/components/groups/interface.js +++ b/assets/js/components/groups/interface.js @@ -4,7 +4,7 @@ * @author Pierre HUBERT */ -ComunicWeb.components.groups.interface = { +const GroupsInterface = { /** * Create a group @@ -373,4 +373,6 @@ ComunicWeb.components.groups.interface = { }; ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); } -}; \ No newline at end of file +}; + +ComunicWeb.components.groups.interface = GroupsInterface; \ No newline at end of file diff --git a/assets/js/components/sidebar/main.js b/assets/js/components/sidebar/main.js index 48865dab..7ef15dad 100644 --- a/assets/js/components/sidebar/main.js +++ b/assets/js/components/sidebar/main.js @@ -519,8 +519,32 @@ const SidebarMain = { else if(group.membership == "invited") { // Show invited state - subInfoEl.innerHTML = " Invited"; + subInfoEl.innerHTML = " Invited "; + const respondRequest = (accept) => { + GroupsInterface.respondInvitation(group.id, accept); + + subInfoEl.innerHTML = accept ? tr("Accepted") : tr("Rejected"); + }; + + // Offer the user to accept or reject the invitation + createElem2({ + appendTo: subInfoEl, + type: "span", + class: "btn btn-success btn-xs", + innerHTML: "", + onclick: (e) => respondRequest(true) + }); + + add_space(subInfoEl); + + createElem2({ + appendTo: subInfoEl, + type: "span", + class: "btn btn-danger btn-xs", + innerHTML: "", + onclick: (e) => respondRequest(false) + }); } else // Group last activity