Fix pagination controls, move mixin to common app, fix pagination invocation on all views, and other random bug fixes
This commit is contained in:
parent
7edefe23c3
commit
6a61b79bbe
425 changed files with 51656 additions and 243 deletions
22
staticfiles/admin/fields/thousand_sep_field.js
Normal file
22
staticfiles/admin/fields/thousand_sep_field.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
function convertPersianToEnglish(value) {
|
||||
const persianNumbers = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||
const englishNumbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||
|
||||
for (let i = 0; i < persianNumbers.length; i++) {
|
||||
value = value.replace(new RegExp(persianNumbers[i], 'g'), englishNumbers[i]);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function formatNumber(input) {
|
||||
let value = convertPersianToEnglish(input.value);
|
||||
// Remove any existing thousand separators and non-digit characters
|
||||
value = value.replace(/,/g, '').replace(/\D/g, '');
|
||||
|
||||
// Add thousand separators
|
||||
value = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
|
||||
// Update the input value
|
||||
input.value = value;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue