Skip to content

[Refactor:InstructorUI] Consolidate Table Sorting#12996

Merged
bmcutler merged 94 commits into
mainfrom
consolidate-table-sort-by-column
Jul 17, 2026
Merged

[Refactor:InstructorUI] Consolidate Table Sorting#12996
bmcutler merged 94 commits into
mainfrom
consolidate-table-sort-by-column

Conversation

@NicholasCiuica

@NicholasCiuica NicholasCiuica commented Jul 2, 2026

Copy link
Copy Markdown
Member

Why is this Change Important & Necessary?

Related to #12960

I'm going to tackle this issue in parts. This first PR will be consolidating all the table sorting logic, as currently each table requires the declaration of its own sorting function and helper functions, but these share lots of code with each other. This will make it easier to create multisortable columns, but also will make it easier to add new sortable tables.

What is the New Behavior?

Now all tables on submitty that have sortable columns share the same sorting logic, because they all use the new SortableTableHeader Vue component. This makes it easy to add or remove sortable columns from existing tables, or make new sortable tables.

To enable saving table sort between reloads, the new TableSortManager Vue component needs to be added to the same Twig page as the sortable table. The only table that I have enabled this persistent sorting behavior for is the details-table, to match current persistent behavior. When multisortable column behavior is introduced, it will build off of the TableSortManager.

What steps should a reviewer take to reproduce or test the bug or new feature?

Ensure that the sortable table headers still work for all the following tables. Note that some tables now have more sortable columns than before (e.g. docker-table is now sortable by tags and owners).

Log in as instructor:

Log in as superuser:

NOTE: To test sortable columns that may have homogenous data by default (e.g. docker-table tags all being "latest"), you can change the text in the columns using your browser's dev/inspect tools and the sorting should still work.

Please let me know if there are any other sortable tables in Submitty that I missed in this PR, and I will handle them in another PR.

EDIT: I have made a number of naming changes to variables related to column headers and sorting in an attempt to make the code easier to understand and more consistent. Please let me know what you think of these changes. Besides name changes, the majority of the new functionality code is concentrated in the newly created files of this PR.

EDIT2: I have found some examples where database entries are sorted before being sent to the frontend, such as when the Randomize Students option is selected above the details-table for grading. Assessing whether this backend sorting is still needed and making any changes or improvements should be done in another PR.

EDIT3: There are still some tables that use a sortTable() function (the activity dashboard and the content_upload_table) which I may convert in a future PR, depending on how they are sorted and if they would benefit from the new components introduced in this PR.

EDIT4: I've added also a slight CSS change that gives active column headers a text-shadow ("double-bold") effect. This is to stand out against the regular bold of the column headers. I believe an effect like this was intended initially, since active-headers were explicitly made bold with CSS, but table headers are already implicitly bold by default.

Inactive:
Screenshot 2026-07-10 122604

Active (being sorted by):
Screenshot 2026-07-10 122609

Automated Testing & Documentation

Cypress tests that currently test table sorting should still work.
The new Vue Components have their own Cypress tests. Thank you @jndlansh !!!
Should this feature be documented on submitty.org? Let me know.

@github-project-automation github-project-automation Bot moved this to Seeking Reviewer in Submitty Development Jul 2, 2026
@automateprojectmangement automateprojectmangement Bot moved this from Seeking Reviewer to Work in Progress in Submitty Development Jul 2, 2026
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.91892% with 90 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.11%. Comparing base (60617d0) to head (0493762).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #12996      +/-   ##
============================================
- Coverage     21.12%   21.11%   -0.01%     
  Complexity    10114    10114              
============================================
  Files           279      282       +3     
  Lines         38125    38231     +106     
  Branches        578      596      +18     
============================================
+ Hits           8053     8074      +21     
- Misses        29507    29575      +68     
- Partials        565      582      +17     
Flag Coverage Δ
autograder 21.16% <ø> (ø)
js 1.73% <0.00%> (-0.05%) ⬇️
migrator 100.00% <ø> (ø)
php 20.20% <ø> (+<0.01%) ⬆️
python_submitty_utils 79.83% <ø> (ø)
submitty_daemon_jobs 91.13% <ø> (ø)
vue 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

typescript is picky about having functions with the same name, so in order to expose sortTableByColumn on window I have to comment out all other sortTableByColumn functions. Everything commented out here will eventually be removed or refactored
... but now I need to change the way that the items inside row elements are found, because being able to toggle columns messes with predefined column indexes
this code only seems to trigger for the section column, but the styling added doesn't actually seem to apply, and anyways this styling doesn't seem meaningful; there is already the Section header, so I see no reason to put "section" as ::before content

@mattLif mattLif left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requested changes are being made in another PR. Approving this one.

@NicholasCiuica NicholasCiuica moved this from Work in Progress to Awaiting Maintainer Review in Submitty Development Jul 14, 2026
@NicholasCiuica

Copy link
Copy Markdown
Member Author

Requested changes are being made in another PR. Approving this one.

I address these changes and the ongoing table highlight issue in my PR #13037

@jndlansh jndlansh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I approve. Great work @NicholasCiuica !

Comment thread site/app/templates/misc/TableSortComponents.twig
Comment thread site/cypress/component/SortableTableHeader.cy.js Outdated
Comment thread site/cypress/component/SortableTableHeader.cy.js Outdated
Comment thread site/public/css/simple-grading.css
Comment thread site/ts/ta-grading-cookies.ts
@github-project-automation github-project-automation Bot moved this from Awaiting Maintainer Review to Work in Progress in Submitty Development Jul 15, 2026
@NicholasCiuica
NicholasCiuica marked this pull request as draft July 15, 2026 14:09
@NicholasCiuica

NicholasCiuica commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

@jndlansh I came across an issue where the TableSortManager would emit the restore-table-sort before DOM content was loaded, so I made another commit to reimplement the window.addEventListener on DOMContentLoaded. Do you know of any better way to wait until the table and its contents are loaded on the page before trying to restore their sort, without having to rely on external DOM? Currently my change causes some component tests to fail.

@NicholasCiuica

Copy link
Copy Markdown
Member Author

@jndlansh I came across an issue where the TableSortManager would emit the restore-table-sort before DOM content was loaded, so I made another commit to reimplement the window.addEventListener on DOMContentLoaded. Do you know of any better way to wait until the table and its contents are loaded on the page before trying to restore their sort, without having to rely on external DOM? Currently my change causes some component tests to fail.

I've done some research on the topic of making an emit after the DOM content is loaded, and have not found an easy solution to our problem here. I have implemented a hacky fix to our TableSortManager component tests that manually triggers a load event before listening for the emit response, but I do not think this is a good solution. Any suggestions would be much appreciated.

bmcutler pushed a commit that referenced this pull request Jul 15, 2026
### Why is this Change Important & Necessary?
Fixes #12584, Related to #12996 
Should only be merged after #12996 for easier testing and important CSS
changes

### What is the New Behavior?
Course staff are now properly highlighted on the Simple Grading and
Gradeable Details pages. Also, the Gradeable Details page also uses the
same blue to highlight the course staff as the rest of the gradeable
tables.

### What steps should a reviewer take to reproduce or test the bug or
new feature?

Please follow the testing procedure on multiple browsers (at least
Chromium and Firefox).

1. Go to the main branch
2. Go to the following gradeables, and for each of them you should see
that staff are not highlighted in the tables:
i. Open a gradeable with student file submission
ii. Make a Numeric gradeable with at least on numeric column and at
least one text column
iii. Make a Checkpoint gradeable with at least one checkpoint column and
at least one text column

<img width="745" height="311" alt="image"
src="https://github.com/user-attachments/assets/817dcf9c-5acd-4f8b-af05-9775335adb2f"
/>

6. Now go to this branch and submitty_install_site
7. Open each gradeable that you opened/made on main and you should now
see that staff are highlighted in the tables:

<img width="738" height="274" alt="Screenshot 2026-07-14 111103"
src="https://github.com/user-attachments/assets/19f8d392-7dd7-449f-b009-baecba670e7c"
/>

EDIT: Please ensure that on the numeric and checkpoint gradeables row
highlighting stops at the user's identifying information, so that the
highlight doesn't interfere with checkpoint grading cells or
numeric/text input cells.

e.g.
<img width="724" height="244" alt="image"
src="https://github.com/user-attachments/assets/9516baba-2bfc-436c-8162-41cdb5966ecc"
/>


### Automated Testing & Documentation
There are currently no tests that check for highlighted staff rows in
the gradeable tables. Should there be?
@jndlansh

Copy link
Copy Markdown
Contributor

@NicholasCiuica I think we wait for the DOM content to load (Let the browser finish Parsing the HTML)

@NicholasCiuica
NicholasCiuica marked this pull request as ready for review July 15, 2026 19:07
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to Seeking Reviewer in Submitty Development Jul 15, 2026

@mattLif mattLif left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rereviewed using same pages, and all previous issues have been addressed or are actively being addressed in a new PR. Code still looks good too. Good work Nick, I approve.

Since sorting by section is not currently implemented, I'll remove it for now. This feature will require some DOM manipulation that might be better saved for when more of the table is refactored to Vue.
@bmcutler
bmcutler merged commit 4c15444 into main Jul 17, 2026
28 checks passed
@bmcutler
bmcutler deleted the consolidate-table-sort-by-column branch July 17, 2026 15:24
@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Done in Submitty Development Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants