Skip to content

feat: add config default sorting for proposal and dataset tables#2249

Open
abdimo101 wants to merge 12 commits intomasterfrom
config-default-sorting
Open

feat: add config default sorting for proposal and dataset tables#2249
abdimo101 wants to merge 12 commits intomasterfrom
config-default-sorting

Conversation

@abdimo101
Copy link
Member

@abdimo101 abdimo101 commented Mar 4, 2026

Description

This PR adds support for configurable default sorting in datasets and proposals tables through the backend configuration file.

Motivation

Background on use case, changes needed

Fixes:

Please provide a list of the fixes implemented in this PR

  • Items added

Changes:

Please provide a list of the changes implemented by this PR

  • changes made

Tests included

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)

Documentation

  • swagger documentation updated [required]
  • official documentation updated [nice-to-have]

official documentation info

If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included

Backend version

  • Does it require a specific version of the backend
  • which version of the backend is required:

Summary by Sourcery

Add support for configurable default sorting of proposals and datasets tables based on backend configuration, and cover this behavior with end-to-end tests.

New Features:

  • Allow proposals list default sort column and direction to be driven by configuration, including handling multi-field columns.
  • Allow datasets list default sort column and direction to be driven by configuration when no explicit sort is set.
  • Extend table column model to support declarative sort direction in configuration.

Tests:

  • Add Cypress tests verifying proposals are default-sorted by configured PI name column.
  • Add Cypress tests verifying datasets are default-sorted by configured start time column.

@abdimo101 abdimo101 requested a review from a team as a code owner March 4, 2026 15:32
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In datasets.effects, the map handler mutates the params object from the store (params.limits.order is set in place); consider cloning params/limits before modifying to preserve state immutability guarantees.
  • The logic for deriving default sort column/direction (including handling comma-separated column names) is now duplicated and slightly inconsistent between proposals and datasets; consider extracting a shared helper to compute the order value from config to keep behavior aligned and easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `datasets.effects`, the `map` handler mutates the `params` object from the store (`params.limits.order` is set in place); consider cloning `params`/`limits` before modifying to preserve state immutability guarantees.
- The logic for deriving default sort column/direction (including handling comma-separated column names) is now duplicated and slightly inconsistent between proposals and datasets; consider extracting a shared helper to compute the `order` value from config to keep behavior aligned and easier to maintain.

## Individual Comments

### Comment 1
<location path="src/app/state-management/effects/proposals.effects.ts" line_range="65-69" />
<code_context>
-        if (sortColumn && sortDirection) {
-          limitsParam.order = `${sortColumn}:${sortDirection}`;
-        }
+        const column = sortColumn
+          ? sortColumn.includes(",")
+            ? sortColumn.split(",")[0]
+            : sortColumn
+          : defaultColumn;
</code_context>
<issue_to_address>
**suggestion:** Trim the extracted column name when splitting on commas to avoid accidental whitespace issues.

Since `sortColumn` may contain multiple comma-separated names from config (e.g. `"pi_lastname, pi_firstname"`), the first element after `split(',')` might include leading/trailing spaces. Please trim it, e.g. `sortColumn.split(',')[0].trim()`, so the selected column is stable even if config spacing changes.

```suggestion
        const column = sortColumn
          ? sortColumn.includes(",")
            ? sortColumn.split(",")[0].trim()
            : sortColumn
          : defaultColumn;
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@abdimo101 abdimo101 requested review from Junjiequan and nitrosx March 9, 2026 14:10
Copy link
Member

@nitrosx nitrosx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall is fine, can you please add some documentation on how to configure it?

@Junjiequan
Copy link
Member

I think the sourcery comment makes sense

@abdimo101
Copy link
Member Author

Overall is fine, can you please add some documentation on how to configure it?

Documentation for it has been added to this PR: SciCatProject/backend#2587

@abdimo101 abdimo101 requested a review from nitrosx March 16, 2026 08:20
@abdimo101 abdimo101 enabled auto-merge (squash) March 16, 2026 17:12
Copy link
Member

@nitrosx nitrosx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some documentation and also the changes that needs to happen on the frontend config files to use this feature?
If I am not mistaken, you need to add the key sort to the column that you want to use for sorting as a default, correct?

@abdimo101 abdimo101 disabled auto-merge March 17, 2026 14:28
@Junjiequan Junjiequan force-pushed the config-default-sorting branch from 0f70164 to 07e067e Compare March 24, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants