-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add a generic view_tab.html template to ease plugin development #12110
Comments
IMO the only way it makes sense for us to add a template is if it can be utilized for core views as well. For ObjectChildrenView specifically, templates will typically inherit from a model-specific parent template anyway so I'm not sure how useful this would be. |
I think this can be tackled on how I did for |
I don't see how useful a table would be for a "Tab View", IMO you would use ObjectChildrenView for that as it would likely be a related table or similar. I think it would make sense if there was a generic view and it consisted of a single left pane which simply loops through all the models meta fields (perhaps have a base call to get_extra_content or similar which populates the attribute fields you want to display. |
80% of my plugins use tab view to display related data in a table and all of them ship with the exact code to do this including the template file. So, the idea was to reduce the code by introducing a boilerplate template which can be used by the core and plugins. Since, there are cases where a template a template would need to provide extra functionality, we can provide blocks to do so. |
I think I missed the part where this was for ObjectChildrenView specifically, the mention of "View Tab" threw me off. |
* adds generic tab view template #12110 * Rename view_tab.html and move to generic/ * Fix console ports template * Move bulk operations view resolution to template * Avoid setting default template_name on ObjectChildrenView * Move base_template and table_config context vars to base context * removed bulk_delete_control from templates * refactored bulk_controls view * fixed table_config * renamed object_tab.html to objectchildren_list.html * removed unused import * Refactor template blocks for bulk operation buttons * Rename object children generic template * Move disconnect bulk action into a separate template for device components * Fix cluster devices & VM interfaces views * minor button label change --------- Co-authored-by: Jeremy Stretch <[email protected]>
NetBox version
v3.4.7
Feature type
Change to existing functionality
Proposed functionality
Add
view_tab.html
totemplates/inc
with the following minimalistic contentTo allow
table_config
to be passed down to the template, make the following change in the python codeUse case
In a lot of my plugins, wherever I use the
ViewTab
functionality, I have to ship out my own template along with the code. In 99% cases, it's exactly the same file which I even reuse within the same plugin to avoid writing multiple ones for different classes. It would ease with the plugin development, if NetBox provided a generic template that the code will automatically look for if not specified by the plugin developer and use that.Database changes
No response
External dependencies
No response
The text was updated successfully, but these errors were encountered: