mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-10 13:00:16 +02:00
[CHANGE] JS corrections
This commit is contained in:
parent
6f0b853a60
commit
11a32c90a8
@ -34,6 +34,7 @@
|
||||
{% if srpfleetrequests %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
|
||||
<div class="alert alert-info" role="alert">
|
||||
<div class="text-end">
|
||||
<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' %}">
|
||||
<i class="fa-solid fa-thumbs-up"></i>
|
||||
</button>
|
||||
|
||||
<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>
|
||||
</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' %}">
|
||||
<i class="fa-solid fa-trash-alt"></i>
|
||||
</button>
|
||||
@ -172,80 +175,81 @@ ESC to cancel{% endblocktranslate %}" id="blah"></i></th>
|
||||
console.error('Action:', e.action);
|
||||
console.error('Trigger:', e.trigger);
|
||||
});
|
||||
</script>
|
||||
{% endblock extra_javascript %}
|
||||
|
||||
{% block extra_script %}
|
||||
$(document).ready(function() {
|
||||
$.fn.editable.defaults.mode = 'inline';
|
||||
$.fn.editable.defaults.showbuttons = false;
|
||||
$.fn.editable.defaults.highlight = "#AAFF80";
|
||||
$(document).ready(function() {
|
||||
const elementEditableSrpAmount = $('.srp');
|
||||
const elementTableSrpList = $('table.srplist');
|
||||
|
||||
$.fn.dataTable.moment = function(format, locale) {
|
||||
let types = $.fn.dataTable.ext.type;
|
||||
$.fn.editable.defaults.mode = 'inline';
|
||||
$.fn.editable.defaults.showbuttons = false;
|
||||
$.fn.editable.defaults.highlight = "#AAFF80";
|
||||
|
||||
// Add type detection
|
||||
types.detect.unshift(function(d) {
|
||||
return moment(d, format, locale, true).isValid() ?
|
||||
'moment-' + format :
|
||||
null;
|
||||
$.fn.dataTable.moment = (format, locale) => {
|
||||
const types = $.fn.dataTable.ext.type;
|
||||
|
||||
// Add type detection
|
||||
types.detect.unshift((d) => {
|
||||
return moment(d, format, locale, true).isValid() ?
|
||||
'moment-' + format :
|
||||
null;
|
||||
});
|
||||
|
||||
// Add sorting method - use an integer for the sorting
|
||||
types.order[ 'moment-' + format+'-pre' ] = (d) => {
|
||||
return moment(d, format, locale, true).unix();
|
||||
};
|
||||
};
|
||||
$.fn.dataTable.moment('YYYY-MMM-D, HH:mm');
|
||||
|
||||
elementEditableSrpAmount.editable({
|
||||
display: function(value, response) {
|
||||
return false;
|
||||
},
|
||||
success: function(response, newValue) {
|
||||
newValue = parseInt(newValue);
|
||||
const newValueOutput = newValue.toLocaleString() + " ISK";
|
||||
|
||||
$(this).html(`<b>${newValueOutput}</b>`);
|
||||
},
|
||||
validate: function(value) {
|
||||
if (value === null || value === '') {
|
||||
return 'Empty values not allowed';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add sorting method - use an integer for the sorting
|
||||
types.order[ 'moment-' + format+'-pre' ] = function(d) {
|
||||
return moment(d, format, locale, true).unix();
|
||||
};
|
||||
};
|
||||
$.fn.dataTable.moment('YYYY-MMM-D, HH:mm');
|
||||
elementEditableSrpAmount.on('hidden', function(e, reason){
|
||||
if(reason === 'save' || reason === 'nochange') {
|
||||
const next_editable_element = $(this).closest('tr').next().find('.editable');
|
||||
|
||||
$('.srp').editable({
|
||||
display: function(value, response) {
|
||||
return false;
|
||||
},
|
||||
success: function(response, newValue) {
|
||||
newValue = parseInt(newValue);
|
||||
let newValueOutput = newValue.toLocaleString() + " ISK";
|
||||
|
||||
$(this).html(newValueOutput.bold());
|
||||
},
|
||||
validate: function(value) {
|
||||
if (value === null || value === '') {
|
||||
return 'Empty values not allowed';
|
||||
setTimeout(function() {
|
||||
next_editable_element.editable('show');
|
||||
}, 400);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
elementTableSrpList.DataTable({
|
||||
"order": [[ 6, "asc" ]],
|
||||
"paging": false,
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": [1, 8],
|
||||
"orderable": false
|
||||
},
|
||||
{
|
||||
"targets": [4, 5],
|
||||
"type": "num"
|
||||
}
|
||||
],
|
||||
"stateSave": true,
|
||||
"stateDuration": 0
|
||||
});
|
||||
|
||||
// tooltip
|
||||
$("[rel=tooltip]").tooltip({ placement: 'top'});
|
||||
});
|
||||
|
||||
$('.srp').on('hidden', function(e, reason){
|
||||
if(reason === 'save' || reason === 'nochange') {
|
||||
let $next = $(this).closest('tr').next().find('.editable');
|
||||
|
||||
setTimeout(function() {
|
||||
$next.editable('show');
|
||||
}, 400);
|
||||
}
|
||||
});
|
||||
|
||||
$('table.srplist').DataTable({
|
||||
"order": [[ 6, "asc" ]],
|
||||
"paging": false,
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": [1, 8],
|
||||
"orderable": false
|
||||
},
|
||||
{
|
||||
"targets": [4, 5],
|
||||
"type": "num"
|
||||
}
|
||||
],
|
||||
"stateSave": true,
|
||||
"stateDuration": 0
|
||||
});
|
||||
|
||||
// tooltip
|
||||
$("[rel=tooltip]").tooltip({ placement: 'top'});
|
||||
});
|
||||
{% endblock extra_script %}
|
||||
</script>
|
||||
{% endblock extra_javascript %}
|
||||
|
||||
{% block extra_css %}
|
||||
{% 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">
|
||||
<i class="fa-solid fa-trash fa-fw"></i>
|
||||
</a>
|
||||
|
||||
{% if srpfleet.fleet_srp_code %}
|
||||
<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>
|
||||
@ -115,7 +116,6 @@
|
||||
<i class="fa-solid fa-check fa-fw"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user