mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-05 11:46:50 -06:00
Adds copy content button (#12584)
* adds copy content button #12499 * adds newline * Omit hash mark from target string * Clean up HTML element IDs --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
committed by
GitHub
parent
244d39387f
commit
404714f618
3
netbox/utilities/templates/builtins/copy_content.html
Normal file
3
netbox/utilities/templates/builtins/copy_content.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<a class="btn btn-sm {{ color }} copy-content" data-clipboard-target="{{ target }}" title="Copy to clipboard">
|
||||
<i class="mdi mdi-content-copy"></i>
|
||||
</a>
|
||||
@@ -6,6 +6,7 @@ from utilities.utils import dict_to_querydict
|
||||
__all__ = (
|
||||
'badge',
|
||||
'checkmark',
|
||||
'copy_content',
|
||||
'customfield_value',
|
||||
'tag',
|
||||
)
|
||||
@@ -79,6 +80,17 @@ def checkmark(value, show_false=True, true='Yes', false='No'):
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('builtins/copy_content.html')
|
||||
def copy_content(target, prefix=None, color='primary'):
|
||||
"""
|
||||
Display a copy button to copy the content of a field.
|
||||
"""
|
||||
return {
|
||||
'target': f'#{prefix or ""}{target}',
|
||||
'color': f'btn-{color}'
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('builtins/htmx_table.html', takes_context=True)
|
||||
def htmx_table(context, viewname, return_url=None, **kwargs):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user