mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-16 08:42:17 -06:00
Compare commits
2 Commits
21178-chan
...
20383-rack
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e8023899f | ||
|
|
601a7092e0 |
@@ -12,7 +12,7 @@ from django.core.validators import RegexValidator
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from netbox.constants import CENSOR_TOKEN, CENSOR_TOKEN_CHANGED
|
||||
from netbox.models import PrimaryModel
|
||||
@@ -128,9 +128,7 @@ class DataSource(JobsMixin, PrimaryModel):
|
||||
# Ensure URL scheme matches selected type
|
||||
if self.backend_class.is_local and self.url_scheme not in ('file', ''):
|
||||
raise ValidationError({
|
||||
'source_url': _("URLs for local sources must start with {scheme} (or specify no scheme)").format(
|
||||
scheme='file://'
|
||||
)
|
||||
'source_url': "URLs for local sources must start with file:// (or specify no scheme)"
|
||||
})
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
@@ -722,6 +722,9 @@ class DeviceForm(TenancyForm, PrimaryModelForm):
|
||||
if position:
|
||||
self.fields['position'].widget.choices = [(position, f'U{position}')]
|
||||
|
||||
# Clear face field when rack is cleared
|
||||
self.fields['face'].widget.attrs['ts-clear-field'] = 'rack'
|
||||
|
||||
|
||||
class ModuleForm(ModuleCommonForm, PrimaryModelForm):
|
||||
device = DynamicModelChoiceField(
|
||||
|
||||
@@ -31,7 +31,7 @@ class RackDimensionsPanel(panels.ObjectAttributesPanel):
|
||||
outer_width = attrs.NumericAttr('outer_width', unit_accessor='get_outer_unit_display')
|
||||
outer_height = attrs.NumericAttr('outer_height', unit_accessor='get_outer_unit_display')
|
||||
outer_depth = attrs.NumericAttr('outer_depth', unit_accessor='get_outer_unit_display')
|
||||
mounting_depth = attrs.TextAttr('mounting_depth', format_string='{} mm')
|
||||
mounting_depth = attrs.TextAttr('mounting_depth', format_string='{}mm')
|
||||
|
||||
|
||||
class RackNumberingPanel(panels.ObjectAttributesPanel):
|
||||
|
||||
8
netbox/project-static/dist/netbox.js
vendored
8
netbox/project-static/dist/netbox.js
vendored
File diff suppressed because one or more lines are too long
6
netbox/project-static/dist/netbox.js.map
vendored
6
netbox/project-static/dist/netbox.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -1,3 +1,4 @@
|
||||
import TomSelect from 'tom-select';
|
||||
import { getElements } from '../util';
|
||||
|
||||
function handleFormSubmit(): void {
|
||||
@@ -8,6 +9,37 @@ function handleFormSubmit(): void {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize clear-field dependencies.
|
||||
* When a field with ts-clear-field attribute's parent field is cleared, this field will also be cleared.
|
||||
*/
|
||||
function initClearFieldDependencies(): void {
|
||||
// Find all fields with ts-clear-field attribute
|
||||
for (const field of getElements<HTMLSelectElement>('[ts-clear-field]')) {
|
||||
const parentFieldName = field.getAttribute('ts-clear-field');
|
||||
if (!parentFieldName) continue;
|
||||
|
||||
// Find the parent field
|
||||
const parentField = document.querySelector<HTMLSelectElement>(`[name="${parentFieldName}"]`);
|
||||
if (!parentField) continue;
|
||||
|
||||
// Listen for changes on the parent field
|
||||
parentField.addEventListener('change', () => {
|
||||
// If parent field is cleared, also clear this dependent field
|
||||
if (!parentField.value || parentField.value === '') {
|
||||
// Check if this field uses TomSelect
|
||||
const tomselect = (field as HTMLSelectElement & { tomselect?: TomSelect }).tomselect;
|
||||
if (tomselect) {
|
||||
tomselect.clear();
|
||||
} else {
|
||||
// Regular select field
|
||||
field.value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach event listeners to each form's submit/reset buttons.
|
||||
*/
|
||||
@@ -28,4 +60,7 @@ export function initFormElements(): void {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize clear-field dependencies
|
||||
initClearFieldDependencies();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-01-15 05:05+0000\n"
|
||||
"POT-Creation-Date: 2026-01-13 05:05+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -12489,8 +12489,8 @@ msgstr ""
|
||||
msgid "Delete Selected"
|
||||
msgstr ""
|
||||
|
||||
#: netbox/netbox/plugins/navigation.py:53
|
||||
#: netbox/netbox/plugins/navigation.py:89
|
||||
#: netbox/netbox/plugins/navigation.py:55
|
||||
#: netbox/netbox/plugins/navigation.py:88
|
||||
msgid "Permissions must be passed as a tuple or list."
|
||||
msgstr ""
|
||||
|
||||
@@ -12498,7 +12498,7 @@ msgstr ""
|
||||
msgid "Buttons must be passed as a tuple or list."
|
||||
msgstr ""
|
||||
|
||||
#: netbox/netbox/plugins/navigation.py:95
|
||||
#: netbox/netbox/plugins/navigation.py:92
|
||||
msgid "Button color must be a choice within ButtonColorChoices."
|
||||
msgstr ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user