pull/4299/head
Tuğçe Küçükoğlu 2023-08-18 15:52:27 +03:00
parent 506fb3ee29
commit 0a97b8fe7e
6 changed files with 16 additions and 7 deletions

View File

@ -2589,7 +2589,8 @@ export default {
let innerHTML = ''; let innerHTML = '';
if (this.responsiveOptions) { if (this.responsiveOptions) {
let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * new Intl.Collator(undefined, { numeric: true }).compare(o1.breakpoint, o2.breakpoint)); const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * comparer(o1.breakpoint, o2.breakpoint));
for (let i = 0; i < responsiveOptions.length; i++) { for (let i = 0; i < responsiveOptions.length; i++) {
let { breakpoint, numMonths } = responsiveOptions[i]; let { breakpoint, numMonths } = responsiveOptions[i];

View File

@ -528,6 +528,7 @@ export default {
if (this.responsiveOptions && !this.isUnstyled) { if (this.responsiveOptions && !this.isUnstyled) {
let _responsiveOptions = [...this.responsiveOptions]; let _responsiveOptions = [...this.responsiveOptions];
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
_responsiveOptions.sort((data1, data2) => { _responsiveOptions.sort((data1, data2) => {
const value1 = data1.breakpoint; const value1 = data1.breakpoint;
@ -537,7 +538,7 @@ export default {
if (value1 == null && value2 != null) result = -1; if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1; else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0; else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return -1 * result; return -1 * result;

View File

@ -523,6 +523,7 @@ export default {
} }
data.sort((data1, data2) => { data.sort((data1, data2) => {
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
let value1 = resolvedFieldDatas.get(data1); let value1 = resolvedFieldDatas.get(data1);
let value2 = resolvedFieldDatas.get(data2); let value2 = resolvedFieldDatas.get(data2);
@ -531,7 +532,7 @@ export default {
if (value1 == null && value2 != null) result = -1; if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1; else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0; else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return this.d_sortOrder * result; return this.d_sortOrder * result;
@ -567,7 +568,9 @@ export default {
if (typeof value1 === 'string' || value1 instanceof String) { if (typeof value1 === 'string' || value1 instanceof String) {
if (value1.localeCompare && value1 !== value2) { if (value1.localeCompare && value1 !== value2) {
return this.d_multiSortMeta[index].order * new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
return this.d_multiSortMeta[index].order * comparer(value1, value2);
} }
} else { } else {
result = value1 < value2 ? -1 : 1; result = value1 < value2 ? -1 : 1;

View File

@ -110,6 +110,7 @@ export default {
sort() { sort() {
if (this.value) { if (this.value) {
const value = [...this.value]; const value = [...this.value];
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
value.sort((data1, data2) => { value.sort((data1, data2) => {
let value1 = ObjectUtils.resolveFieldData(data1, this.sortField); let value1 = ObjectUtils.resolveFieldData(data1, this.sortField);
@ -119,7 +120,7 @@ export default {
if (value1 == null && value2 != null) result = -1; if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1; else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0; else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return this.sortOrder * result; return this.sortOrder * result;

View File

@ -438,6 +438,8 @@ export default {
if (this.responsiveOptions && !this.isUnstyled) { if (this.responsiveOptions && !this.isUnstyled) {
this.sortedResponsiveOptions = [...this.responsiveOptions]; this.sortedResponsiveOptions = [...this.responsiveOptions];
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
this.sortedResponsiveOptions.sort((data1, data2) => { this.sortedResponsiveOptions.sort((data1, data2) => {
const value1 = data1.breakpoint; const value1 = data1.breakpoint;
const value2 = data2.breakpoint; const value2 = data2.breakpoint;
@ -446,7 +448,7 @@ export default {
if (value1 == null && value2 != null) result = -1; if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1; else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0; else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return -1 * result; return -1 * result;

View File

@ -417,6 +417,7 @@ export default {
}, },
sortNodesSingle(nodes) { sortNodesSingle(nodes) {
let _nodes = [...nodes]; let _nodes = [...nodes];
const comparer = new Intl.Collator(undefined, { numeric: true }).compare;
_nodes.sort((node1, node2) => { _nodes.sort((node1, node2) => {
const value1 = ObjectUtils.resolveFieldData(node1.data, this.d_sortField); const value1 = ObjectUtils.resolveFieldData(node1.data, this.d_sortField);
@ -426,7 +427,7 @@ export default {
if (value1 == null && value2 != null) result = -1; if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1; else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0; else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2); else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0; else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return this.d_sortOrder * result; return this.d_sortOrder * result;