Add new sort everywhere needed, update API docs
parent
4d6a272795
commit
f9360b8ade
|
@ -101,7 +101,7 @@ import ChevronLeftIcon from 'primevue/icons/chevronleft';
|
||||||
import ChevronRightIcon from 'primevue/icons/chevronright';
|
import ChevronRightIcon from 'primevue/icons/chevronright';
|
||||||
import ChevronUpIcon from 'primevue/icons/chevronup';
|
import ChevronUpIcon from 'primevue/icons/chevronup';
|
||||||
import Ripple from 'primevue/ripple';
|
import Ripple from 'primevue/ripple';
|
||||||
import { DomHandler, UniqueComponentId } from 'primevue/utils';
|
import { DomHandler, UniqueComponentId, ObjectUtils } from 'primevue/utils';
|
||||||
import BaseCarousel from './BaseCarousel.vue';
|
import BaseCarousel from './BaseCarousel.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -553,15 +553,8 @@ export default {
|
||||||
_responsiveOptions.sort((data1, data2) => {
|
_responsiveOptions.sort((data1, data2) => {
|
||||||
const value1 = data1.breakpoint;
|
const value1 = data1.breakpoint;
|
||||||
const value2 = data2.breakpoint;
|
const value2 = data2.breakpoint;
|
||||||
let result = null;
|
|
||||||
|
|
||||||
if (value1 == null && value2 != null) result = -1;
|
return ObjectUtils.sort(value1, value2, -1, comparer);
|
||||||
else if (value1 != null && value2 == null) result = 1;
|
|
||||||
else if (value1 == null && value2 == null) result = 0;
|
|
||||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
|
||||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
|
||||||
|
|
||||||
return -1 * result;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < _responsiveOptions.length; i++) {
|
for (let i = 0; i < _responsiveOptions.length; i++) {
|
||||||
|
|
|
@ -887,6 +887,11 @@ export interface DataTableProps {
|
||||||
* Order to sort the data by default.
|
* Order to sort the data by default.
|
||||||
*/
|
*/
|
||||||
sortOrder?: number | undefined;
|
sortOrder?: number | undefined;
|
||||||
|
/**
|
||||||
|
* Determines how null values are sorted.
|
||||||
|
* @defaultValue 1
|
||||||
|
*/
|
||||||
|
nullSortOrder?: number;
|
||||||
/**
|
/**
|
||||||
* Default sort order of an unsorted column.
|
* Default sort order of an unsorted column.
|
||||||
* @defaultValue 1
|
* @defaultValue 1
|
||||||
|
|
|
@ -115,15 +115,8 @@ export default {
|
||||||
value.sort((data1, data2) => {
|
value.sort((data1, data2) => {
|
||||||
let value1 = ObjectUtils.resolveFieldData(data1, this.sortField);
|
let value1 = ObjectUtils.resolveFieldData(data1, this.sortField);
|
||||||
let value2 = ObjectUtils.resolveFieldData(data2, this.sortField);
|
let value2 = ObjectUtils.resolveFieldData(data2, this.sortField);
|
||||||
let result = null;
|
|
||||||
|
|
||||||
if (value1 == null && value2 != null) result = -1;
|
return ObjectUtils.sort(value1, value2, this.sortOrder, comparer);
|
||||||
else if (value1 != null && value2 == null) result = 1;
|
|
||||||
else if (value1 == null && value2 == null) result = 0;
|
|
||||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
|
||||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
|
||||||
|
|
||||||
return this.sortOrder * result;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -68,7 +68,7 @@ import ChevronLeftIcon from 'primevue/icons/chevronleft';
|
||||||
import ChevronRightIcon from 'primevue/icons/chevronright';
|
import ChevronRightIcon from 'primevue/icons/chevronright';
|
||||||
import ChevronUpIcon from 'primevue/icons/chevronup';
|
import ChevronUpIcon from 'primevue/icons/chevronup';
|
||||||
import Ripple from 'primevue/ripple';
|
import Ripple from 'primevue/ripple';
|
||||||
import { DomHandler } from 'primevue/utils';
|
import { DomHandler, ObjectUtils } from 'primevue/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'GalleriaThumbnails',
|
name: 'GalleriaThumbnails',
|
||||||
|
@ -443,15 +443,8 @@ export default {
|
||||||
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;
|
||||||
let result = null;
|
|
||||||
|
|
||||||
if (value1 == null && value2 != null) result = -1;
|
return ObjectUtils.sort(value1, value2, -1, comparer);
|
||||||
else if (value1 != null && value2 == null) result = 1;
|
|
||||||
else if (value1 == null && value2 == null) result = 0;
|
|
||||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
|
||||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
|
||||||
|
|
||||||
return -1 * result;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < this.sortedResponsiveOptions.length; i++) {
|
for (let i = 0; i < this.sortedResponsiveOptions.length; i++) {
|
||||||
|
|
|
@ -434,15 +434,8 @@ export default {
|
||||||
_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);
|
||||||
const value2 = ObjectUtils.resolveFieldData(node2.data, this.d_sortField);
|
const value2 = ObjectUtils.resolveFieldData(node2.data, this.d_sortField);
|
||||||
let result = null;
|
|
||||||
|
|
||||||
if (value1 == null && value2 != null) result = -1;
|
return ObjectUtils.sort(value1, value2, this.d_sortOrder, comparer);
|
||||||
else if (value1 != null && value2 == null) result = 1;
|
|
||||||
else if (value1 == null && value2 == null) result = 0;
|
|
||||||
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparer(value1, value2);
|
|
||||||
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
|
|
||||||
|
|
||||||
return this.d_sortOrder * result;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return _nodes;
|
return _nodes;
|
||||||
|
@ -462,22 +455,13 @@ export default {
|
||||||
multisortField(node1, node2, index) {
|
multisortField(node1, node2, index) {
|
||||||
const value1 = ObjectUtils.resolveFieldData(node1.data, this.d_multiSortMeta[index].field);
|
const value1 = ObjectUtils.resolveFieldData(node1.data, this.d_multiSortMeta[index].field);
|
||||||
const value2 = ObjectUtils.resolveFieldData(node2.data, this.d_multiSortMeta[index].field);
|
const value2 = ObjectUtils.resolveFieldData(node2.data, this.d_multiSortMeta[index].field);
|
||||||
let result = null;
|
const comparer = ObjectUtils.localeComparator();
|
||||||
|
|
||||||
if (value1 == null && value2 != null) result = -1;
|
if (value1 === value2) {
|
||||||
else if (value1 != null && value2 == null) result = 1;
|
return this.d_multiSortMeta.length - 1 > index ? this.multisortField(node1, node2, index + 1) : 0;
|
||||||
else if (value1 == null && value2 == null) result = 0;
|
|
||||||
else {
|
|
||||||
if (value1 === value2) {
|
|
||||||
return this.d_multiSortMeta.length - 1 > index ? this.multisortField(node1, node2, index + 1) : 0;
|
|
||||||
} else {
|
|
||||||
if ((typeof value1 === 'string' || value1 instanceof String) && (typeof value2 === 'string' || value2 instanceof String))
|
|
||||||
return this.d_multiSortMeta[index].order * ObjectUtils.localeComparator().compare(value1, value2);
|
|
||||||
else result = value1 < value2 ? -1 : 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.d_multiSortMeta[index].order * result;
|
return ObjectUtils.sort(value1, value2, this.d_multiSortMeta[index].order, comparer);
|
||||||
},
|
},
|
||||||
filter(value) {
|
filter(value) {
|
||||||
let filteredNodes = [];
|
let filteredNodes = [];
|
||||||
|
|
|
@ -18854,6 +18854,14 @@
|
||||||
"default": "",
|
"default": "",
|
||||||
"description": "Order to sort the data by default."
|
"description": "Order to sort the data by default."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "nullSortOrder",
|
||||||
|
"optional": true,
|
||||||
|
"readonly": false,
|
||||||
|
"type": "number",
|
||||||
|
"default": "1",
|
||||||
|
"description": "Determines how null values are sorted."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "defaultSortOrder",
|
"name": "defaultSortOrder",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
|
|
Loading…
Reference in New Issue