Add backend routine for browser rows
This commit is contained in:
parent
436269b701
commit
c68a6131e0
@ -234,6 +234,7 @@ service SearchService {
|
|||||||
rpc JoinSearchNodes(JoinSearchNodesIn) returns (String);
|
rpc JoinSearchNodes(JoinSearchNodesIn) returns (String);
|
||||||
rpc ReplaceSearchNode(ReplaceSearchNodeIn) returns (String);
|
rpc ReplaceSearchNode(ReplaceSearchNodeIn) returns (String);
|
||||||
rpc FindAndReplace(FindAndReplaceIn) returns (OpChangesWithCount);
|
rpc FindAndReplace(FindAndReplaceIn) returns (OpChangesWithCount);
|
||||||
|
rpc BrowserRowForCard(CardID) returns (BrowserRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
service StatsService {
|
service StatsService {
|
||||||
@ -1038,6 +1039,26 @@ message FindAndReplaceIn {
|
|||||||
string field_name = 6;
|
string field_name = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message BrowserRow {
|
||||||
|
message Cell {
|
||||||
|
string text = 1;
|
||||||
|
bool is_rtl = 2;
|
||||||
|
}
|
||||||
|
enum Color {
|
||||||
|
COLOR_DEFAULT = 0;
|
||||||
|
COLOR_MARKED = 1;
|
||||||
|
COLOR_SUSPENDED = 2;
|
||||||
|
COLOR_FLAG_RED = 3;
|
||||||
|
COLOR_FLAG_ORANGE = 4;
|
||||||
|
COLOR_FLAG_GREEN = 5;
|
||||||
|
COLOR_FLAG_BLUE = 6;
|
||||||
|
}
|
||||||
|
repeated Cell cells = 1;
|
||||||
|
Color color = 2;
|
||||||
|
string font_name = 3;
|
||||||
|
uint32 font_size = 4;
|
||||||
|
}
|
||||||
|
|
||||||
message AfterNoteUpdatesIn {
|
message AfterNoteUpdatesIn {
|
||||||
repeated int64 nids = 1;
|
repeated int64 nids = 1;
|
||||||
bool mark_notes_modified = 2;
|
bool mark_notes_modified = 2;
|
||||||
|
@ -13,8 +13,9 @@ use crate::{
|
|||||||
config::SortKind,
|
config::SortKind,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
search::{
|
search::{
|
||||||
concatenate_searches, parse_search, replace_search_node, write_nodes, BoolSeparator, Node,
|
browser, concatenate_searches, parse_search, replace_search_node, write_nodes,
|
||||||
PropertyKind, RatingKind, SearchNode, SortMode, StateKind, TemplateKind,
|
BoolSeparator, Node, PropertyKind, RatingKind, SearchNode, SortMode, StateKind,
|
||||||
|
TemplateKind,
|
||||||
},
|
},
|
||||||
text::escape_anki_wildcards,
|
text::escape_anki_wildcards,
|
||||||
};
|
};
|
||||||
@ -89,6 +90,10 @@ impl SearchService for Backend {
|
|||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn browser_row_for_card(&self, input: pb::CardId) -> Result<pb::BrowserRow> {
|
||||||
|
self.with_col(|col| col.browser_row_for_card(input.cid.into()).map(Into::into))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<pb::SearchNode> for Node {
|
impl TryFrom<pb::SearchNode> for Node {
|
||||||
@ -264,3 +269,37 @@ impl From<Option<SortOrderProto>> for SortMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<browser::Row> for pb::BrowserRow {
|
||||||
|
fn from(row: browser::Row) -> Self {
|
||||||
|
pb::BrowserRow {
|
||||||
|
cells: row.cells.into_iter().map(Into::into).collect(),
|
||||||
|
color: row.color.into(),
|
||||||
|
font_name: row.font.name,
|
||||||
|
font_size: row.font.size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<browser::Cell> for pb::browser_row::Cell {
|
||||||
|
fn from(cell: browser::Cell) -> Self {
|
||||||
|
pb::browser_row::Cell {
|
||||||
|
text: cell.text,
|
||||||
|
is_rtl: cell.is_rtl,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<browser::RowColor> for i32 {
|
||||||
|
fn from(color: browser::RowColor) -> Self {
|
||||||
|
match color {
|
||||||
|
browser::RowColor::Default => pb::browser_row::Color::Default as i32,
|
||||||
|
browser::RowColor::Marked => pb::browser_row::Color::Marked as i32,
|
||||||
|
browser::RowColor::Suspended => pb::browser_row::Color::Suspended as i32,
|
||||||
|
browser::RowColor::FlagRed => pb::browser_row::Color::FlagRed as i32,
|
||||||
|
browser::RowColor::FlagOrange => pb::browser_row::Color::FlagOrange as i32,
|
||||||
|
browser::RowColor::FlagGreen => pb::browser_row::Color::FlagGreen as i32,
|
||||||
|
browser::RowColor::FlagBlue => pb::browser_row::Color::FlagBlue as i32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user