mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-10 21:10:17 +02:00
[CHANGE] JS corrections
This commit is contained in:
parent
6f0b853a60
commit
11a32c90a8
@ -34,6 +34,7 @@
|
|||||||
{% if srpfleetrequests %}
|
{% if srpfleetrequests %}
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
<div class="alert alert-info" role="alert">
|
<div class="alert alert-info" role="alert">
|
||||||
<div class="text-end">
|
<div class="text-end">
|
||||||
<b><span style="padding-right:2.5em">{% translate "Total Losses:" %} {{ srpfleetrequests.count }}</span></b>
|
<b><span style="padding-right:2.5em">{% translate "Total Losses:" %} {{ srpfleetrequests.count }}</span></b>
|
||||||
@ -43,9 +44,11 @@
|
|||||||
<button type="submit" title="Approve" class="btn btn-success btn-sm m-1" formaction="{% url 'srp:request_approve' %}">
|
<button type="submit" title="Approve" class="btn btn-success btn-sm m-1" formaction="{% url 'srp:request_approve' %}">
|
||||||
<i class="fa-solid fa-thumbs-up"></i>
|
<i class="fa-solid fa-thumbs-up"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button type="submit" title="Reject" class="btn btn-warning btn-sm m-1" formaction="{% url 'srp:request_reject' %}">
|
<button type="submit" title="Reject" class="btn btn-warning btn-sm m-1" formaction="{% url 'srp:request_reject' %}">
|
||||||
<i class="fa-solid fa-thumbs-down"></i>
|
<i class="fa-solid fa-thumbs-down"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button type="submit" title="Remove" onclick="return confirm('{% translate "Are you sure you want to delete SRP requests?" %}')" class="btn btn-danger btn-sm m-1" formaction="{% url 'srp:request_remove' %}">
|
<button type="submit" title="Remove" onclick="return confirm('{% translate "Are you sure you want to delete SRP requests?" %}')" class="btn btn-danger btn-sm m-1" formaction="{% url 'srp:request_remove' %}">
|
||||||
<i class="fa-solid fa-trash-alt"></i>
|
<i class="fa-solid fa-trash-alt"></i>
|
||||||
</button>
|
</button>
|
||||||
@ -172,41 +175,41 @@ ESC to cancel{% endblocktranslate %}" id="blah"></i></th>
|
|||||||
console.error('Action:', e.action);
|
console.error('Action:', e.action);
|
||||||
console.error('Trigger:', e.trigger);
|
console.error('Trigger:', e.trigger);
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
{% endblock extra_javascript %}
|
|
||||||
|
|
||||||
{% block extra_script %}
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
const elementEditableSrpAmount = $('.srp');
|
||||||
|
const elementTableSrpList = $('table.srplist');
|
||||||
|
|
||||||
$.fn.editable.defaults.mode = 'inline';
|
$.fn.editable.defaults.mode = 'inline';
|
||||||
$.fn.editable.defaults.showbuttons = false;
|
$.fn.editable.defaults.showbuttons = false;
|
||||||
$.fn.editable.defaults.highlight = "#AAFF80";
|
$.fn.editable.defaults.highlight = "#AAFF80";
|
||||||
|
|
||||||
$.fn.dataTable.moment = function(format, locale) {
|
$.fn.dataTable.moment = (format, locale) => {
|
||||||
let types = $.fn.dataTable.ext.type;
|
const types = $.fn.dataTable.ext.type;
|
||||||
|
|
||||||
// Add type detection
|
// Add type detection
|
||||||
types.detect.unshift(function(d) {
|
types.detect.unshift((d) => {
|
||||||
return moment(d, format, locale, true).isValid() ?
|
return moment(d, format, locale, true).isValid() ?
|
||||||
'moment-' + format :
|
'moment-' + format :
|
||||||
null;
|
null;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add sorting method - use an integer for the sorting
|
// Add sorting method - use an integer for the sorting
|
||||||
types.order[ 'moment-' + format+'-pre' ] = function(d) {
|
types.order[ 'moment-' + format+'-pre' ] = (d) => {
|
||||||
return moment(d, format, locale, true).unix();
|
return moment(d, format, locale, true).unix();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
$.fn.dataTable.moment('YYYY-MMM-D, HH:mm');
|
$.fn.dataTable.moment('YYYY-MMM-D, HH:mm');
|
||||||
|
|
||||||
$('.srp').editable({
|
elementEditableSrpAmount.editable({
|
||||||
display: function(value, response) {
|
display: function(value, response) {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
success: function(response, newValue) {
|
success: function(response, newValue) {
|
||||||
newValue = parseInt(newValue);
|
newValue = parseInt(newValue);
|
||||||
let newValueOutput = newValue.toLocaleString() + " ISK";
|
const newValueOutput = newValue.toLocaleString() + " ISK";
|
||||||
|
|
||||||
$(this).html(newValueOutput.bold());
|
$(this).html(`<b>${newValueOutput}</b>`);
|
||||||
},
|
},
|
||||||
validate: function(value) {
|
validate: function(value) {
|
||||||
if (value === null || value === '') {
|
if (value === null || value === '') {
|
||||||
@ -215,17 +218,17 @@ ESC to cancel{% endblocktranslate %}" id="blah"></i></th>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.srp').on('hidden', function(e, reason){
|
elementEditableSrpAmount.on('hidden', function(e, reason){
|
||||||
if(reason === 'save' || reason === 'nochange') {
|
if(reason === 'save' || reason === 'nochange') {
|
||||||
let $next = $(this).closest('tr').next().find('.editable');
|
const next_editable_element = $(this).closest('tr').next().find('.editable');
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$next.editable('show');
|
next_editable_element.editable('show');
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('table.srplist').DataTable({
|
elementTableSrpList.DataTable({
|
||||||
"order": [[ 6, "asc" ]],
|
"order": [[ 6, "asc" ]],
|
||||||
"paging": false,
|
"paging": false,
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
@ -245,7 +248,8 @@ ESC to cancel{% endblocktranslate %}" id="blah"></i></th>
|
|||||||
// tooltip
|
// tooltip
|
||||||
$("[rel=tooltip]").tooltip({ placement: 'top'});
|
$("[rel=tooltip]").tooltip({ placement: 'top'});
|
||||||
});
|
});
|
||||||
{% endblock extra_script %}
|
</script>
|
||||||
|
{% endblock extra_javascript %}
|
||||||
|
|
||||||
{% block extra_css %}
|
{% block extra_css %}
|
||||||
{% include "bundles/datatables-css-bs5.html" %}
|
{% include "bundles/datatables-css-bs5.html" %}
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
<a href="{% url 'srp:remove' srpfleet.id %}" onclick="return confirm('{% translate "Are you sure you want to delete this SRP code and its contents?" %}')" class="btn btn-danger btn-sm m-1" title="Remove">
|
<a href="{% url 'srp:remove' srpfleet.id %}" onclick="return confirm('{% translate "Are you sure you want to delete this SRP code and its contents?" %}')" class="btn btn-danger btn-sm m-1" title="Remove">
|
||||||
<i class="fa-solid fa-trash fa-fw"></i>
|
<i class="fa-solid fa-trash fa-fw"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
{% if srpfleet.fleet_srp_code %}
|
{% if srpfleet.fleet_srp_code %}
|
||||||
<a href="{% url 'srp:disable' srpfleet.id %}" class="btn btn-warning btn-sm m-1" title="Disable">
|
<a href="{% url 'srp:disable' srpfleet.id %}" class="btn btn-warning btn-sm m-1" title="Disable">
|
||||||
<i class="fa-solid fa-ban fa-fw"></i>
|
<i class="fa-solid fa-ban fa-fw"></i>
|
||||||
@ -115,7 +116,6 @@
|
|||||||
<i class="fa-solid fa-check fa-fw"></i>
|
<i class="fa-solid fa-check fa-fw"></i>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user