Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to auto-sort columns alphabetically #2252

Merged
merged 4 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
}

.columnConfigItemName {
width: 110px;
text-overflow: ellipsis;
overflow: hidden;
line-height: 24px;
Expand Down
21 changes: 21 additions & 0 deletions src/components/ColumnsConfiguration/ColumnsConfiguration.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ export default class ColumnsConfiguration extends React.Component {
this.props.handleColumnsOrder(this.props.order.map(order => ({ ...order, visible: false })));
}

autoSort() {
const defaultOrder = ['objectId', 'createdAt', 'updatedAt', 'ACL']
const order = {
default: [],
other: []
};
for (const column of this.props.order) {
const index = defaultOrder.indexOf(column.name);
if (index !== -1) {
order.default[index] = column;
} else {
order.other.push(column)
}
}
this.props.handleColumnsOrder([...order.default.filter(column => column), ...order.other.sort((a,b) => a.name.localeCompare(b.name))]);
}

render() {
const { handleColumnDragDrop, handleColumnsOrder, order, disabled } = this.props;
let [ title, entry ] = [styles.title, styles.entry ].map(className => (
Expand Down Expand Up @@ -118,6 +135,10 @@ export default class ColumnsConfiguration extends React.Component {
color='white'
value='Show all'
onClick={this.showAll.bind(this)} />
<Button
color='white'
value='Autosort'
onClick={this.autoSort.bind(this)} />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
right: 0;
border-radius: 5px 0 5px 5px;
background: #797691;
width: 220px;
width: 320px;
font-size: 14px;

.columnConfigContainer {
Expand Down