From a3051e606478b2e5ce0ce4f369b0429ef9acca35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 04:19:11 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(web):=20a=20sheet=20pages=20do?= =?UTF-8?q?wn=20its=20rows=20and=20across=20its=20columns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A window at a time, both ways, moved by links: 50 rows and 12 columns, so a page lands on a screen instead of being dragged sideways past a scrollbar that is not there. The footer counts the window against the sheet — "51–100 / 5000" down the rows, "M–X / 40" across them — and a step with nowhere to go stays in place, dimmed. The xlsx dimension is treated as a claim, not a fact: a size the reading does not bear out is not printed at all, the step onward is proved by a cell arriving past the window rather than derived from the count, and the page asked for is the page drawn — clamping to a wrong dimension would snap a reader back to the first window every time they stepped on. --- crates/izlek-web/src/board.rs | 12 +- crates/izlek-web/src/detail.rs | 92 +++++++-- crates/izlek-web/src/i18n.rs | 9 +- crates/izlek-web/src/sheet.rs | 219 +++++++++++++++++----- crates/izlek-web/tests/fixtures/wide.xlsx | Bin 0 -> 2748 bytes crates/izlek-web/tests/http.rs | 77 ++++++++ style/main.scss | 55 +++++- 7 files changed, 394 insertions(+), 70 deletions(-) create mode 100644 crates/izlek-web/tests/fixtures/wide.xlsx diff --git a/crates/izlek-web/src/board.rs b/crates/izlek-web/src/board.rs index 6c7dcdc..72cb1f7 100644 --- a/crates/izlek-web/src/board.rs +++ b/crates/izlek-web/src/board.rs @@ -500,6 +500,8 @@ struct BoardQuery { tab: Option, file: Option, sheet: Option, + rows: Option, + cols: Option, refusal: Option, on: Option, sort: Option, @@ -550,6 +552,14 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { .as_deref() .and_then(|value| value.parse::().ok()) .unwrap_or(0); + // Which window of it is drawn, in pages of rows and pages of columns. + let page_of = |value: Option<&str>| { + value + .and_then(|value| value.parse::().ok()) + .unwrap_or(0) + }; + let open_rows = page_of(query.rows.as_deref()); + let open_cols = page_of(query.cols.as_deref()); // `?task=X&new=1` together would render both modals at once — two // document-level datepicker listeners double-stepping the month nav — so // an open task wins and `new` is ignored. @@ -604,7 +614,7 @@ pub async fn board_page(cx: &Cx, user: &User) -> Result { if let Some(task_id) = &open_task { (crate::detail::task_modal(cx, task_id, query.confirm.as_deref() == Some("delete"), open_tab).await?) if let Some(file_id) = &query.file { - (crate::detail::file_viewer_modal(cx, task_id, file_id, open_tab, open_sheet).await?) + (crate::detail::file_viewer_modal(cx, task_id, file_id, open_tab, open_sheet, open_rows, open_cols).await?) } } if open_new { diff --git a/crates/izlek-web/src/detail.rs b/crates/izlek-web/src/detail.rs index b56b7c4..27dc1b9 100644 --- a/crates/izlek-web/src/detail.rs +++ b/crates/izlek-web/src/detail.rs @@ -2119,6 +2119,8 @@ pub async fn file_viewer_modal( file_id: &str, tab: Tab, sheet_index: usize, + row_page: usize, + column_page: usize, ) -> Result { let user = match require_user(cx).await { Ok(user) => user, @@ -2153,7 +2155,9 @@ pub async fn file_viewer_modal( let sheet = if kind == crate::files::ViewerKind::Sheet { match store.attachment_bytes(file_id).await { Ok(Some(bytes)) => { - tokio::task::spawn_blocking(move || crate::sheet::read(bytes, sheet_index)) + tokio::task::spawn_blocking(move || { + crate::sheet::read(bytes, sheet_index, row_page, column_page) + }) .await .ok() .flatten() @@ -2199,11 +2203,10 @@ pub async fn file_viewer_modal( } } -/// One sheet of a workbook as a table: the tab strip when the book has more +/// One window of one sheet as a table: the tab strip when the book has more /// than one sheet, the grid with its column letters and row numbers, and the -/// clipped line when the sheet ran past what [`crate::sheet`] draws. A -/// workbook no reader here understands says so in one line — the header's -/// download link is still the whole file. +/// two pagers that move the window. A workbook no reader here understands +/// says so in one line — the header's download link is still the whole file. async fn sheet_view( cx: &Cx, sheet: Option, @@ -2212,13 +2215,28 @@ async fn sheet_view( tab: Tab, lang: Lang, ) -> Result { + use crate::sheet::{COLUMNS_PER_PAGE, ROWS_PER_PAGE, column_name}; + let Some(sheet) = sheet else { return view! { cx =>

(t(lang, Key::ThisFileWillNotOpen))

}; }; let width = sheet.rows.iter().map(Vec::len).max().unwrap_or(0); - let columns: Vec = (0..width).map(crate::sheet::column_name).collect(); + let columns: Vec = (0..width) + .map(|column| column_name(sheet.first_column + column)) + .collect(); + let row_page = sheet.first_row / ROWS_PER_PAGE; + let column_page = sheet.first_column / COLUMNS_PER_PAGE; + // Every link out of here is the same page with one number moved, so the + // window a link lands on is the window its own numbers name. + let at = |sheet_index: usize, rows: usize, columns: usize| { + format!( + "/?task={task_id}&tab={}&file={file_id}&sheet={sheet_index}&rows={rows}&cols={columns}", + tab.slug() + ) + }; // The tab strip is a row of links, not a control: switching sheets is a - // navigation like every other overlay state on this page. + // navigation like every other overlay state on this page, and it starts + // that sheet at its own first window. let tabs: Vec<(String, String, &'static str)> = sheet .names .iter() @@ -2226,10 +2244,7 @@ async fn sheet_view( .map(|(index, name)| { ( name.clone(), - format!( - "/?task={task_id}&tab={}&file={file_id}&sheet={index}", - tab.slug() - ), + at(index, 0, 0), if index == sheet.index { "sheet-tab sheet-tab-on" } else { @@ -2238,6 +2253,28 @@ async fn sheet_view( ) }) .collect(); + let rows_back = (row_page > 0).then(|| at(sheet.index, row_page - 1, column_page)); + let rows_on = sheet + .more_rows + .then(|| at(sheet.index, row_page + 1, column_page)); + let columns_back = (column_page > 0).then(|| at(sheet.index, row_page, column_page - 1)); + let columns_on = sheet + .more_columns + .then(|| at(sheet.index, row_page, column_page + 1)); + // "51–100 / 5000" down the rows, "M–X / 40" across the columns: the + // window's own edges in the same vocabulary the grid labels its gutters + // with, counted against the whole sheet where the file's own size can be + // trusted and left uncounted where it cannot. + let row_range = match sheet.total_rows { + Some(total) => format!("{}–{} / {total}", sheet.first_row + 1, sheet.last_row()), + None => format!("{}–{}", sheet.first_row + 1, sheet.last_row()), + }; + let first_letter = column_name(sheet.first_column); + let last_letter = column_name(sheet.last_column().saturating_sub(1)); + let column_range = match sheet.total_columns { + Some(total) => format!("{first_letter}–{last_letter} / {total}"), + None => format!("{first_letter}–{last_letter}"), + }; view! { cx =>
@@ -2261,7 +2298,7 @@ async fn sheet_view( for (index, row) in sheet.rows.iter().enumerate() { - (format!("{}", index + 1)) + (format!("{}", sheet.first_row + index + 1)) for column in 0..width { (row.get(column).cloned().unwrap_or_default()) } @@ -2270,9 +2307,34 @@ async fn sheet_view(
- if sheet.clipped { -

(t(lang, Key::SheetClipped))

- } +
+
+ (row_range) + if let Some(href) = rows_back { + (glyph::chevron(cx).await?) + } else { + (glyph::chevron(cx).await?) + } + if let Some(href) = rows_on { + (glyph::chevron(cx).await?) + } else { + (glyph::chevron(cx).await?) + } +
+
+ (column_range) + if let Some(href) = columns_back { + (glyph::chevron(cx).await?) + } else { + (glyph::chevron(cx).await?) + } + if let Some(href) = columns_on { + (glyph::chevron(cx).await?) + } else { + (glyph::chevron(cx).await?) + } +
+
} } diff --git a/crates/izlek-web/src/i18n.rs b/crates/izlek-web/src/i18n.rs index e71a28b..d2da8d1 100644 --- a/crates/izlek-web/src/i18n.rs +++ b/crates/izlek-web/src/i18n.rs @@ -66,8 +66,9 @@ pub enum Key { Play, Pause, CloseTheFile, - SheetClipped, ThisFileWillNotOpen, + Previous, + Next, Esc, CloseThisTask, Status, @@ -416,10 +417,12 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (Pause, Tr) => "Duraklat", (CloseTheFile, En) => "Close the file", (CloseTheFile, Tr) => "Dosyayı kapat", - (SheetClipped, En) => "First 400 rows, 40 columns.", - (SheetClipped, Tr) => "İlk 400 satır, 40 sütun.", (ThisFileWillNotOpen, En) => "This file will not open.", (ThisFileWillNotOpen, Tr) => "Bu dosya açılmıyor.", + (Previous, En) => "Previous", + (Previous, Tr) => "Önceki", + (Next, En) => "Next", + (Next, Tr) => "Sonraki", (Esc, En) => "esc", (Esc, Tr) => "esc", (CloseThisTask, En) => "Close this task", diff --git a/crates/izlek-web/src/sheet.rs b/crates/izlek-web/src/sheet.rs index 9e6f4a4..d0bbf76 100644 --- a/crates/izlek-web/src/sheet.rs +++ b/crates/izlek-web/src/sheet.rs @@ -4,45 +4,85 @@ //! ViewerKind`] this one is not a src on an element: the bytes are parsed //! here and come out as strings the view puts in a ``. Values only — //! a cell's formula, formatting, charts and images are not carried over. +//! +//! A sheet is read one window at a time, never whole: a page of rows and a +//! page of columns, both moved by links. A book of any size costs the same +//! page, and nothing has to be dragged sideways to reach a column. use std::io::Cursor; use calamine::{Data, Reader, Xlsx, open_workbook_auto_from_rs, open_workbook_from_rs}; -/// How much of one sheet is drawn. A workbook is a million rows wide open, -/// and a table that size is a page that never paints; past this the view says -/// so and the download is the whole file. -pub(crate) const MAX_ROWS: usize = 400; -pub(crate) const MAX_COLS: usize = 40; +/// One window of a sheet. Sized to land on a screen rather than to be +/// generous: what does not fit is one link away, and a page that has to be +/// panned is the thing paging exists to avoid. +pub(crate) const ROWS_PER_PAGE: usize = 50; +pub(crate) const COLUMNS_PER_PAGE: usize = 12; -/// One sheet of a workbook, ready to lay out: every sheet's name for the tab -/// strip, which of them this is, and its cells as display strings. +/// One window of one sheet, ready to lay out: every sheet's name for the tab +/// strip, which of them this is, where the window sits, and whether the sheet +/// runs past it. pub(crate) struct Sheet { pub names: Vec, pub index: usize, pub rows: Vec>, - /// True when the sheet ran past [`MAX_ROWS`] or [`MAX_COLS`] and what is - /// drawn is a corner of it. - pub clipped: bool, + /// Zero-based offsets of the window's own corner, for the row numbers and + /// column letters the grid draws down its edges. + pub first_row: usize, + pub first_column: usize, + /// The whole sheet's size, when the file says so and the reading agrees. + /// An xlsx declares its own dimensions and plenty of writers get them + /// wrong, so a count that cannot be trusted is no count at all rather + /// than a number the footer would print as fact. + pub total_rows: Option, + pub total_columns: Option, + /// Whether there is another window past this one. Observed, not derived + /// from the count: a cell arriving past the window is proof, and proof is + /// what a pager needs. + pub more_rows: bool, + pub more_columns: bool, } -/// The workbook's `index`-th sheet, or `None` when the bytes are not a -/// workbook any reader here understands — a `.doc` that sniffed as an OLE -/// container, or an `.xlsx` truncated in transit. An out-of-range `index` -/// (a hand-edited query string) falls back to the first sheet rather than -/// failing. -pub(crate) fn read(bytes: Vec, index: usize) -> Option { +impl Sheet { + /// The window's own last row and column, one-based — what the footer + /// counts up to. + pub fn last_row(&self) -> usize { + self.first_row + self.rows.len() + } + + pub fn last_column(&self) -> usize { + self.first_column + self.rows.iter().map(Vec::len).max().unwrap_or(0) + } +} + +/// The `index`-th sheet of the workbook, windowed to `row_page` and +/// `column_page`. `None` when the bytes are not a workbook any reader here +/// understands — a `.doc` that sniffed as an OLE container, or an `.xlsx` +/// truncated in transit. An out-of-range sheet or page (a hand-edited query +/// string) falls back to the first one rather than failing. +pub(crate) fn read( + bytes: Vec, + index: usize, + row_page: usize, + column_page: usize, +) -> Option { // xlsx first, because that is the format that holds millions of rows and // the only one calamine will hand over a cell at a time. Reading the // whole range of a 300,000-row book costs about 380MB and most of a - // second; stopping at the rows that are drawn costs neither. - read_streamed(&bytes, index).or_else(|| read_whole(bytes, index)) + // second; stopping at the end of the window costs neither. + read_streamed(&bytes, index, row_page, column_page) + .or_else(|| read_whole(bytes, index, row_page, column_page)) } /// The lazy path: an xlsx read cell by cell in stream order, abandoned the -/// moment the rows past [`MAX_ROWS`] start. `None` when the bytes are not an +/// moment the rows past the window start. `None` when the bytes are not an /// xlsx at all, which is the caller's cue to try the other formats. -fn read_streamed(bytes: &[u8], index: usize) -> Option { +fn read_streamed( + bytes: &[u8], + index: usize, + row_page: usize, + column_page: usize, +) -> Option { let mut book: Xlsx>> = open_workbook_from_rs(Cursor::new(bytes.to_vec())).ok()?; let names = book.sheet_names(); if names.is_empty() { @@ -51,31 +91,44 @@ fn read_streamed(bytes: &[u8], index: usize) -> Option { let index = if index < names.len() { index } else { 0 }; let mut cells = book.worksheet_cells_reader(&names[index]).ok()?; let bounds = cells.dimensions(); - let (first_row, first_column) = bounds.start; - let height = bounds.end.0.saturating_sub(first_row) as usize + 1; - let width = bounds.end.1.saturating_sub(first_column) as usize + 1; - let mut clipped = height > MAX_ROWS || width > MAX_COLS; + let (sheet_row, sheet_column) = bounds.start; + let declared_rows = bounds.end.0.saturating_sub(sheet_row) as usize + 1; + let declared_columns = bounds.end.1.saturating_sub(sheet_column) as usize + 1; + // The asked-for page is honoured whatever the file declares: an xlsx + // dimension is a claim, not a fact, and clamping to a wrong one would + // snap a reader back to the first window every time they stepped on. + let (first_row, first_column) = (row_page * ROWS_PER_PAGE, column_page * COLUMNS_PER_PAGE); let mut rows: Vec> = Vec::new(); + let mut more_rows = false; + let mut more_columns = false; + let mut seen_rows = 0; + let mut seen_columns = 0; while let Ok(Some(found)) = cells.next_cell() { let (row, column) = found.get_position(); // A cell before the sheet's own first row or column is a dimension // that lied; there is nowhere to put it, so it is passed over. let (Some(row), Some(column)) = ( - row.checked_sub(first_row).map(|row| row as usize), - column.checked_sub(first_column).map(|column| column as usize), + row.checked_sub(sheet_row).map(|row| row as usize), + column.checked_sub(sheet_column).map(|column| column as usize), ) else { continue; }; - // Cells arrive in row order, so the first one past the last drawn row - // is the end of the reading — whatever the dimension claimed. - if row >= MAX_ROWS { - clipped = true; + seen_rows = seen_rows.max(row + 1); + seen_columns = seen_columns.max(column + 1); + // Cells arrive in row order, so the first one past the window is both + // the end of the reading and the proof there is another window. + if row >= first_row + ROWS_PER_PAGE { + more_rows = true; break; } - if column >= MAX_COLS { - clipped = true; + if column >= first_column + COLUMNS_PER_PAGE { + more_columns = true; + continue; + } + if row < first_row || column < first_column { continue; } + let (row, column) = (row - first_row, column - first_column); if rows.len() <= row { rows.resize(row + 1, Vec::new()); } @@ -85,18 +138,32 @@ fn read_streamed(bytes: &[u8], index: usize) -> Option { } line[column] = cell(&Data::from(found.get_value().clone())); } + // The declared size is believed only where the reading bears it out. A + // sheet whose cells ran past what it declared has a wrong dimension, and + // one abandoned mid-read was never counted at all. + let counted = !more_rows; Some(Sheet { names, index, + total_rows: (counted && declared_rows >= seen_rows).then_some(declared_rows.max(seen_rows)), + total_columns: (declared_columns >= seen_columns).then_some(declared_columns), + more_rows: more_rows || declared_rows > first_row + ROWS_PER_PAGE, + more_columns: more_columns || declared_columns > first_column + COLUMNS_PER_PAGE, rows, - clipped, + first_row, + first_column, }) } /// The whole-workbook path, for the formats with no cell-at-a-time reader: /// xls, xlsb and ods. All three are bounded by the upload limit and by their /// own row ceilings, so the range fits in memory in a way an xlsx need not. -fn read_whole(bytes: Vec, index: usize) -> Option { +fn read_whole( + bytes: Vec, + index: usize, + row_page: usize, + column_page: usize, +) -> Option { let mut book = open_workbook_auto_from_rs(Cursor::new(bytes)).ok()?; let names = book.sheet_names(); if names.is_empty() { @@ -104,17 +171,33 @@ fn read_whole(bytes: Vec, index: usize) -> Option { } let index = if index < names.len() { index } else { 0 }; let range = book.worksheet_range(&names[index]).ok()?; - let clipped = range.height() > MAX_ROWS || range.width() > MAX_COLS; - let rows = range + let total_rows = range.height(); + let total_columns = range.width(); + let (first_row, first_column) = (row_page * ROWS_PER_PAGE, column_page * COLUMNS_PER_PAGE); + let rows: Vec> = range .rows() - .take(MAX_ROWS) - .map(|row| row.iter().take(MAX_COLS).map(cell).collect()) + .skip(first_row) + .take(ROWS_PER_PAGE) + .map(|row| { + row.iter() + .skip(first_column) + .take(COLUMNS_PER_PAGE) + .map(cell) + .collect() + }) .collect(); Some(Sheet { names, index, rows, - clipped, + first_row, + first_column, + // Nothing is declared here: the whole range was read, so its size is + // measured rather than believed. + total_rows: Some(total_rows), + total_columns: Some(total_columns), + more_rows: total_rows > first_row + ROWS_PER_PAGE, + more_columns: total_columns > first_column + COLUMNS_PER_PAGE, }) } @@ -208,21 +291,59 @@ mod tests { assert_eq!(column_name(702), "AAA"); } - /// The clip is what keeps a workbook of any size from becoming a page of - /// that size — and on the streamed path, from being read at all past the - /// rows that are drawn. + /// The window is what keeps a workbook of any size from becoming a page + /// of that size — and on the streamed path, from being read at all past + /// the rows it draws. #[test] - fn a_book_past_the_clip_is_read_only_as_far_as_it_is_drawn() { + fn a_page_holds_one_window_and_the_next_page_holds_the_next() { let bytes = include_bytes!("../tests/fixtures/tall.xlsx").to_vec(); - let sheet = read(bytes, 0).expect("the workbook opens"); - assert_eq!(sheet.rows.len(), MAX_ROWS); - assert!(sheet.clipped); - assert_eq!(sheet.rows[0][0], "Row 1"); - assert_eq!(sheet.rows[MAX_ROWS - 1][0], format!("Row {MAX_ROWS}")); + let first = read(bytes.clone(), 0, 0, 0).expect("the workbook opens"); + assert_eq!(first.rows.len(), ROWS_PER_PAGE); + // This fixture declares no dimension, the way plenty of writers + // leave one out, so its size is not counted — but the next window is + // still known to be there, because a cell arrived in it. + assert_eq!(first.total_rows, None); + assert!(first.more_rows); + assert_eq!(first.first_row, 0); + assert_eq!(first.rows[0][0], "Row 1"); + assert_eq!(first.rows[ROWS_PER_PAGE - 1][0], format!("Row {ROWS_PER_PAGE}")); + + let third = read(bytes.clone(), 0, 2, 0).expect("the workbook opens"); + assert_eq!(third.first_row, 2 * ROWS_PER_PAGE); + assert_eq!( + third.rows[0][0], + format!("Row {}", 2 * ROWS_PER_PAGE + 1) + ); + + // A page nobody links to — typed into the query string — is the + // empty window it names, with the step back to a real one still + // there. Nothing pretends it was a different page. + let past_the_end = read(bytes, 0, 9_000, 0).expect("the workbook opens"); + assert!(past_the_end.rows.is_empty()); + assert!(!past_the_end.more_rows); + } + + /// A wide sheet pages sideways the same way, and the window's own corner + /// is what the grid labels its edges from. + #[test] + fn columns_page_the_same_way_rows_do() { + let bytes = include_bytes!("../tests/fixtures/wide.xlsx").to_vec(); + let first = read(bytes.clone(), 0, 0, 0).expect("the workbook opens"); + assert_eq!(first.total_columns, Some(40)); + assert!(first.more_columns); + assert_eq!(first.rows[0].len(), COLUMNS_PER_PAGE); + assert_eq!(first.rows[0][0], "Col A"); + + let second = read(bytes, 0, 0, 1).expect("the workbook opens"); + assert_eq!(second.first_column, COLUMNS_PER_PAGE); + assert_eq!( + second.rows[0][0], + format!("Col {}", column_name(COLUMNS_PER_PAGE)) + ); } #[test] fn bytes_that_are_not_a_workbook_have_no_sheet() { - assert!(read(b"not a workbook at all".to_vec(), 0).is_none()); + assert!(read(b"not a workbook at all".to_vec(), 0, 0, 0).is_none()); } } \ No newline at end of file diff --git a/crates/izlek-web/tests/fixtures/wide.xlsx b/crates/izlek-web/tests/fixtures/wide.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..df0c3171d66ca2c94de65a0a00461c7a19932e3d GIT binary patch literal 2748 zcmcgueK=HU8-K<`Uy9zsgm)RWeaJ9EgJP1+_9eCLCLd#lqC_(~oXj*aN`}QOCZCbs zc8l3C$VD;8q!gvCY?)Hy^fF4Ap`kJPn7ve5(O%d4*L(kQpXc1?zMtRuJ-_F=?t9mE z^sFTSfH}a-uuahxWv?nbAuxcya1^}YpmSq^)D-oZI1 z$g zZ+;!gmvzf_+Gq^bndLUt@dKT(cDWmH8vG7P2iO*WsZnEvb^oT5d)gy>OKw>;zB$9w zNB?}XJT>f3&*$+Ex7E-6y#XKkOU0IY#>2*{W^*2~?O3tg4J~%H*`e_k-?x!dd|Fk? z$gQcj5-`6rWqFT!M(H2%DZ%iZh;}qWSJCg5QPTBex*`_(OJ?kT`&m^0fTbt^v;Y9~ zV2f}X6y!&v1x?%nPLgX-Jzo1eRlJCa6U6>2QR2M`t4Pn$3Ho=!q3~w@vno|>auU-G zt<|-_s+V9YHF$g_B#Iv>#JX|UlGRQ`R$uR}^Wfz8EouPQ50x0j8a?ds=zO!zG#Hic z*(zpc>s~y>DZFEl=8@`G?lSn_BR?fJ>fYRT>v~0Bc7EnkDceWYk<7Ti_?rXoO*)Tf ztV-WkR)S;LU}D=&IXpVLTr;F;uJFYjOZC@vf#>%ChrETOw!;S-i7XE5OPZczr-CW~ z0IN^{=zpa7QNyWZKj|qvT#whD^?)3(C#n4W@Ox1jx*_-SM+raqsQ2gc}E5y3EVJz{-DpSo;a? zfDJRgP`AQUzG(NDOJm@&EV|p#6t4GUm!|lq$^x&sZi z!5-;Ix7oPWqSo1qhjEh22D{a*DzE%d-tWG8+@-a5wc0`lv4i3C>-v-aRhJ#=0PvRq zfcab0&_n+IVWAcu9+ng8Mm&2;)!zzYUb;I)5UI{gUlZfY^mfJ2!l&mj>iYAO`xqlB zyH(3`_V5L-iK(gF_XW={%E$Iw2Un+^>85zYWnE2&pR6j#ACUj&{o`gTKU@`fkkegA zc2LB2T<#4}rM2`ji{*~Fqq()IlEMK?{k<*JcWbk2BJaw(TejQ1adU4d_8+p;A2)P! z8G9P$zd@PiMqcT!VniOYzUNg?V4&m?c~^X1G4Q4Ze_Y?V|A+D3fD1}oPDNRDYnF;G zAoeKi&kQj4KWaYfQ7j)+#y+^GUq)TWV@F@EKI?kL=ODfh4yY*_C|P8$ENpEgI*=*$OZ^8fe{l3Sqmd;A;c6$Od-S`M(iPE1&pkK zkaaM!4noXf#2i8#VZ;$aurPv!5K9=bgp4nquNAfFag)e#HIZ25XpCq?kE=zAtBJxY zXR$>F7;X|JuI3b0smT_t$8fcL<7!T0l}p$nFAO)yH?D?_RT{EIObl1cFRmsIt6a_& zWn;KWe#!2Z=M&rYRJ^OYDjsXRyQtNZ)YnO4soGp=<_g^Lph{Xxf~3}&>?IWp4oPai zZ{H^!8ElqBZlqZ#oZnx+JI0f`R>~|%Qs$69_z^GH(b9#$!{ zAxW8g6zR_u>E?=>-|j}px}o;jRnHYE=86R;LU5HKNJ3B}2YudqJKu1)%M*H4_r3d_ zOK36)dv)Q7V=>5X#IqEG`Li~pf*PTyyG3!1bjR6F|fPt0gYySA%qOk}D9 Ob+8!)fbZOix4!_r&G|zB literal 0 HcmV?d00001 diff --git a/crates/izlek-web/tests/http.rs b/crates/izlek-web/tests/http.rs index 65c8116..e9f9556 100644 --- a/crates/izlek-web/tests/http.rs +++ b/crates/izlek-web/tests/http.rs @@ -6494,3 +6494,80 @@ async fn an_admin_sets_the_address_mail_links_point_at() { "an empty field did not clear the stored address" ); } + +/// A sheet is read one window at a time and the pagers move it: down the rows +/// and across the columns, each a link like every other overlay state. The +/// window's own numbers and letters label the grid, so a page says where it +/// sits without being told. +#[tokio::test] +async fn a_big_sheet_pages_down_its_rows_and_across_its_columns() { + let app = App::open().await; + let admin_cookie = admin(&app).await; + let column = first_column(&app).await; + let task = a_task(&app, &admin_cookie, &column, "Read the big book").await; + + let book = include_bytes!("fixtures/wide.xlsx"); + app.post_multipart( + "/files", + Some(&admin_cookie), + &[("task_id", &task)], + Some(( + "wide.xlsx", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + book, + )), + ) + .await; + let snapshot = app + .post( + "/api/fetch_task", + Some(&admin_cookie), + &[("task_id", &task)], + ) + .await; + let file_id = attachment_id_named(&snapshot.body, "wide.xlsx"); + + let first = app + .get( + &format!("/?task={task}&file={file_id}"), + Some(&admin_cookie), + ) + .await; + let html = String::from_utf8_lossy(&first.bytes); + assert!(html.contains("Col A"), "the first column is missing: {html}"); + assert!(!html.contains("Col M"), "the window is not 12 wide: {html}"); + assert!(html.contains("A–L / 40"), "no column count: {html}"); + assert!(html.contains("1–8 / 8"), "no row count: {html}"); + assert!( + html.contains(&format!("file={file_id}&sheet=0&rows=0&cols=1")), + "no step to the next columns: {html}" + ); + + // Stepping across lands on the next twelve columns, and the grid labels + // them from where the window sits rather than from A. + let across = app + .get( + &format!("/?task={task}&file={file_id}&sheet=0&rows=0&cols=1"), + Some(&admin_cookie), + ) + .await; + let html = String::from_utf8_lossy(&across.bytes); + assert!(html.contains("Col M"), "the second window is wrong: {html}"); + assert!(html.contains("M–X / 40"), "the count did not move: {html}"); + assert!( + html.contains(&format!("file={file_id}&sheet=0&rows=0&cols=0")), + "no step back to the first columns: {html}" + ); + + // A window nobody links to is the empty one it names, not a redirect and + // not the first page wearing another page's numbers. + let nowhere = app + .get( + &format!("/?task={task}&file={file_id}&sheet=0&rows=99&cols=0"), + Some(&admin_cookie), + ) + .await; + let html = String::from_utf8_lossy(&nowhere.bytes); + assert!(html.contains("sheet-table"), "the grid is gone: {html}"); + assert!(!html.contains("Col A"), "row 4951 is not row 1: {html}"); +} diff --git a/style/main.scss b/style/main.scss index 528a37c..945ab86 100644 --- a/style/main.scss +++ b/style/main.scss @@ -1237,7 +1237,7 @@ img.avatar { // further, and the grid takes whatever is left under the tab strip and pans // inside that — the panel itself never leaves the screen. .viewer:has(.viewer-sheet) { - width: min(96vw, 1400px); + width: auto; max-width: min(96vw, 1400px); display: flex; flex-direction: column; @@ -1287,8 +1287,11 @@ img.avatar { border-color: var(--accent); } +// A window is sized to land on a screen, so the grid takes only the room its +// own rows need — the pagers below it stay in view rather than being pushed +// off by a table that always claims the whole panel. .sheet-grid { - flex: 1; + flex: 0 1 auto; min-width: 0; min-height: 0; overflow: auto; @@ -1345,6 +1348,54 @@ img.avatar { font-size: 12px; } +// A sheet is read one window at a time, and these move it: the rows down the +// left, the columns across the right, each counted against the whole sheet. +// A step with nowhere to go stays in place, dimmed, so the pair never moves +// under the pointer. +.sheet-foot { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16px; +} + +.sheet-pager { + display: flex; + align-items: center; + gap: 4px; +} + +.sheet-range { + color: var(--text-dim); + font-size: 12px; + font-variant-numeric: tabular-nums; + margin-right: 4px; +} + +.sheet-step { + display: inline-flex; + align-items: center; + justify-content: center; + width: 26px; + height: 24px; + border: 1px solid var(--border); + border-radius: var(--radius-sm); + color: var(--text-dim); + + &:hover { color: var(--text); border-color: var(--accent); } +} + +// One chevron points down; the other three are that chevron turned. +.sheet-step-up .glyph { transform: rotate(180deg); } +.sheet-step-left .glyph { transform: rotate(90deg); } +.sheet-step-right .glyph { transform: rotate(-90deg); } + +.sheet-step-off { + opacity: 0.3; + + &:hover { color: var(--text-dim); border-color: var(--border); } +} + .new-task-form { display: flex; flex-direction: column;