mirror of
https://github.com/ubicloud/ubicloud.git
synced 2025-10-05 22:31:57 +08:00
Table-based model browsing can be friendlier than the unordered list display currently used on the admin site. However, you need to be careful to not introduce N+1 queries when using table-based browsing. AutoForme is a library that builds on top of Forme (already used on the admin site) and provides the ability to browse and search the models in a way that avoids N+1 queries. It's quite flexible, requiring only a few lines of configuration code per model to have it display and allow searching of the columns desired. AutoForme also supports CRUD actions for models, but those are currently disabled, and it is only used for the tabular display and searching. It also supports downloading of data in CSV format (both in browse and search mode), which can be useful with external analysis tools. One potential regression with the AutoForme based browsing and searching is the use of offsets for pagination, instead of using a filter. If this becomes problematic, it's possible to add filter-based pagination to AutoForme. While it is possible to implement table-based browsing without using AutoForme, it would require reimplementing parts of AutoForme, and I think using AutoForme will result in smaller and simpler code in the long run. Currently, this only implements the table-based browsing for Firewall as a proof of concept. We can expand it to other models in the future. |
||
---|---|---|
.. | ||
admin_spec.rb | ||
auth_spec.rb | ||
spec_helper.rb |