Skip to content

Display column index in table THEAD#240

Closed
rossjones wants to merge 1 commit into
mainfrom
table-header-row
Closed

Display column index in table THEAD#240
rossjones wants to merge 1 commit into
mainfrom
table-header-row

Conversation

@rossjones
Copy link
Copy Markdown
Contributor

Currently when there is no header name specified, the first row in the table is not shown. To allow users to relate this to the data they can see in their source file, we instead show the column index in base26 (A, B, C ... AA, AB, AC ... etc).

Currently the selectable_table will include this new row in the calculation for the selection, and so we need to make sure we account for it when saving selections.

@rossjones rossjones requested review from alaric-rd and simonwo June 10, 2025 10:32
Copy link
Copy Markdown
Member

@simonwo simonwo left a comment

Choose a reason for hiding this comment

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

We discussed and:

  • I understood that this is the first of 3-4 PRs to add support for source sheet headers, to be used in the validation errors designs. So some of this is temporary and meant to be updated later.
  • I clarified that "no header" which is currently used on the sheet selector is probably still a valid design choice, so we may not always want indexes/mapped headers. It's possible that sheet headers are helpful in all cases, and it's also possible that they are only helpful when the user needs to identify cells in the source sheet and are noise otherwise. Designers may want to choose between these options too. So "none", "source" and "mapped" may all be valid options for headers.

}

static fromElement(element) {
if (element.parentElement.tagName == "THEAD"){
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.

Elsewhere uses nodeName… is the difference significant?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nodeName is typically used for attributes whereas tagName is used for element tag names. nodeName does the right thing for elements, but tagName will break for attributes. I'm not aware of any idioms wrt these two, but if there is one, am happy to change to using it.

Comment on lines +25 to +31
<thead>
<tr>
{% for i in range(0, row_length) -%}
<th>{{ i | encode_header }}</th>
{% endfor %}
</tr>
</thead>
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.

The user may make a selection of headers that doesn't include the first N columns:

image

So we can't assume that the columns start from A:

image

In the above example the first name column is incorrectly labelled as column A, when in their source spreadsheet it is column C.

In a future PR we'll need to be using the indexes for that column as found in the source spreadsheet if we are going to output them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I've corrected this in the follow on PR.

Comment on lines 701 to 710
// If we have HTML elements defined on the page (with specific names) then they will be used
// to store the top left row/column and bottom right row/column.
if (tlRowTarget) { tlRowTarget.value = selection.startCell.row; }
// to store the top left row/column and bottom right row/column.
// We reduce the row index by one to handle the table chrome
// which should not be included in the selection.
if (tlRowTarget) { tlRowTarget.value = selection.startCell.row - 1; }
if (tlColTarget) { tlColTarget.value = selection.startCell.col; }
if (brRowTarget) { brRowTarget.value = selection.endCell.row; }
if (brRowTarget) { brRowTarget.value = selection.endCell.row - 1; }
if (brColTarget) { brColTarget.value = selection.endCell.col; }
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.

I guess in a future PR we will need to fix this to not assume that the header is always present.

@rossjones
Copy link
Copy Markdown
Contributor Author

After making progress on #241 I think this PR is only useful for guiding the upcoming UI changes in 241, so I won't merge this, and will just delete once 241 is ready.

@rossjones
Copy link
Copy Markdown
Contributor Author

Not needed anymore, superceded by #241

@rossjones rossjones closed this Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants