mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add simple function for determining OPTIONS
This commit is contained in:
parent
5e338dca3f
commit
058e53459b
@ -103,6 +103,8 @@ settings_urls = [
|
||||
|
||||
# Some javascript files are served 'dynamically', allowing them to pass through the Django translation layer
|
||||
dynamic_javascript_urls = [
|
||||
url(r'^api.js', DynamicJsView.as_view(template_name='js/api.js'), name='api.js'),
|
||||
url(r'^forms.js', DynamicJsView.as_view(template_name='js/forms.js'), name='forms.js'),
|
||||
url(r'^modals.js', DynamicJsView.as_view(template_name='js/modals.js'), name='modals.js'),
|
||||
url(r'^barcode.js', DynamicJsView.as_view(template_name='js/barcode.js'), name='barcode.js'),
|
||||
url(r'^bom.js', DynamicJsView.as_view(template_name='js/bom.js'), name='bom.js'),
|
||||
|
@ -144,11 +144,12 @@
|
||||
|
||||
<!-- general InvenTree -->
|
||||
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/sidenav.js' %}"></script>
|
||||
|
||||
<!-- translated -->
|
||||
<script type='text/javascript' src="{% i18n_static 'api.js' %}"></script>
|
||||
<script type='text/javascript' src="{% i18n_static 'forms.js' %}"></script>
|
||||
<script type='text/javascript' src="{% i18n_static 'barcode.js' %}"></script>
|
||||
<script type='text/javascript' src="{% i18n_static 'bom.js' %}"></script>
|
||||
<script type='text/javascript' src="{% i18n_static 'company.js' %}"></script>
|
||||
|
38
InvenTree/templates/js/forms.js
Normal file
38
InvenTree/templates/js/forms.js
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This file contains code for rendering (and managing) HTML forms
|
||||
* which are served via the django-drf API.
|
||||
*
|
||||
* The django DRF library provides an OPTIONS method for each API endpoint,
|
||||
* which allows us to introspect the available fields at any given endpoint.
|
||||
*
|
||||
* The OPTIONS method provides the following information for each available field:
|
||||
*
|
||||
* - Field name
|
||||
* - Field label (translated)
|
||||
* - Field help text (translated)
|
||||
* - Field type
|
||||
* - Read / write status
|
||||
* - Field required status
|
||||
* - min_value / max_value
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Get the API endpoint options at the provided URL,
|
||||
* using a HTTP options request.
|
||||
*/
|
||||
function getApiEndpointOptions(url, options={}) {
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'OPTIONS',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
accepts: {
|
||||
json: 'application/json',
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user