mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix javascript issues on login screens
This commit is contained in:
parent
d4a8f5823c
commit
4e7825df13
@ -1,5 +1,3 @@
|
|||||||
{% load inventree_extras %}
|
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
ClipboardJS,
|
ClipboardJS,
|
||||||
inventreeFormDataUpload,
|
inventreeFormDataUpload,
|
||||||
@ -130,66 +128,68 @@ function inventreeDocReady() {
|
|||||||
attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text');
|
attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text');
|
||||||
|
|
||||||
// Add autocomplete to the search-bar
|
// Add autocomplete to the search-bar
|
||||||
$('#search-bar').autocomplete({
|
if ($('#search-bar').exists()) {
|
||||||
source: function(request, response) {
|
$('#search-bar').autocomplete({
|
||||||
$.ajax({
|
source: function(request, response) {
|
||||||
url: '/api/part/',
|
$.ajax({
|
||||||
data: {
|
url: '/api/part/',
|
||||||
search: request.term,
|
data: {
|
||||||
limit: user_settings.SEARCH_PREVIEW_RESULTS,
|
search: request.term,
|
||||||
offset: 0
|
limit: user_settings.SEARCH_PREVIEW_RESULTS,
|
||||||
},
|
offset: 0
|
||||||
success: function(data) {
|
},
|
||||||
|
success: function(data) {
|
||||||
|
|
||||||
var transformed = $.map(data.results, function(el) {
|
var transformed = $.map(data.results, function(el) {
|
||||||
return {
|
return {
|
||||||
label: el.full_name,
|
label: el.full_name,
|
||||||
id: el.pk,
|
id: el.pk,
|
||||||
thumbnail: el.thumbnail,
|
thumbnail: el.thumbnail,
|
||||||
data: el,
|
data: el,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
response(transformed);
|
response(transformed);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
response([]);
|
response([]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
create: function() {
|
create: function() {
|
||||||
$(this).data('ui-autocomplete')._renderItem = function(ul, item) {
|
$(this).data('ui-autocomplete')._renderItem = function(ul, item) {
|
||||||
|
|
||||||
var html = `<a href='/part/${item.id}/'><span>`;
|
var html = `<a href='/part/${item.id}/'><span>`;
|
||||||
|
|
||||||
html += `<img class='hover-img-thumb' src='`;
|
html += `<img class='hover-img-thumb' src='`;
|
||||||
html += item.thumbnail || `/static/img/blank_image.png`;
|
html += item.thumbnail || `/static/img/blank_image.png`;
|
||||||
html += `'> `;
|
html += `'> `;
|
||||||
html += item.label;
|
html += item.label;
|
||||||
|
|
||||||
html += '</span>';
|
html += '</span>';
|
||||||
|
|
||||||
if (user_settings.SEARCH_SHOW_STOCK_LEVELS) {
|
if (user_settings.SEARCH_SHOW_STOCK_LEVELS) {
|
||||||
html += partStockLabel(
|
html += partStockLabel(
|
||||||
item.data,
|
item.data,
|
||||||
{
|
{
|
||||||
classes: 'badge-right',
|
classes: 'badge-right',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '</a>';
|
html += '</a>';
|
||||||
|
|
||||||
return $('<li>').append(html).appendTo(ul);
|
return $('<li>').append(html).appendTo(ul);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
select: function( event, ui ) {
|
select: function( event, ui ) {
|
||||||
window.location = '/part/' + ui.item.id + '/';
|
window.location = '/part/' + ui.item.id + '/';
|
||||||
},
|
},
|
||||||
minLength: 2,
|
minLength: 2,
|
||||||
classes: {
|
classes: {
|
||||||
'ui-autocomplete': 'dropdown-menu search-menu',
|
'ui-autocomplete': 'dropdown-menu search-menu',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Generate brand-icons
|
// Generate brand-icons
|
||||||
$('.brand-icon').each(function(i, obj) {
|
$('.brand-icon').each(function(i, obj) {
|
@ -1,10 +1,12 @@
|
|||||||
|
|
||||||
function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
||||||
if (cache) {
|
if (cache) {
|
||||||
sessionStorage.setItem("inventree-" + alertType, message);
|
sessionStorage.setItem(`inventree-${alertType}`, message);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
showMessage('#' + alertType, message, timeout);
|
showMessage('#' + alertType, message, timeout);
|
||||||
|
|
||||||
|
sessionStorage.removeItem(`inventree-${alertType}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,4 +84,4 @@ function showMessage(message, options={}) {
|
|||||||
$(`#alert-${id}`).delay(timeout).slideUp(200, function() {
|
$(`#alert-${id}`).delay(timeout).slideUp(200, function() {
|
||||||
$(this).alert(close);
|
$(this).alert(close);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,6 @@ settings_urls = [
|
|||||||
|
|
||||||
# These javascript files are served "dynamically" - i.e. rendered on demand
|
# These javascript files are served "dynamically" - i.e. rendered on demand
|
||||||
dynamic_javascript_urls = [
|
dynamic_javascript_urls = [
|
||||||
url(r'^inventree.js', DynamicJsView.as_view(template_name='js/dynamic/inventree.js'), name='inventree.js'),
|
|
||||||
url(r'^calendar.js', DynamicJsView.as_view(template_name='js/dynamic/calendar.js'), name='calendar.js'),
|
url(r'^calendar.js', DynamicJsView.as_view(template_name='js/dynamic/calendar.js'), name='calendar.js'),
|
||||||
url(r'^nav.js', DynamicJsView.as_view(template_name='js/dynamic/nav.js'), name='nav.js'),
|
url(r'^nav.js', DynamicJsView.as_view(template_name='js/dynamic/nav.js'), name='nav.js'),
|
||||||
url(r'^settings.js', DynamicJsView.as_view(template_name='js/dynamic/settings.js'), name='settings.js'),
|
url(r'^settings.js', DynamicJsView.as_view(template_name='js/dynamic/settings.js'), name='settings.js'),
|
||||||
|
@ -33,9 +33,15 @@
|
|||||||
<!--
|
<!--
|
||||||
Background Image Attribution: https://unsplash.com/photos/Ixvv3YZkd7w
|
Background Image Attribution: https://unsplash.com/photos/Ixvv3YZkd7w
|
||||||
-->
|
-->
|
||||||
|
<div class='container-fluid'>
|
||||||
|
<div class='notification-area' id='alerts'>
|
||||||
|
<!-- Div for displayed alerts -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class='main body-wrapper login-screen d-flex'>
|
<div class='main body-wrapper login-screen d-flex'>
|
||||||
|
|
||||||
|
|
||||||
<div class='login-container'>
|
<div class='login-container'>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
@ -52,24 +58,31 @@
|
|||||||
|
|
||||||
{% block extra_body %}
|
{% block extra_body %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<div class='notification-area' id='alerts'>
|
|
||||||
<!-- Div for displayed alerts -->
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script type="text/javascript" src="{% static 'script/jquery_3.3.1_jquery.min.js' %}"></script>
|
<script type="text/javascript" src="{% static 'script/jquery_3.3.1_jquery.min.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'script/jquery-ui/jquery-ui.min.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
|
||||||
|
|
||||||
<!-- general InvenTree -->
|
<!-- general InvenTree -->
|
||||||
|
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
||||||
|
|
||||||
<!-- dynamic javascript templates -->
|
<!-- fontawesome -->
|
||||||
<script type='text/javascript' src="{% url 'inventree.js' %}"></script>
|
|
||||||
|
|
||||||
<script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script>
|
<script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'fontawesome/js/brands.js' %}"></script>
|
<script type='text/javascript' src="{% static 'fontawesome/js/brands.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% static 'fontawesome/js/fontawesome.js' %}"></script>
|
<script type='text/javascript' src="{% static 'fontawesome/js/fontawesome.js' %}"></script>
|
||||||
|
|
||||||
|
<!-- 3rd party general js -->
|
||||||
|
<script type="text/javascript" src="{% static 'fullcalendar/main.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'fullcalendar/locales-all.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'select2/js/select2.full.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'script/moment.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'script/chart.min.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'script/clipboard.min.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'script/randomColor.min.js' %}"></script>
|
||||||
|
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
|
|
||||||
|
@ -141,9 +141,9 @@
|
|||||||
|
|
||||||
<!-- general InvenTree -->
|
<!-- general InvenTree -->
|
||||||
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
||||||
|
|
||||||
<!-- dynamic javascript templates -->
|
<!-- dynamic javascript templates -->
|
||||||
<script type='text/javascript' src="{% url 'inventree.js' %}"></script>
|
|
||||||
<script type='text/javascript' src="{% url 'calendar.js' %}"></script>
|
<script type='text/javascript' src="{% url 'calendar.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% url 'nav.js' %}"></script>
|
<script type='text/javascript' src="{% url 'nav.js' %}"></script>
|
||||||
<script type='text/javascript' src="{% url 'settings.js' %}"></script>
|
<script type='text/javascript' src="{% url 'settings.js' %}"></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user