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:
Abhimanyu Saharan
2023-07-06 23:49:55 +05:30
committed by GitHub
parent 244d39387f
commit 404714f618
12 changed files with 71 additions and 25 deletions

View 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>

View File

@@ -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):
"""