diff --git a/client/src/components/Collections/PairedElementView.vue b/client/src/components/Collections/PairedElementView.vue index 364832a22db..42cd1d9e8af 100644 --- a/client/src/components/Collections/PairedElementView.vue +++ b/client/src/components/Collections/PairedElementView.vue @@ -1,69 +1,58 @@ diff --git a/client/src/components/Collections/PairedListCollectionCreator.vue b/client/src/components/Collections/PairedListCollectionCreator.vue index d18767c3257..6e9ada15396 100644 --- a/client/src/components/Collections/PairedListCollectionCreator.vue +++ b/client/src/components/Collections/PairedListCollectionCreator.vue @@ -1,115 +1,898 @@ + + - diff --git a/client/src/utils/natural-sort.js b/client/src/utils/natural-sort.js deleted file mode 100644 index c620f169163..00000000000 --- a/client/src/utils/natural-sort.js +++ /dev/null @@ -1,38 +0,0 @@ -// Alphanumeric/natural sort fn -function naturalSort(a, b) { - // setup temp-scope variables for comparison evauluation - var re = /(-?[0-9.]+)/g; - - var x = a.toString().toLowerCase() || ""; - var y = b.toString().toLowerCase() || ""; - var nC = String.fromCharCode(0); - var xN = x.replace(re, `${nC}$1${nC}`).split(nC); - var yN = y.replace(re, `${nC}$1${nC}`).split(nC); - var xD = new Date(x).getTime(); - var yD = xD ? new Date(y).getTime() : null; - // natural sorting of dates - if (yD) { - if (xD < yD) { - return -1; - } else if (xD > yD) { - return 1; - } - } - - // natural sorting through split numeric strings and default strings - var oFxNcL; - - var oFyNcL; - for (var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++) { - oFxNcL = parseFloat(xN[cLoc]) || xN[cLoc]; - oFyNcL = parseFloat(yN[cLoc]) || yN[cLoc]; - if (oFxNcL < oFyNcL) { - return -1; - } else if (oFxNcL > oFyNcL) { - return 1; - } - } - return 0; -} - -export default naturalSort; diff --git a/client/src/utils/naturalSort.ts b/client/src/utils/naturalSort.ts new file mode 100644 index 00000000000..91a047b90dd --- /dev/null +++ b/client/src/utils/naturalSort.ts @@ -0,0 +1,45 @@ +// Alphanumeric/natural sort fn +export function naturalSort(a = "", b = ""): number { + // setup temp-scope variables for comparison evauluation + const re = /(-?[0-9.]+)/g; + + const x = a.toString().toLowerCase() || ""; + const y = b.toString().toLowerCase() || ""; + const nC = String.fromCharCode(0); + const xN = x.replace(re, `${nC}$1${nC}`).split(nC); + const yN = y.replace(re, `${nC}$1${nC}`).split(nC); + const xD = new Date(x).getTime(); + const yD = xD ? new Date(y).getTime() : null; + // natural sorting of dates + if (yD) { + if (xD < yD) { + return -1; + } else if (xD > yD) { + return 1; + } + } + + // natural sorting through split numeric strings and default strings + let oFxNcL; + + let oFyNcL; + for (let cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++) { + oFxNcL = parseFloat(xN[cLoc] || "") || xN[cLoc]; + oFyNcL = parseFloat(yN[cLoc] || "") || yN[cLoc]; + + // Check if either part is undefined + if (oFxNcL === undefined) { + return -1; + } + if (oFyNcL === undefined) { + return 1; + } + + if (oFxNcL < oFyNcL) { + return -1; + } else if (oFxNcL > oFyNcL) { + return 1; + } + } + return 0; +}