Skip to content
Merged
Changes from 9 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
15 changes: 14 additions & 1 deletion specifyweb/backend/stored_queries/batch_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,20 @@ def _get_orig_column(string_id: str):

# We would have arbitarily sorted the columns, so our columns will not be correct.
# Rather than sifting the data, we just add a default visual order.
visual_order = Func.first(headers_enumerated)
visual_order_groups: list[list[int]] = [[] for _ in visible_fields]
for index, (key, _header) in headers_enumerated:
# Find the column's original position if it existed in the origin query
original_place = key[0]
duplicate_index = key[1]
if original_place < len(visible_fields):
visual_order_groups[original_place].insert(duplicate_index, index)
else:
# New field/column. Add it to the end of the dataset.
visual_order_groups.append([index])

visual_order: list[int] = []
for bucket in visual_order_groups:
visual_order.extend(bucket)

headers = Func.second(key_and_headers)

Expand Down
Loading