diff --git a/InvenTree/templates/js/dynamic/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js similarity index 74% rename from InvenTree/templates/js/dynamic/inventree.js rename to InvenTree/InvenTree/static/script/inventree/inventree.js index 1774ba6f3d..b4f7114448 100644 --- a/InvenTree/templates/js/dynamic/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -1,5 +1,3 @@ -{% load inventree_extras %} - /* globals ClipboardJS, inventreeFormDataUpload, @@ -130,66 +128,68 @@ function inventreeDocReady() { attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text'); // Add autocomplete to the search-bar - $('#search-bar').autocomplete({ - source: function(request, response) { - $.ajax({ - url: '/api/part/', - data: { - search: request.term, - limit: user_settings.SEARCH_PREVIEW_RESULTS, - offset: 0 - }, - success: function(data) { + if ($('#search-bar').exists()) { + $('#search-bar').autocomplete({ + source: function(request, response) { + $.ajax({ + url: '/api/part/', + data: { + search: request.term, + limit: user_settings.SEARCH_PREVIEW_RESULTS, + offset: 0 + }, + success: function(data) { - var transformed = $.map(data.results, function(el) { - return { - label: el.full_name, - id: el.pk, - thumbnail: el.thumbnail, - data: el, - }; - }); - response(transformed); - }, - error: function() { - response([]); - } - }); - }, - create: function() { - $(this).data('ui-autocomplete')._renderItem = function(ul, item) { + var transformed = $.map(data.results, function(el) { + return { + label: el.full_name, + id: el.pk, + thumbnail: el.thumbnail, + data: el, + }; + }); + response(transformed); + }, + error: function() { + response([]); + } + }); + }, + create: function() { + $(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 += item.thumbnail || `/static/img/blank_image.png`; - html += `'> `; - html += item.label; + html += `<img class='hover-img-thumb' src='`; + html += item.thumbnail || `/static/img/blank_image.png`; + html += `'> `; + html += item.label; - html += '</span>'; - - if (user_settings.SEARCH_SHOW_STOCK_LEVELS) { - html += partStockLabel( - item.data, - { - classes: 'badge-right', - } - ); - } + html += '</span>'; + + if (user_settings.SEARCH_SHOW_STOCK_LEVELS) { + html += partStockLabel( + item.data, + { + classes: 'badge-right', + } + ); + } - html += '</a>'; + html += '</a>'; - return $('<li>').append(html).appendTo(ul); - }; - }, - select: function( event, ui ) { - window.location = '/part/' + ui.item.id + '/'; - }, - minLength: 2, - classes: { - 'ui-autocomplete': 'dropdown-menu search-menu', - }, - }); + return $('<li>').append(html).appendTo(ul); + }; + }, + select: function( event, ui ) { + window.location = '/part/' + ui.item.id + '/'; + }, + minLength: 2, + classes: { + 'ui-autocomplete': 'dropdown-menu search-menu', + }, + }); + } // Generate brand-icons $('.brand-icon').each(function(i, obj) { diff --git a/InvenTree/InvenTree/static/script/inventree/notification.js b/InvenTree/InvenTree/static/script/inventree/notification.js index 4ed1333ac6..f62226985e 100644 --- a/InvenTree/InvenTree/static/script/inventree/notification.js +++ b/InvenTree/InvenTree/static/script/inventree/notification.js @@ -1,10 +1,12 @@ function showAlertOrCache(alertType, message, cache, timeout=5000) { if (cache) { - sessionStorage.setItem("inventree-" + alertType, message); + sessionStorage.setItem(`inventree-${alertType}`, message); } else { showMessage('#' + alertType, message, timeout); + + sessionStorage.removeItem(`inventree-${alertType}`); } } @@ -82,4 +84,4 @@ function showMessage(message, options={}) { $(`#alert-${id}`).delay(timeout).slideUp(200, function() { $(this).alert(close); }); -} \ No newline at end of file +} diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 77a0e06a0c..053ba05264 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -94,7 +94,6 @@ settings_urls = [ # These javascript files are served "dynamically" - i.e. rendered on demand 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'^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'), diff --git a/InvenTree/templates/account/base.html b/InvenTree/templates/account/base.html index eeaa0c449d..4dded57eba 100644 --- a/InvenTree/templates/account/base.html +++ b/InvenTree/templates/account/base.html @@ -33,9 +33,15 @@ <!-- 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='login-container'> <div class="row"> <div class='container-fluid'> @@ -52,24 +58,31 @@ {% block extra_body %} {% endblock %} - - <div class='notification-area' id='alerts'> - <!-- Div for displayed alerts --> - </div> </div> <!-- Scripts --> <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 --> +<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script> <script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script> -<!-- dynamic javascript templates --> -<script type='text/javascript' src="{% url 'inventree.js' %}"></script> - +<!-- fontawesome --> <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/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'> diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index d01d5051f6..a07d706e8e 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -141,9 +141,9 @@ <!-- general InvenTree --> <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 --> -<script type='text/javascript' src="{% url 'inventree.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 'settings.js' %}"></script>