mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -06:00
Deleted obsolete javascript
This commit is contained in:
parent
37e0388a5a
commit
98fe83944f
@ -32,61 +32,6 @@ $(document).ready(function() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper select fields
|
|
||||||
$('select.helper-parent').change(function () {
|
|
||||||
|
|
||||||
// Resolve child field by ID specified in parent
|
|
||||||
var child_field = $('#id_' + $(this).attr('child'));
|
|
||||||
|
|
||||||
// Wipe out any existing options within the child field
|
|
||||||
child_field.empty();
|
|
||||||
child_field.append($("<option></option>").attr("value", "").text(""));
|
|
||||||
|
|
||||||
// If the parent has a value set, fetch a list of child options via the API and populate the child field with them
|
|
||||||
if ($(this).val()) {
|
|
||||||
|
|
||||||
// Construct the API request URL
|
|
||||||
var api_url = $(this).attr('child-source');
|
|
||||||
var parent_accessor = $(this).attr('parent-accessor');
|
|
||||||
if (parent_accessor) {
|
|
||||||
api_url += '?' + parent_accessor + '=' + $(this).val();
|
|
||||||
} else {
|
|
||||||
api_url += '?' + $(this).attr('name') + '_id=' + $(this).val();
|
|
||||||
}
|
|
||||||
var api_url_extra = $(this).attr('child-filter');
|
|
||||||
if (api_url_extra) {
|
|
||||||
api_url += '&' + api_url_extra;
|
|
||||||
}
|
|
||||||
|
|
||||||
var disabled_indicator = $(this).attr('disabled-indicator');
|
|
||||||
var disabled_exempt = child_field.attr('exempt');
|
|
||||||
var child_display = $(this).attr('child-display');
|
|
||||||
if (!child_display) {
|
|
||||||
child_display = 'name';
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: api_url,
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (response, status) {
|
|
||||||
console.log(response);
|
|
||||||
$.each(response, function (index, choice) {
|
|
||||||
var option = $("<option></option>").attr("value", choice.id).text(choice[child_display]);
|
|
||||||
if (disabled_indicator && choice[disabled_indicator] && choice.id != disabled_exempt) {
|
|
||||||
option.attr("disabled", "disabled")
|
|
||||||
}
|
|
||||||
child_field.append(option);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trigger change event in case the child field is the parent of another field
|
|
||||||
child_field.change();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// API select widget
|
// API select widget
|
||||||
$('select[filter-for]').change(function () {
|
$('select[filter-for]').change(function () {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user