-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Initial Bootstrap 5 theme implementation - foundational UI port #2642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
these are practically unchanged from the Bootstrap 4 templates
Removed custom CSS from admin.css in favor of Bootstrap 5 classes. Updated base.html to use the right static files and included popover and toast message handling.
…ration Migrated macros to BS5 and created form.js to bind widgets to Bootstrap 5 components. Added select2 support (non-functional in modals). Planning to replace select2 with native JS solutions to remove jQuery dependency.
Added action.js to handle bulk actions and initialize tooltips for column descriptions. TODO: review implementation.
… scripts Introduced modal.js for modal management and details_filter.js for details model filtering.
…further testing and fixes)
Example includes modal operations, inline models editing, filtering, search, export, Select2 integration, and multi-level navigation to demonstrate all BS5 components.
can you run |
…renderers in rules.py
…older (e.g., 'bootstrap4', 'bootstrap5'). This function is essential for UI components, like widgets, that need to adapt their rendering based on the configured theme. The implementation is robust and supports multi-admin applications by inspecting the current request's endpoint (`request.endpoint`) and matching it against the endpoints of the views registered within each `Admin` instance. If the helper is called from outside an admin-related view (e.g., a public homepage) or outside a request context, it falls back to using the theme of the first registered `Admin` instance. TODO: - A caching mechanism should be added to avoid re-scanning the admin views on every call, which currently involves a nested loop.
…ed on active theme configuration
improved the development environment setup to support both `pip` and `uv`.
Continued development on this PR. I've styled the FileUploadInput and ImageUploadInput widgets to provide responsive, theme-aware defaults for Bootstrap 5, while preserving the ability for users to provide their own custom templates. Here are some screenshots from the "Forms" example demonstrating the new default look: |
…pdate form.js version to 1.0.2
Is this PR ready for review or do you plan to keep working on it? A 64k PR is somewhat too complex, I fear |
@ElLorans I may be mistaken because I did this very quickly, but the only files I created/modified are:
The following line of code counts roughly how many lines of code were actually affected by this PR (TL;DR <5k)
|
Thanks. About my first question, is the PR ready for review or do you need any final tweaks? |
You can review it. Just consider what I wrote above: I only managed to integrate Select2. I didn't integrate x-editable and datepicker. So this PR is somewhat of a starting point on which, hopefully, other contributors will also start contributing. |
Unfortunately and understandibly, everybody prefers his own frontend theme PR. Maybe we can coordinate here #2647 |
This PR provides a Bootstrap 5 port of the existing Bootstrap 4 theme, adapting Flask-Admin's UI components to work with Bootstrap 5 while maintaining some sort of backward compatibility.
Changes Made
Template & Macro Adaptation
JavaScript Modernization
form.js
to bind "widgets" (right now it's just Select2) to Bootstrap 5 componentsmodal.js
for modal dialog managementfilter.js
anddetails_filter.js
for enhanced filteringaction.js
for bulk actions and tooltip initializationUI Component Porting
Static Assets
Current Status
This is a partial port with the following limitations:
Static File Verification
All new static files (Bootstrap, Bootswatch themes, Select2, etc.) can be verified against official distributions by comparing SHA hashes with CDN and official release versions.
Future Work
This port establishes the foundation for removing jQuery dependency by preparing integration points for modern JavaScript alternatives (i.e. Choices.js) to replace Select2 in future iterations.
Example Application
Includes comprehensive example demonstrating all ported features: modal operations, inline editing, filtering, search, export functionality, and multi-level navigation.
The example is an enhanced port of the original Bootstrap 4 example. Screenshots below showcase the key functionality:
List filtering and bulk actions
This screenshot shows list filtering capabilities and bulk actions applied to selected records (one record selected in this case):
Inline editing with modal creation
Demonstrates creating a new organization with inline user addition. The trash icon (top right) allows removing the added user for demonstration purposes:
Theme switching and Select2 integration
Shows the United Bootswatch theme and demonstrates Select2 functionality in modal creation:
Link to relevant issues or previous PRs
Other contributors have attempted to achieve this result (#2350 #2163). This PR aims to initiate the definitive introduction of Bootstrap 5 support by providing a comprehensive foundation for the migration.