mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 08:21:39 -06:00
fix(series): show selected books in KOReader series views
Pass bulk selection state through the dedicated series-page model so grid and list layouts render the same selection cues as the library. Closes #1956
This commit is contained in:
@@ -1221,6 +1221,8 @@ function CatalogLists:listBody(kind, context)
|
|||||||
local m = {
|
local m = {
|
||||||
entries = books, view = self:listView(kind), screen_w = sw, screen_h = sh, local_page = context.local_page,
|
entries = books, view = self:listView(kind), screen_w = sw, screen_h = sh, local_page = context.local_page,
|
||||||
offline = context.list_offline and {} or nil,
|
offline = context.list_offline and {} or nil,
|
||||||
|
select = self:isBulkSelectionActive(),
|
||||||
|
selected = function(b) return self.bulk_select_all or self:bulkIsBookSelected(b) end,
|
||||||
order_label = (context.params or {}).sort == "title" and _("Title A–Z") or _("Reading order"),
|
order_label = (context.params or {}).sort == "title" and _("Title A–Z") or _("Reading order"),
|
||||||
states = states, indexes = indexes, current_index = cur, next_book = next_book,
|
states = states, indexes = indexes, current_index = cur, next_book = next_book,
|
||||||
range = #books > 0 and T(_("Books %1 – %2"), first, last) or nil,
|
range = #books > 0 and T(_("Books %1 – %2"), first, last) or nil,
|
||||||
|
|||||||
@@ -255,6 +255,8 @@ function Pages.seriesBody(m, f)
|
|||||||
local short = ListData.distinctTitles(books)
|
local short = ListData.distinctTitles(books)
|
||||||
content = ListView.cellsGrid(list_w, g, books, function(b)
|
content = ListView.cellsGrid(list_w, g, books, function(b)
|
||||||
return ListView.bookCell(g, b, {
|
return ListView.bookCell(g, b, {
|
||||||
|
select = m.select,
|
||||||
|
selected = m.selected and m.selected(b),
|
||||||
title = function(x) return x.seriesIndex and (tostring(x.seriesIndex) .. ". " .. (short[x.id] or x.title or "")) or (short[x.id] or x.title or "") end,
|
title = function(x) return x.seriesIndex and (tostring(x.seriesIndex) .. ". " .. (short[x.id] or x.title or "")) or (short[x.id] or x.title or "") end,
|
||||||
meta = function(x)
|
meta = function(x)
|
||||||
local st = ListData.stateOf(x)
|
local st = ListData.stateOf(x)
|
||||||
@@ -272,7 +274,12 @@ function Pages.seriesBody(m, f)
|
|||||||
content = ListView.indexList(list_w, list_h, {
|
content = ListView.indexList(list_w, list_h, {
|
||||||
entries = books, rows_per_col = rows.n, row_h = rows.rh, cols = 1, gutter = 34, rail = false,
|
entries = books, rows_per_col = rows.n, row_h = rows.rh, cols = 1, gutter = 34, rail = false,
|
||||||
groupOf = function(b) return "#" .. tostring(b.seriesIndex or "") end, group_rules = false,
|
groupOf = function(b) return "#" .. tostring(b.seriesIndex or "") end, group_rules = false,
|
||||||
row = function(w, hh, b) return ListView.bookRow(w, hh, b, { context = "series" }) end, action = m.action,
|
row = function(w, hh, b) return ListView.bookRow(w, hh, b, {
|
||||||
|
select = m.select,
|
||||||
|
selected = m.selected and m.selected(b),
|
||||||
|
context = "series",
|
||||||
|
}) end,
|
||||||
|
action = m.action,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
local list = vstack({ w = list_w }, { head, space(nil, px(8)), content })
|
local list = vstack({ w = list_w }, { head, space(nil, px(8)), content })
|
||||||
|
|||||||
@@ -41,4 +41,24 @@ assert(catalog:listFetchCompleteSeries({ page = 1, size = 100, sort = "title" },
|
|||||||
"ordinary book lists keep server pagination")
|
"ordinary book lists keep server pagination")
|
||||||
assert(#requested == 0, "ordinary book lists do not fetch ahead")
|
assert(#requested == 0, "ordinary book lists do not fetch ahead")
|
||||||
|
|
||||||
|
local first_book = { id = 1, title = "First", seriesIndex = 1 }
|
||||||
|
local second_book = { id = 2, title = "Second", seriesIndex = 2 }
|
||||||
|
package.loaded["bookorbit_list_data"].stateOf = function() return "unread" end
|
||||||
|
package.loaded["bookorbit_list_pages"].seriesLayout = function()
|
||||||
|
return { pages = 1, first = 2, rest = 2 }
|
||||||
|
end
|
||||||
|
function catalog:listScreen() return 600, 800 end
|
||||||
|
function catalog:listView() return "grid" end
|
||||||
|
function catalog:isBulkSelectionActive() return true end
|
||||||
|
function catalog:bulkIsBookSelected(book) return book.id == first_book.id end
|
||||||
|
function catalog:listMinutesLeft() return nil end
|
||||||
|
local _, model = catalog:listBody("seriespage", {
|
||||||
|
books = { first_book, second_book },
|
||||||
|
params = { seriesId = 42, sort = "title" },
|
||||||
|
series_summary = { total = 2, finished = 0, reading = 0 },
|
||||||
|
})
|
||||||
|
assert(model.select == true, "a series page exposes active selection mode to its book cards")
|
||||||
|
assert(model.selected(first_book) == true, "a series page marks the selected book")
|
||||||
|
assert(model.selected(second_book) == false, "a series page leaves unselected books unmarked")
|
||||||
|
|
||||||
print("bookorbit_series_paging_test.lua: ok")
|
print("bookorbit_series_paging_test.lua: ok")
|
||||||
|
|||||||
Reference in New Issue
Block a user