#5423 closed enhancement (fixed)
Add pagination to group invitations loop
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Groups | Keywords: | has-patch |
Cc: |
Description
The group invitations loop bp_group_has_invites()
doesn't handle pagination. I'd like to include an invitation management pane on the WordPress admin group edit page and that will require pagination.
This patch adds the necessary arguments to modify the query for pagination and adds the basic js that returns the correct part of the invitations list.
One piece that I don't have working is that the jQuery that adds and removes members from the list works only on the initial page load and will not work once the list has been refreshed by loading a different page of results or adding or removing a member. If someone can point me in the right direction on that problem, I'd appreciate it.
Thanks for looking at this patch.
Attachments (8)
Change History (20)
#1
@
11 years ago
- Component changed from Core to Groups
Thanks for the patch, dcavins. I really like the new technique of loading the entire invites list via AJAX on every change - IMO, this simplifies everything greatly, and provides for a much more consistent UI. The fact that we are able to get pagination in this way is a bonus.
As I think I mentioned in a previous ticket, our has_invites() queries are very lame, and your extension inherited some of that lameness :) It's really much more appropriate as a BP_Group_Member_Query query. 5423.02.patch is an update of your patch, which makes the necessary mods to BP_Group_Member_Query and the bp_group_has_members() stack. (These mods will also help with some of your other group-invite-related tickets.)
Could I ask you to take a look at the new patch? First, let me know whether you think it's a viable way forward in terms of the queries. Second, I ran into a couple issue that may or may not be my fault, but I was hoping you could look more closely at.
- Removing an invitation by unchecking the relevant checkbox doesn't seem to work (page refreshes but with the invite still in page)
- Removing an invitation by clicking Remove Invite seems to break sometimes. I got a nonce notice a couple times - maybe after the page is reloaded? Not totally sure.
Thanks for your work on this! Looking like a great improvement (and a good excuse to enhance BP_Group_Member_Query
).
#2
@
11 years ago
Another issue just dawned on me. The changes to the javascript file will break backward compatibility for users who are using bp-legacy but have overridden send-invites.php in their theme. Can you have a look to see if the JS can be rewritten in such a way as to continue to support this case?
#3
@
11 years ago
Hi boonebgorges-
I really like your extension of the BP_Group_Member_Query for this use. It'll help me on several other invitation-related tickets, too. :)
Here's a new patch that combines your BP_Group_Member_Query work with some other pagination and template updates.
I have some ideas about supporting the previous send-invites.php
template javascript. I'll look into it in the next day or so.
Notes: bp_group_has_invites()
now accepts pagination parameters and uses BP_Group_Member_Query
to build the list.
Solved "javascript fails on AJAX-produced pages" problem from my earlier patch by moving a hidden input storing group_id out of the piece refreshed via an AJAX call. (The code created in wp_ajax couldn't produce the group ID, so it was getting lost, and it's needed for the invite/uninvite action.)
In buddypress.js, changed the target in the .on() function. It wasn't working when monitoring a div that was being recreated via AJAX. So it's now monitoring a parent div that remains in the DOM all the time.
#4
@
11 years ago
I was able to add backwards compatibility with the old template style by checking for the new pagination target div. This new patch (5423.04) maintains the old invite/remove invite javascript for themes using the old-style template.
We can't actually provide pagination in the old template (pagination requires some new structural elements), but this patch prevents the old-style templates from being totally broken.
#7
@
11 years ago
dcavins - I had another look at this, and I think it's almost ready to go. The one remaining issue is that the invitation pagination counts (Viewing 10-12 of 12) are not updating dynamically when adding/subtracting users from the list. Yet when I refresh the page, the counts are updated. Maybe something funky is happening with caching or something? Would you mind taking a look?
#8
@
11 years ago
Oh, how embarrassing. Using the wrong selector often gives the wrong result. I'm attaching the fix.
Thanks very much for working on this new set of features. It's not sexy, but it is useful.
#9
@
11 years ago
Great, thanks, dcavins.
Going to make a few small changes:
- I have to switch the default per_page param in bp_group_has_invites() to false. Otherwise, themes like bp-default won't show anything beyond the first 10 invitations. This means that, to support pagination in bp-legacy, we have to manually pass a per_page argument. Not the most elegant thing in the world, but I've put it right in the template. It works.
- I moved the 'Select people to invite from your invite list' so that it only shows up when you haven't yet selected any members. The notice is really unnecessary when you've got invites, and also its persistence was causing some funniness with fading out and then reappearing after the AJAX response.
#11
@
11 years ago
- Owner set to boonebgorges
- Resolution set to fixed
- Status changed from new to closed
In 8063:
#12
in reply to:
↑ 10
@
11 years ago
Replying to boonebgorges:
In 8062:
Ha, that's actually currently the case with member requests. (If there are more than 10, they don't show.) I think that your change is totally reasonable, since the new underlying structure allows for easy pagination if desired.
Thanks again for putting in the time on this ticket.
Adds pagination pieces to invitation code