stuff
This commit is contained in:
parent
1614e6fbc7
commit
dfba4d933d
|
@ -7835,28 +7835,9 @@
|
|||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
}
|
||||
render() {
|
||||
let maxOffset = Math.floor(this.props.items.length/this.props.amount);
|
||||
let items = [], alphabet = {};
|
||||
if (BDFDB.ArrayUtils.is(this.props.items) && this.props.items.length) {
|
||||
if (!this.props.alphabetKey) items = this.props.items;
|
||||
else {
|
||||
let unsortedItems = [].concat(this.props.items);
|
||||
for (let key of ["0-9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]) {
|
||||
let numbers = key == "0-9", alphaItems = [];
|
||||
for (let item of unsortedItems) if (item && item[this.props.alphabetKey] && (numbers && !isNaN(parseInt(item[this.props.alphabetKey][0])) || item[this.props.alphabetKey].toUpperCase().indexOf(key) == 0)) alphaItems.push(item);
|
||||
for (let sortedItem of alphaItems) BDFDB.ArrayUtils.remove(unsortedItems, sortedItem);
|
||||
alphabet[key] = {items:BDFDB.ArrayUtils.keySort(alphaItems, this.props.alphabetKey), disabled:!alphaItems.length};
|
||||
}
|
||||
alphabet["?!"] = {items:BDFDB.ArrayUtils.keySort(unsortedItems, this.props.alphabetKey), disabled:!unsortedItems.length};
|
||||
for (let key in alphabet) items.push(alphabet[key].items);
|
||||
items = items.flat(10);
|
||||
}
|
||||
}
|
||||
return typeof this.props.renderItem != "function" || !items.length ? null : BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.paginationlist,
|
||||
children: [
|
||||
items.length > this.props.amount && BDFDB.ReactUtils.createElement("nav", {
|
||||
renderPagination() {
|
||||
let maxOffset = Math.ceil(this.props.items.length/this.props.amount) - 1;
|
||||
return this.props.items.length > this.props.amount && BDFDB.ReactUtils.createElement("nav", {
|
||||
className: BDFDB.disCN.paginationlistpagination,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
|
@ -7934,7 +7915,29 @@
|
|||
})
|
||||
})
|
||||
]
|
||||
}),
|
||||
});
|
||||
}
|
||||
render() {
|
||||
let items = [], alphabet = {};
|
||||
if (BDFDB.ArrayUtils.is(this.props.items) && this.props.items.length) {
|
||||
if (!this.props.alphabetKey) items = this.props.items;
|
||||
else {
|
||||
let unsortedItems = [].concat(this.props.items);
|
||||
for (let key of ["0-9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]) {
|
||||
let numbers = key == "0-9", alphaItems = [];
|
||||
for (let item of unsortedItems) if (item && item[this.props.alphabetKey] && (numbers && !isNaN(parseInt(item[this.props.alphabetKey][0])) || item[this.props.alphabetKey].toUpperCase().indexOf(key) == 0)) alphaItems.push(item);
|
||||
for (let sortedItem of alphaItems) BDFDB.ArrayUtils.remove(unsortedItems, sortedItem);
|
||||
alphabet[key] = {items:BDFDB.ArrayUtils.keySort(alphaItems, this.props.alphabetKey), disabled:!alphaItems.length};
|
||||
}
|
||||
alphabet["?!"] = {items:BDFDB.ArrayUtils.keySort(unsortedItems, this.props.alphabetKey), disabled:!unsortedItems.length};
|
||||
for (let key in alphabet) items.push(alphabet[key].items);
|
||||
items = items.flat(10);
|
||||
}
|
||||
}
|
||||
return typeof this.props.renderItem != "function" || !items.length ? null : BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.paginationlist,
|
||||
children: [
|
||||
this.renderPagination(),
|
||||
items.length > this.props.amount && this.props.alphabetKey && BDFDB.ReactUtils.createElement("nav", {
|
||||
className: BDFDB.disCN.paginationlistalphabet,
|
||||
children: Object.keys(alphabet).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
|
||||
|
@ -7943,10 +7946,12 @@
|
|||
children: key
|
||||
}))
|
||||
}),
|
||||
this.props.header,
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.paginationlistcontent,
|
||||
children: items.slice(this.props.offset * this.props.amount, (this.props.offset + 1) * this.props.amount).map(data => {return this.props.renderItem(data);})
|
||||
})
|
||||
children: items.slice(this.props.offset * this.props.amount, (this.props.offset + 1) * this.props.amount).map((data, i) => {return this.props.renderItem(data, i);}).flat(10).filter(n => n)
|
||||
}),
|
||||
this.props.copyToBottom && this.renderPagination()
|
||||
].flat(10).filter(n => n)
|
||||
});
|
||||
}
|
||||
|
@ -8408,10 +8413,7 @@
|
|||
})
|
||||
]
|
||||
}), "title", "data", "settings", "renderLabel", "cardClassName", "cardStyle", "onCheckboxChange", "maxWidth", "fullWidth", "pagination"));
|
||||
return !this.props.data.length ? null : BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.settingstablelist, this.props.className),
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Flex, {
|
||||
let header = BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCN.settingstableheaders,
|
||||
align: InternalComponents.LibraryComponents.Flex.Align.STRETCH,
|
||||
style: this.props.vertical && this.props.biggestWidth ? {
|
||||
|
@ -8430,12 +8432,18 @@
|
|||
children: setting
|
||||
})
|
||||
}))
|
||||
}),
|
||||
!BDFDB.ObjectUtils.is(this.props.pagination) ? this.props.data.map(renderItem) : BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.PaginatedList, Object.assign({}, this.props.pagination, {
|
||||
});
|
||||
let usePagination = BDFDB.ObjectUtils.is(this.props.pagination);
|
||||
return !this.props.data.length ? null : BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.settingstablelist, this.props.className),
|
||||
children: [
|
||||
!usePagination && header,
|
||||
!usePagination ? this.props.data.map(renderItem) : BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.PaginatedList, Object.assign({}, this.props.pagination, {
|
||||
header: header,
|
||||
items: this.props.data,
|
||||
renderItem: renderItem
|
||||
}))
|
||||
]
|
||||
].filter(n => n)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue