Renamed "sorting" to "reorder", and the "sort-form" route to "order".
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/* The Mia! Accounting Flask Project
|
||||
* account-sort.js: The JavaScript for the account sorting form
|
||||
* account-order.js: The JavaScript for the account order
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2023 imacat.
|
||||
@ -23,15 +23,15 @@
|
||||
|
||||
// Initializes the page JavaScript.
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const list = document.getElementById("sort-account-list");
|
||||
const list = document.getElementById("account-order-list");
|
||||
const onReorder = function () {
|
||||
const accounts = Array.from(list.children);
|
||||
for (let i = 0; i < accounts.length; i++) {
|
||||
const input = document.getElementById("sort-" + accounts[i].dataset.id + "-no");
|
||||
const code = document.getElementById("sort-" + accounts[i].dataset.id + "-code");
|
||||
input.value = i + 1;
|
||||
const no = document.getElementById("account-order-" + accounts[i].dataset.id + "-no");
|
||||
const code = document.getElementById("account-order-" + accounts[i].dataset.id + "-code");
|
||||
no.value = String(i + 1);
|
||||
code.innerText = list.dataset.baseCode + "-" + ("000" + (i + 1)).slice(-3);
|
||||
}
|
||||
};
|
||||
initializeDragAndDropSorting(list, onReorder);
|
||||
initializeDragAndDropReordering(list, onReorder);
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
/* The Mia! Accounting Flask Project
|
||||
* drag-and-drop-sorting.js: The JavaScript for the sorting with drag-and-drop
|
||||
* drag-and-drop-reorder.js: The JavaScript for the reorder a list with drag-and-drop
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2023 imacat.
|
||||
@ -22,24 +22,24 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes the drag-and-drop sorting on a list.
|
||||
* Initializes the drag-and-drop reordering on a list.
|
||||
*
|
||||
* @param list {HTMLElement} the list to be sorted
|
||||
* @param list {HTMLElement} the list to be reordered
|
||||
* @param onReorder {(function())|*} The callback to reorder the items
|
||||
*/
|
||||
function initializeDragAndDropSorting(list, onReorder) {
|
||||
initializeMouseDragAndDropSorting(list, onReorder);
|
||||
initializeTouchDragAndDropSorting(list, onReorder);
|
||||
function initializeDragAndDropReordering(list, onReorder) {
|
||||
initializeMouseDragAndDropReordering(list, onReorder);
|
||||
initializeTouchDragAndDropReordering(list, onReorder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the drag-and-drop sorting with mouse.
|
||||
* Initializes the drag-and-drop reordering with mouse.
|
||||
*
|
||||
* @param list {HTMLElement} the list to be sorted
|
||||
* @param list {HTMLElement} the list to be reordered
|
||||
* @param onReorder {(function())|*} The callback to reorder the items
|
||||
* @private
|
||||
*/
|
||||
function initializeMouseDragAndDropSorting(list, onReorder) {
|
||||
function initializeMouseDragAndDropReordering(list, onReorder) {
|
||||
const items = Array.from(list.children);
|
||||
let dragged = null;
|
||||
items.forEach(function (item) {
|
||||
@ -60,13 +60,13 @@ function initializeMouseDragAndDropSorting(list, onReorder) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the drag-and-drop sorting with touch devices.
|
||||
* Initializes the drag-and-drop reordering with touch devices.
|
||||
*
|
||||
* @param list {HTMLElement} the list to be sorted
|
||||
* @param list {HTMLElement} the list to be reordered
|
||||
* @param onReorder {(function())|*} The callback to reorder the items
|
||||
* @private
|
||||
*/
|
||||
function initializeTouchDragAndDropSorting(list, onReorder) {
|
||||
function initializeTouchDragAndDropReordering(list, onReorder) {
|
||||
const items = Array.from(list.children);
|
||||
items.forEach(function (item) {
|
||||
item.addEventListener("touchstart", function () {
|
Reference in New Issue
Block a user