I'm building an interface for administrating organizations that can have lots of people connected. The total pool of people consists of a few thousand individuals.
To the best of my knowledge, AA doesn't really have a good system for this kind of situation.
So far I've used something like this in the form block to add/remove people from the organization:
f.has_many :person_organizations, for: [:person_organizations, f.object.person_organizations.active] do |connection_f|
all_people = Person.select([:id, :firstname, :lastname]).order(:firstname, :lastname)
connection_f.input :person, as: :select,
collection: all_people,
member_label: proc { |d| "#{d.firstname} #{d.lastname}"
unless connection_f.object.nil?
# Show the destroy checkbox only if it is an existing person
# else, there's already dynamic JS to add / remove new dentists
connection_f.input :_destroy, as: :boolean, label: 'Delete this connection'
end
end
The problem with this is that after adding a few people to an organization, the time it takes to generate all the select boxes begins to be substantial as it has to do pretty much the same work for each element. See beneath ("slett denne koblingen" means "delete this connection")
Does anyone know of a way to alleviate this pain?
I've had a couple of thoughts, but I don't quite understand how I would implement them:
Also, I'm aware of a github issue discussing a solution to this kind of challenge, but it seems like it's still a way off, if it will ever be implemented: https://github.com/activeadmin/activeadmin/issues/2692#issuecomment-71500513
I have encountered the same sluggishness. The challenge you are faced with is the number of populated selects that will get created. I recommend using some form of AJAX and Select2/Chosen combination to "autocomplete" a textbox input. This will greatly reduce the HTML footprint and speed load times. The user experience may be more appreciated by your admins too.
https://github.com/activeadmin/activeadmin/issues/1754
https://github.com/mfairburn/activeadmin-select2
Viget Labs has a gem that provides an alternate solution for handling the autocomplete association. https://github.com/vigetlabs/active_admin_associations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With