mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 05:25:42 +00:00
Merge branch 'master' of https://github.com/inventree/InvenTree into plugin-2037
This commit is contained in:
@ -62,26 +62,17 @@
|
||||
$('table').find('.btn-edit-setting').click(function() {
|
||||
var setting = $(this).attr('setting');
|
||||
var pk = $(this).attr('pk');
|
||||
var url = `/settings/${pk}/edit/`;
|
||||
|
||||
var is_global = true;
|
||||
|
||||
if ($(this).attr('user')){
|
||||
url += `user/`;
|
||||
is_global = false;
|
||||
}
|
||||
|
||||
launchModalForm(
|
||||
url,
|
||||
{
|
||||
success: function(response) {
|
||||
|
||||
if (response.is_bool) {
|
||||
var enabled = response.value.toLowerCase() == 'true';
|
||||
$(`#setting-value-${setting}`).prop('checked', enabled);
|
||||
} else {
|
||||
$(`#setting-value-${setting}`).html(response.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
editSetting(pk, {
|
||||
global: is_global,
|
||||
title: is_global ? '{% trans "Edit Global Setting" %}' : '{% trans "Edit User Setting" %}',
|
||||
});
|
||||
});
|
||||
|
||||
$("#edit-user").on('click', function() {
|
||||
|
@ -212,26 +212,37 @@
|
||||
{% trans "Select language" %}
|
||||
</label>
|
||||
<div class='form-group input-group mb-3'>
|
||||
<select name="language" class="select form-control">
|
||||
<select name="language" class="select form-control w-25">
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
{% get_available_languages as LANGUAGES %}
|
||||
{% get_language_info_list for LANGUAGES as languages %}
|
||||
{% if 'alllang' in request.GET %}{% define True as ALL_LANG %}{% endif %}
|
||||
{% for language in languages %}
|
||||
{% define language.code as lang_code %}
|
||||
{% define locale_stats|keyvalue:lang_code as lang_translated %}
|
||||
{% if lang_translated > 10 or lang_code == 'en' or lang_code == LANGUAGE_CODE %}{% define True as use_lang %}{% else %}{% define False as use_lang %}{% endif %}
|
||||
{% if ALL_LANG or use_lang %}
|
||||
<option value="{{ lang_code }}"{% if lang_code == LANGUAGE_CODE %} selected{% endif %}>
|
||||
{{ language.name_local }} ({{ lang_code }})
|
||||
{% if lang_translated %}
|
||||
{% blocktrans %}{{ lang_translated }}% translated{% endblocktrans %}
|
||||
{% else %}
|
||||
{% trans 'No translations available' %}
|
||||
{% if lang_code == 'en' %}-{% else %}{% trans 'No translations available' %}{% endif %}
|
||||
{% endif %}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div class='input-group-append'>
|
||||
<input type="submit" value="{% trans 'Set Language' %}" class="btn btn btn-primary">
|
||||
</div>
|
||||
<p>{% trans "Some languages are not complete" %}
|
||||
{% if ALL_LANG %}
|
||||
. <a href="{% url 'settings' %}">{% trans "Show only sufficent" %}</a>
|
||||
{% else %}
|
||||
and hidden. <a href="?alllang">{% trans "Show them too" %}</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -22,12 +22,12 @@
|
||||
<a href="https://github.com/inventree/InvenTree/releases">{% inventree_version %}</a>{% include "clip.html" %}
|
||||
{% inventree_is_development as dev %}
|
||||
{% if dev %}
|
||||
<span class='badge rounded-pill bg-primary'>{% trans "Development Version" %}</span>
|
||||
<span class='badge badge-right rounded-pill bg-primary'>{% trans "Development Version" %}</span>
|
||||
{% else %}
|
||||
{% if up_to_date %}
|
||||
<span class='badge rounded-pill bg-success'>{% trans "Up to Date" %}</span>
|
||||
<span class='badge badge-right rounded-pill bg-success'>{% trans "Up to Date" %}</span>
|
||||
{% else %}
|
||||
<span class='badge rounded-pill bg-info'>{% trans "Update Available" %}</span>
|
||||
<span class='badge badge-right rounded-pill bg-info'>{% trans "Update Available" %}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
@ -71,9 +71,12 @@
|
||||
{% include "spacer.html" %}
|
||||
<span class='float-right'><h3>{% inventree_title %}</h3></span>
|
||||
</div>
|
||||
<hr>
|
||||
<div class='container-fluid'>{% block content %}{% endblock %}</div>
|
||||
</div>
|
||||
<div class='container-fluid'>
|
||||
<hr>
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -32,6 +32,7 @@ for a account and sign in below:{% endblocktrans %}</p>
|
||||
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
|
||||
{% endif %}
|
||||
|
||||
<hr>
|
||||
<div class="btn-group float-right" role="group">
|
||||
<button class="btn btn-success" type="submit">{% trans "Sign In" %}</button>
|
||||
</div>
|
||||
|
@ -14,6 +14,7 @@
|
||||
{% if redirect_field_value %}
|
||||
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
|
||||
{% endif %}
|
||||
<hr>
|
||||
<div class='btn-group float-right' role='group'>
|
||||
<a type='button' class='btn btn-secondary' href='{% url "index" %}'><span class='fas fa-undo-alt'></span> {% trans "Back to Site" %}</a>
|
||||
<button type="submit" class="btn btn-danger btn-block">{% trans 'Sign Out' %}</button>
|
||||
|
@ -83,7 +83,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<main class='col ps-md-2 pt-2'>
|
||||
<main class='col ps-md-2 pt-2 pe-2'>
|
||||
|
||||
{% block alerts %}
|
||||
<div class='notification-area' id='alerts'>
|
||||
@ -190,6 +190,18 @@ $(document).ready(function () {
|
||||
{% endif %}
|
||||
|
||||
moment.locale('{{ request.LANGUAGE_CODE }}');
|
||||
|
||||
// Account notifications
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
showMessage(
|
||||
'{{ message }}',
|
||||
{
|
||||
style: 'info',
|
||||
}
|
||||
);
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
@ -1,6 +1,7 @@
|
||||
{% load inventree_extras %}
|
||||
|
||||
/* exported
|
||||
editSetting,
|
||||
user_settings,
|
||||
global_settings,
|
||||
*/
|
||||
@ -18,3 +19,83 @@ const global_settings = {
|
||||
{{ key }}: {% primitive_to_javascript value %},
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
/*
|
||||
* Edit a setting value
|
||||
*/
|
||||
function editSetting(pk, options={}) {
|
||||
|
||||
// Is this a global setting or a user setting?
|
||||
var global = options.global || false;
|
||||
|
||||
var url = '';
|
||||
|
||||
if (global) {
|
||||
url = `/api/settings/global/${pk}/`;
|
||||
} else {
|
||||
url = `/api/settings/user/${pk}/`;
|
||||
}
|
||||
|
||||
// First, read the settings object from the server
|
||||
inventreeGet(url, {}, {
|
||||
success: function(response) {
|
||||
|
||||
if (response.choices && response.choices.length > 0) {
|
||||
response.type = 'choice';
|
||||
}
|
||||
|
||||
// Construct the field
|
||||
var fields = {
|
||||
value: {
|
||||
label: response.name,
|
||||
help_text: response.description,
|
||||
type: response.type,
|
||||
choices: response.choices,
|
||||
}
|
||||
};
|
||||
|
||||
constructChangeForm(fields, {
|
||||
url: url,
|
||||
method: 'PATCH',
|
||||
title: options.title,
|
||||
processResults: function(data, fields, opts) {
|
||||
|
||||
switch (data.type) {
|
||||
case 'boolean':
|
||||
// Convert to boolean value
|
||||
data.value = data.value.toString().toLowerCase() == 'true';
|
||||
break;
|
||||
case 'integer':
|
||||
// Convert to integer value
|
||||
data.value = parseInt(data.value.toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
processBeforeUpload: function(data) {
|
||||
// Convert value to string
|
||||
data.value = data.value.toString();
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: function(response) {
|
||||
|
||||
var setting = response.key;
|
||||
|
||||
if (response.type == 'boolean') {
|
||||
var enabled = response.value.toString().toLowerCase() == 'true';
|
||||
$(`#setting-value-${setting}`).prop('checked', enabled);
|
||||
} else {
|
||||
$(`#setting-value-${setting}`).html(response.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(xhr) {
|
||||
showApiError(xhr, url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -61,7 +61,11 @@ function inventreeGet(url, filters={}, options={}) {
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
console.error('Error on GET at ' + url);
|
||||
console.error(thrownError);
|
||||
|
||||
if (thrownError) {
|
||||
console.error('Error: ' + thrownError);
|
||||
}
|
||||
|
||||
if (options.error) {
|
||||
options.error({
|
||||
error: thrownError
|
||||
@ -174,7 +178,7 @@ function showApiError(xhr, url) {
|
||||
var title = null;
|
||||
var message = null;
|
||||
|
||||
switch (xhr.status) {
|
||||
switch (xhr.status || 0) {
|
||||
// No response
|
||||
case 0:
|
||||
title = '{% trans "No Response" %}';
|
||||
|
@ -257,7 +257,7 @@ function barcodeDialog(title, options={}) {
|
||||
|
||||
$(modal).modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false,
|
||||
keyboard: user_settings.FORMS_CLOSE_USING_ESCAPE,
|
||||
});
|
||||
|
||||
if (options.preShow) {
|
||||
|
@ -43,11 +43,18 @@ function buildFormFields() {
|
||||
}
|
||||
},
|
||||
sales_order: {
|
||||
icon: 'fa-truck',
|
||||
},
|
||||
batch: {},
|
||||
target_date: {},
|
||||
take_from: {},
|
||||
destination: {},
|
||||
target_date: {
|
||||
icon: 'fa-calendar-alt',
|
||||
},
|
||||
take_from: {
|
||||
icon: 'fa-sitemap',
|
||||
},
|
||||
destination: {
|
||||
icon: 'fa-sitemap',
|
||||
},
|
||||
link: {
|
||||
icon: 'fa-link',
|
||||
},
|
||||
|
@ -19,7 +19,6 @@
|
||||
renderStockLocation,
|
||||
renderSupplierPart,
|
||||
renderUser,
|
||||
showAlertDialog,
|
||||
showAlertOrCache,
|
||||
showApiError,
|
||||
*/
|
||||
@ -199,14 +198,6 @@ function constructChangeForm(fields, options) {
|
||||
json: 'application/json',
|
||||
},
|
||||
success: function(data) {
|
||||
|
||||
// Push existing 'value' to each field
|
||||
for (const field in data) {
|
||||
|
||||
if (field in fields) {
|
||||
fields[field].value = data[field];
|
||||
}
|
||||
}
|
||||
|
||||
// An optional function can be provided to process the returned results,
|
||||
// before they are rendered to the form
|
||||
@ -219,6 +210,14 @@ function constructChangeForm(fields, options) {
|
||||
}
|
||||
}
|
||||
|
||||
// Push existing 'value' to each field
|
||||
for (const field in data) {
|
||||
|
||||
if (field in fields) {
|
||||
fields[field].value = data[field];
|
||||
}
|
||||
}
|
||||
|
||||
// Store the entire data object
|
||||
options.instance = data;
|
||||
|
||||
@ -347,10 +346,12 @@ function constructForm(url, options) {
|
||||
constructCreateForm(OPTIONS.actions.POST, options);
|
||||
} else {
|
||||
// User does not have permission to POST to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Create operation not allowed" %}'
|
||||
);
|
||||
showMessage('{% trans "Action Prohibited" %}', {
|
||||
style: 'danger',
|
||||
details: '{% trans "Create operation not allowed" %}',
|
||||
icon: 'fas fa-user-times',
|
||||
});
|
||||
|
||||
console.log(`'POST action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
@ -360,10 +361,12 @@ function constructForm(url, options) {
|
||||
constructChangeForm(OPTIONS.actions.PUT, options);
|
||||
} else {
|
||||
// User does not have permission to PUT/PATCH to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Update operation not allowed" %}'
|
||||
);
|
||||
showMessage('{% trans "Action Prohibited" %}', {
|
||||
style: 'danger',
|
||||
details: '{% trans "Update operation not allowed" %}',
|
||||
icon: 'fas fa-user-times',
|
||||
});
|
||||
|
||||
console.log(`${options.method} action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
@ -372,10 +375,12 @@ function constructForm(url, options) {
|
||||
constructDeleteForm(OPTIONS.actions.DELETE, options);
|
||||
} else {
|
||||
// User does not have permission to DELETE to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "Delete operation not allowed" %}'
|
||||
);
|
||||
showMessage('{% trans "Action Prohibited" %}', {
|
||||
style: 'danger',
|
||||
details: '{% trans "Delete operation not allowed" %}',
|
||||
icon: 'fas fa-user-times',
|
||||
});
|
||||
|
||||
console.log(`DELETE action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
@ -384,10 +389,12 @@ function constructForm(url, options) {
|
||||
// TODO?
|
||||
} else {
|
||||
// User does not have permission to GET to the endpoint
|
||||
showAlertDialog(
|
||||
'{% trans "Action Prohibited" %}',
|
||||
'{% trans "View operation not allowed" %}'
|
||||
);
|
||||
showMessage('{% trans "Action Prohibited" %}', {
|
||||
style: 'danger',
|
||||
details: '{% trans "View operation not allowed" %}',
|
||||
icon: 'fas fa-user-times',
|
||||
});
|
||||
|
||||
console.log(`GET action unavailable at ${url}`);
|
||||
}
|
||||
break;
|
||||
@ -717,6 +724,11 @@ function submitFormData(fields, options) {
|
||||
data = form_data;
|
||||
}
|
||||
|
||||
// Optionally pre-process the data before uploading to the server
|
||||
if (options.processBeforeUpload) {
|
||||
data = options.processBeforeUpload(data);
|
||||
}
|
||||
|
||||
// Submit data
|
||||
upload_func(
|
||||
options.url,
|
||||
|
@ -992,7 +992,7 @@ function loadPartTable(table, url, options={}) {
|
||||
}
|
||||
});
|
||||
|
||||
var grid_view = inventreeLoad('part-grid-view') == 1;
|
||||
var grid_view = options.gridView && inventreeLoad('part-grid-view') == 1;
|
||||
|
||||
$(table).inventreeTable({
|
||||
url: url,
|
||||
@ -1020,7 +1020,7 @@ function loadPartTable(table, url, options={}) {
|
||||
$('#view-part-list').removeClass('btn-outline-secondary').addClass('btn-secondary');
|
||||
}
|
||||
},
|
||||
buttons: [
|
||||
buttons: options.gridView ? [
|
||||
{
|
||||
icon: 'fas fa-bars',
|
||||
attributes: {
|
||||
@ -1053,7 +1053,7 @@ function loadPartTable(table, url, options={}) {
|
||||
);
|
||||
}
|
||||
}
|
||||
],
|
||||
] : [],
|
||||
customView: function(data) {
|
||||
|
||||
var html = '';
|
||||
|
@ -12,9 +12,6 @@
|
||||
<div class="navbar-header clearfix content-heading">
|
||||
<a class="navbar-brand" id='logo' href="{% url 'index' %}" style="padding-top: 7px; padding-bottom: 5px;"><img src="{% static 'img/inventree.png' %}" width="32" height="32" style="display:block; margin: auto;"/></a>
|
||||
</div>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-objects" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse" id="navbar-objects">
|
||||
<ul class="navbar-nav">
|
||||
{% if roles.part.view %}
|
||||
@ -84,19 +81,24 @@
|
||||
</ul>
|
||||
</div>
|
||||
{% include "search_form.html" %}
|
||||
<ul class='navbar-nav'>
|
||||
<ul class='navbar-nav flex-row'>
|
||||
{% if barcodes %}
|
||||
<li id='navbar-barcode-li'>
|
||||
<li class='nav-item' id='navbar-barcode-li'>
|
||||
<button id='barcode-scan' class='btn btn-secondary' title='{% trans "Scan Barcode" %}'>
|
||||
<span class='fas fa-qrcode'></span>
|
||||
</button>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class='nav-item' id='navbar-barcode-li'>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-objects" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
</li>
|
||||
<li class='nav-item dropdown'>
|
||||
<a class='nav-link dropdown-toggle' href='#' id='userMenuDropdown' role='button' data-bs-toggle='dropdown'>
|
||||
<span class='fas fa-user'></span> <strong>{{ user.get_username }}</strong>
|
||||
</a>
|
||||
<ul class='dropdown-menu dropdown-menu-end'>
|
||||
<ul class='dropdown-menu dropdown-menu-end inventree-navbar-menu'>
|
||||
{% if user.is_authenticated %}
|
||||
{% if user.is_staff %}
|
||||
<li><a class='dropdown-item' href="/admin/"><span class="fas fa-user"></span> {% trans "Admin" %}</a></li>
|
||||
@ -130,7 +132,6 @@
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
<div class='container' style='width: 80%;'>
|
||||
{% if qr_data %}
|
||||
<div class='qr-container'>
|
||||
<div class='d-flex justify-content-center'>
|
||||
<img src="{% qrcode qr_data %}">
|
||||
</div>
|
||||
{% else %}
|
||||
|
Reference in New Issue
Block a user