Skip to content

Add allow_sorting Property#126

Merged
gbeeley merged 4 commits into
masterfrom
add-allow-sort-property
Jun 16, 2026
Merged

Add allow_sorting Property#126
gbeeley merged 4 commits into
masterfrom
add-allow-sort-property

Conversation

@Lightning11wins

@Lightning11wins Lightning11wins commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This PR adds the allow_sorting property to table-column widgets that allow the app designer to disable clicking the header row of a table to sort by that given column. It also adds the allow_sorting property to the entire table, where it serves as a default for columns where the property is not specified. This value defaults to yes, which gives the current behavior.

This functionality will be very useful for apps where clicking the header row to sort is either not needed, does not make sense, or is just simply very hard to implement correctly.

@Lightning11wins Lightning11wins self-assigned this Jun 11, 2026
@Lightning11wins Lightning11wins added ai-review Request AI review for PRs. documentation Changes, improvements, or fixes to documentation files. size: trivial Easy to review, probably ~100 lines or fewer. labels Jun 11, 2026
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

Adds an allow_sorting property to both widget/table and widget/table-column, letting app designers prevent header-click sorting on individual columns or the whole table. The table-level value acts as the default for columns that do not specify it, and everything defaults to yes to preserve existing behavior.

  • The C backend reads the property via htrGetBoolean with the correct two-level default chain (column → table → 1) and emits a per-column integer flag in the JS init block.
  • The JavaScript click handler gates the sort path with a simple truthy check on cols[ly.colnum].allow_sorting, so clicking a disabled column header is a no-op.
  • Documentation entries in widgets.xml accurately describe both the table-level and column-level properties and their inheritance relationship.

Confidence Score: 4/5

Safe to merge; the feature is additive and defaults to the existing behavior, so no regressions are expected.

The two-level default chain in C is correct, the per-column emit is properly formatted, and the JS guard is straightforward. The only gap is that non-sortable header cells give no visual cue to the user — the cursor and appearance stay identical to sortable columns, so a click simply disappears silently.

centrallix-os/sys/js/htdrv_table.js — the header-cell rendering loop could apply a cursor hint when allow_sorting is false.

Important Files Changed

Filename Overview
centrallix/htmlgen/htdrv_table.c Adds allow_sorting to both httbl_col and httbl_struct, reads it via htrGetBoolean with correct defaulting (table-level defaults to 1, column-level defaults to the table value), and emits it as an integer per-column in the JS init block.
centrallix-os/sys/js/htdrv_table.js Guards the header-click sort path with cols[ly.colnum].allow_sorting; click is silently swallowed when sorting is disabled, with no cursor or visual indicator change for the user.
centrallix-doc/Widgets/widgets.xml Adds documentation entries for the table-level and column-level allow_sorting properties; descriptions are accurate and consistent with the implementation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User clicks table header cell] --> B{subkind == headercell?}
    B -- No --> C[Not a header click]
    B -- Yes --> D{allow_sorting == 1?}
    D -- No --> E[No-op: click ignored]
    D -- Yes --> F[Build new sort order]
    F --> G{Column in sort order?}
    G -- asc --> H[Toggle to desc]
    G -- desc --> I[Toggle to asc]
    G -- absent --> J[Prepend as asc]
    H & I & J --> K[Invoke OrderObject on osrc]

    subgraph C render time
        L[Read table allow_sorting default=1] --> M[Per column: read allow_sorting default=table value]
        M --> N[Emit allow_sorting as INT in JS init]
    end
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
centrallix-os/sys/js/htdrv_table.js:3090
**No visual feedback for non-sortable header cells.** When `allow_sorting` is `0`, clicking the header is silently swallowed, but the column header renders identically to a sortable one — same cursor, same appearance. A user who clicks a disabled header gets no indication that the action is unsupported. Applying `cursor: not-allowed` to the header cell at setup time (in the `for(var i…)` loop around line 2305) when `!t.cols[i].allow_sorting` would make the intent immediately clear.

Reviews (1): Last reviewed commit: "Rename allow_sort to allow_sorting." | Re-trigger Greptile

@Lightning11wins

Copy link
Copy Markdown
Contributor Author

The issue raised by Greptile is a known lack of feedback that's common across Centrallix, and it's fixed in #90, so we'll ignore it here.

@Lightning11wins

Copy link
Copy Markdown
Contributor Author

This PR is ready for human review.

@Lightning11wins Lightning11wins requested review from gbeeley and nboard and removed request for nboard June 12, 2026 16:21

@gbeeley gbeeley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good - thanks!

@gbeeley gbeeley merged commit 536a082 into master Jun 16, 2026
2 checks passed
@Lightning11wins Lightning11wins deleted the add-allow-sort-property branch June 16, 2026 20:30
@Lightning11wins Lightning11wins removed the request for review from nboard June 16, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request AI review for PRs. documentation Changes, improvements, or fixes to documentation files. size: trivial Easy to review, probably ~100 lines or fewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants