mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 12:06:53 -06:00
update templates & rendering for bootstrap 5
This commit is contained in:
parent
ec38ec8004
commit
94c25b0ff4
@ -64,7 +64,7 @@ class RackElevationSVG:
|
|||||||
drawing = svgwrite.Drawing(size=(width, height))
|
drawing = svgwrite.Drawing(size=(width, height))
|
||||||
|
|
||||||
# add the stylesheet
|
# add the stylesheet
|
||||||
with open('{}/css/rack_elevation.css'.format(settings.STATICFILES_DIRS[0])) as css_file:
|
with open('{}/rack_elevation.css'.format(settings.STATIC_ROOT)) as css_file:
|
||||||
drawing.defs.add(drawing.style(css_file.read()))
|
drawing.defs.add(drawing.style(css_file.read()))
|
||||||
|
|
||||||
# add gradients
|
# add gradients
|
||||||
|
@ -214,7 +214,7 @@ class CommentField(forms.CharField):
|
|||||||
widget = forms.Textarea
|
widget = forms.Textarea
|
||||||
default_label = ''
|
default_label = ''
|
||||||
# TODO: Port Markdown cheat sheet to internal documentation
|
# TODO: Port Markdown cheat sheet to internal documentation
|
||||||
default_helptext = '<i class="mdi mdi-information-outline"></i> '\
|
default_helptext = '<i class="bi bi-info-circle"></i> '\
|
||||||
'<a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">'\
|
'<a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">'\
|
||||||
'Markdown</a> syntax is supported'
|
'Markdown</a> syntax is supported'
|
||||||
|
|
||||||
@ -390,7 +390,8 @@ class JSONField(_JSONField):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
if not self.help_text:
|
if not self.help_text:
|
||||||
self.help_text = 'Enter context data in <a href="https://json.org/">JSON</a> format.'
|
|
||||||
|
self.help_text = 'Enter context data in <a target="_blank" href="https://json.org/">JSON</a> format.'
|
||||||
self.widget.attrs['placeholder'] = ''
|
self.widget.attrs['placeholder'] = ''
|
||||||
|
|
||||||
def prepare_value(self, value):
|
def prepare_value(self, value):
|
||||||
|
@ -4,6 +4,8 @@ import re
|
|||||||
import yaml
|
import yaml
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
|
from .widgets import APISelect, APISelectMultiple, StaticSelect2
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'BootstrapMixin',
|
'BootstrapMixin',
|
||||||
@ -28,18 +30,28 @@ class BootstrapMixin(forms.BaseForm):
|
|||||||
forms.CheckboxInput,
|
forms.CheckboxInput,
|
||||||
forms.ClearableFileInput,
|
forms.ClearableFileInput,
|
||||||
forms.FileInput,
|
forms.FileInput,
|
||||||
forms.RadioSelect
|
forms.RadioSelect,
|
||||||
|
APISelect,
|
||||||
|
APISelectMultiple,
|
||||||
|
StaticSelect2,
|
||||||
]
|
]
|
||||||
|
|
||||||
for field_name, field in self.fields.items():
|
for field_name, field in self.fields.items():
|
||||||
|
|
||||||
if field.widget.__class__ not in exempt_widgets:
|
if field.widget.__class__ not in exempt_widgets:
|
||||||
css = field.widget.attrs.get('class', '')
|
css = field.widget.attrs.get('class', '')
|
||||||
field.widget.attrs['class'] = ' '.join([css, 'form-control']).strip()
|
field.widget.attrs['class'] = ' '.join([css, 'form-control']).strip()
|
||||||
|
|
||||||
if field.required and not isinstance(field.widget, forms.FileInput):
|
if field.required and not isinstance(field.widget, forms.FileInput):
|
||||||
field.widget.attrs['required'] = 'required'
|
field.widget.attrs['required'] = 'required'
|
||||||
if 'placeholder' not in field.widget.attrs:
|
|
||||||
|
if 'placeholder' not in field.widget.attrs and field.label is not None:
|
||||||
field.widget.attrs['placeholder'] = field.label
|
field.widget.attrs['placeholder'] = field.label
|
||||||
|
|
||||||
|
if field.widget.__class__ == forms.CheckboxInput:
|
||||||
|
css = field.widget.attrs.get('class', '')
|
||||||
|
field.widget.attrs['class'] = ' '.join((css, 'form-check-input')).strip()
|
||||||
|
|
||||||
|
|
||||||
class ReturnURLForm(forms.Form):
|
class ReturnURLForm(forms.Form):
|
||||||
"""
|
"""
|
||||||
|
@ -1,20 +1 @@
|
|||||||
<div class="input-group">
|
{% include 'django/forms/widgets/number.html' %}
|
||||||
{% include 'django/forms/widgets/number.html' %}
|
|
||||||
<span class="input-group-btn">
|
|
||||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
|
||||||
<span class="caret"></span>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-right">
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="10000" class="set_speed">10 Mbps</a></li>
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="100000" class="set_speed">100 Mbps</a></li>
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="1000000" class="set_speed">1 Gbps</a></li>
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="10000000" class="set_speed">10 Gbps</a></li>
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="25000000" class="set_speed">25 Gbps</a></li>
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="40000000" class="set_speed">40 Gbps</a></li>
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="100000000" class="set_speed">100 Gbps</a></li>
|
|
||||||
<li class="divider"></li>
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="1544" class="set_speed">T1 (1.544 Mbps)</a></li>
|
|
||||||
<li><a href="#" target="{{ widget.name }}" data="2048" class="set_speed">E1 (2.048 Mbps)</a></li>
|
|
||||||
</ul>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
@ -1,8 +1 @@
|
|||||||
<div class="input-group">
|
{% include "django/forms/widgets/input.html" %}
|
||||||
{% include "django/forms/widgets/input.html" %}
|
|
||||||
<span class="input-group-btn">
|
|
||||||
<button class="btn btn-default reslugify" type="button" title="Regenerate slug">
|
|
||||||
<i class="mdi mdi-refresh"></i>
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user