mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Rename columns for future mode-independent use
This commit is contained in:
parent
7a0cb08ac2
commit
dd56dc6650
8 changed files with 109 additions and 106 deletions
|
@ -522,7 +522,7 @@ class Collection:
|
||||||
order="c.ivl asc, c.due desc".
|
order="c.ivl asc, c.due desc".
|
||||||
|
|
||||||
If order is a BuiltinSort.Kind value, sort using that builtin sort, eg
|
If order is a BuiltinSort.Kind value, sort using that builtin sort, eg
|
||||||
col.find_cards("", order=BuiltinSort.Kind.CARD_DUE)
|
col.find_cards("", order=BuiltinSort.Kind.DUE)
|
||||||
|
|
||||||
The reverse argument only applies when a BuiltinSort.Kind is provided;
|
The reverse argument only applies when a BuiltinSort.Kind is provided;
|
||||||
otherwise the collection config defines whether reverse is set or not.
|
otherwise the collection config defines whether reverse is set or not.
|
||||||
|
|
|
@ -124,12 +124,8 @@ def test_findCards():
|
||||||
col.set_config_bool(Config.Bool.BROWSER_SORT_BACKWARDS, True)
|
col.set_config_bool(Config.Bool.BROWSER_SORT_BACKWARDS, True)
|
||||||
col.flush()
|
col.flush()
|
||||||
assert col.findCards("", order=True)[0] in latestCardIds
|
assert col.findCards("", order=True)[0] in latestCardIds
|
||||||
assert (
|
assert col.find_cards("", order=BuiltinSort.DUE, reverse=False)[0] == firstCardId
|
||||||
col.find_cards("", order=BuiltinSort.CARD_DUE, reverse=False)[0] == firstCardId
|
assert col.find_cards("", order=BuiltinSort.DUE, reverse=True)[0] != firstCardId
|
||||||
)
|
|
||||||
assert (
|
|
||||||
col.find_cards("", order=BuiltinSort.CARD_DUE, reverse=True)[0] != firstCardId
|
|
||||||
)
|
|
||||||
# model
|
# model
|
||||||
assert len(col.findCards("note:basic")) == 3
|
assert len(col.findCards("note:basic")) == 3
|
||||||
assert len(col.findCards("-note:basic")) == 2
|
assert len(col.findCards("-note:basic")) == 2
|
||||||
|
|
|
@ -802,21 +802,21 @@ message SortOrder {
|
||||||
NOTE_CREATION = 1;
|
NOTE_CREATION = 1;
|
||||||
NOTE_DUE = 2;
|
NOTE_DUE = 2;
|
||||||
NOTE_EASE = 3;
|
NOTE_EASE = 3;
|
||||||
NOTE_FIELD = 4;
|
SORT_FIELD = 4;
|
||||||
NOTE_INTERVAL = 5;
|
NOTE_INTERVAL = 5;
|
||||||
NOTE_LAPSES = 6;
|
NOTE_LAPSES = 6;
|
||||||
NOTE_MOD = 7;
|
NOTE_MOD = 7;
|
||||||
NOTE_REPS = 8;
|
NOTE_REPS = 8;
|
||||||
NOTE_TAGS = 9;
|
TAGS = 9;
|
||||||
NOTETYPE = 10;
|
NOTETYPE = 10;
|
||||||
CARD_MOD = 11;
|
CARD_MOD = 11;
|
||||||
CARD_REPS = 12;
|
REPS = 12;
|
||||||
CARD_DUE = 13;
|
DUE = 13;
|
||||||
CARD_EASE = 14;
|
EASE = 14;
|
||||||
CARD_LAPSES = 15;
|
LAPSES = 15;
|
||||||
CARD_INTERVAL = 16;
|
INTERVAL = 16;
|
||||||
CARD_DECK = 17;
|
DECK = 17;
|
||||||
CARD_TEMPLATE = 18;
|
CARDS = 18;
|
||||||
}
|
}
|
||||||
Kind kind = 1;
|
Kind kind = 1;
|
||||||
bool reverse = 2;
|
bool reverse = 2;
|
||||||
|
|
|
@ -8,34 +8,34 @@ use crate::{backend_proto as pb, browser_table, collection::Collection, i18n::I1
|
||||||
const CARD_COLUMNS: [browser_table::Column; 15] = [
|
const CARD_COLUMNS: [browser_table::Column; 15] = [
|
||||||
browser_table::Column::Question,
|
browser_table::Column::Question,
|
||||||
browser_table::Column::Answer,
|
browser_table::Column::Answer,
|
||||||
browser_table::Column::CardDeck,
|
browser_table::Column::Deck,
|
||||||
browser_table::Column::CardDue,
|
browser_table::Column::Due,
|
||||||
browser_table::Column::CardEase,
|
browser_table::Column::Ease,
|
||||||
browser_table::Column::CardLapses,
|
browser_table::Column::Lapses,
|
||||||
browser_table::Column::CardInterval,
|
browser_table::Column::Interval,
|
||||||
browser_table::Column::CardMod,
|
browser_table::Column::CardMod,
|
||||||
browser_table::Column::CardReps,
|
browser_table::Column::Reps,
|
||||||
browser_table::Column::CardTemplate,
|
browser_table::Column::Cards,
|
||||||
browser_table::Column::NoteCreation,
|
browser_table::Column::NoteCreation,
|
||||||
browser_table::Column::NoteField,
|
browser_table::Column::SortField,
|
||||||
browser_table::Column::NoteMod,
|
browser_table::Column::NoteMod,
|
||||||
browser_table::Column::NoteTags,
|
browser_table::Column::Tags,
|
||||||
browser_table::Column::Notetype,
|
browser_table::Column::Notetype,
|
||||||
];
|
];
|
||||||
|
|
||||||
const NOTE_COLUMNS: [browser_table::Column; 13] = [
|
const NOTE_COLUMNS: [browser_table::Column; 13] = [
|
||||||
browser_table::Column::CardDeck,
|
browser_table::Column::Deck,
|
||||||
browser_table::Column::CardMod,
|
browser_table::Column::CardMod,
|
||||||
browser_table::Column::NoteCards,
|
browser_table::Column::NoteCards,
|
||||||
browser_table::Column::NoteCreation,
|
browser_table::Column::NoteCreation,
|
||||||
browser_table::Column::NoteDue,
|
browser_table::Column::NoteDue,
|
||||||
browser_table::Column::NoteEase,
|
browser_table::Column::NoteEase,
|
||||||
browser_table::Column::NoteField,
|
browser_table::Column::SortField,
|
||||||
browser_table::Column::NoteInterval,
|
browser_table::Column::NoteInterval,
|
||||||
browser_table::Column::NoteLapses,
|
browser_table::Column::NoteLapses,
|
||||||
browser_table::Column::NoteMod,
|
browser_table::Column::NoteMod,
|
||||||
browser_table::Column::NoteReps,
|
browser_table::Column::NoteReps,
|
||||||
browser_table::Column::NoteTags,
|
browser_table::Column::Tags,
|
||||||
browser_table::Column::Notetype,
|
browser_table::Column::Notetype,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -70,24 +70,24 @@ impl browser_table::Column {
|
||||||
fn sorting(self) -> pb::browser_columns::Sorting {
|
fn sorting(self) -> pb::browser_columns::Sorting {
|
||||||
match self {
|
match self {
|
||||||
Self::Question | Self::Answer | Self::Custom => pb::browser_columns::Sorting::None,
|
Self::Question | Self::Answer | Self::Custom => pb::browser_columns::Sorting::None,
|
||||||
Self::NoteField => pb::browser_columns::Sorting::Reversed,
|
Self::SortField => pb::browser_columns::Sorting::Reversed,
|
||||||
_ => pb::browser_columns::Sorting::Normal,
|
_ => pb::browser_columns::Sorting::Normal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uses_cell_font(self) -> bool {
|
fn uses_cell_font(self) -> bool {
|
||||||
matches!(self, Self::Question | Self::Answer | Self::NoteField)
|
matches!(self, Self::Question | Self::Answer | Self::SortField)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn alignment(self) -> pb::browser_columns::Alignment {
|
fn alignment(self) -> pb::browser_columns::Alignment {
|
||||||
match self {
|
match self {
|
||||||
Self::Question
|
Self::Question
|
||||||
| Self::Answer
|
| Self::Answer
|
||||||
| Self::CardTemplate
|
| Self::Cards
|
||||||
| Self::CardDeck
|
| Self::Deck
|
||||||
| Self::NoteField
|
| Self::SortField
|
||||||
| Self::Notetype
|
| Self::Notetype
|
||||||
| Self::NoteTags => pb::browser_columns::Alignment::Start,
|
| Self::Tags => pb::browser_columns::Alignment::Start,
|
||||||
_ => pb::browser_columns::Alignment::Center,
|
_ => pb::browser_columns::Alignment::Center,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,24 +97,24 @@ impl browser_table::Column {
|
||||||
Self::Custom => i18n.browsing_addon(),
|
Self::Custom => i18n.browsing_addon(),
|
||||||
Self::Question => i18n.browsing_question(),
|
Self::Question => i18n.browsing_question(),
|
||||||
Self::Answer => i18n.browsing_answer(),
|
Self::Answer => i18n.browsing_answer(),
|
||||||
Self::CardDeck => i18n.decks_deck(),
|
Self::Deck => i18n.decks_deck(),
|
||||||
Self::CardDue => i18n.statistics_due_date(),
|
Self::Due => i18n.statistics_due_date(),
|
||||||
Self::CardEase => i18n.browsing_ease(),
|
Self::Ease => i18n.browsing_ease(),
|
||||||
Self::CardInterval => i18n.browsing_interval(),
|
Self::Interval => i18n.browsing_interval(),
|
||||||
Self::CardLapses => i18n.scheduling_lapses(),
|
Self::Lapses => i18n.scheduling_lapses(),
|
||||||
Self::CardMod => i18n.search_card_modified(),
|
Self::CardMod => i18n.search_card_modified(),
|
||||||
Self::CardReps => i18n.scheduling_reviews(),
|
Self::Reps => i18n.scheduling_reviews(),
|
||||||
Self::CardTemplate => i18n.browsing_card(),
|
Self::Cards => i18n.browsing_card(),
|
||||||
Self::NoteCards => i18n.editing_cards(),
|
Self::NoteCards => i18n.editing_cards(),
|
||||||
Self::NoteCreation => i18n.browsing_created(),
|
Self::NoteCreation => i18n.browsing_created(),
|
||||||
Self::NoteDue => i18n.statistics_due_date(),
|
Self::NoteDue => i18n.statistics_due_date(),
|
||||||
Self::NoteEase => i18n.browsing_average_ease(),
|
Self::NoteEase => i18n.browsing_average_ease(),
|
||||||
Self::NoteField => i18n.browsing_sort_field(),
|
Self::SortField => i18n.browsing_sort_field(),
|
||||||
Self::NoteInterval => i18n.browsing_average_interval(),
|
Self::NoteInterval => i18n.browsing_average_interval(),
|
||||||
Self::NoteMod => i18n.search_note_modified(),
|
Self::NoteMod => i18n.search_note_modified(),
|
||||||
Self::NoteLapses => i18n.scheduling_lapses(),
|
Self::NoteLapses => i18n.scheduling_lapses(),
|
||||||
Self::NoteReps => i18n.scheduling_reviews(),
|
Self::NoteReps => i18n.scheduling_reviews(),
|
||||||
Self::NoteTags => i18n.editing_tags(),
|
Self::Tags => i18n.editing_tags(),
|
||||||
Self::Notetype => i18n.browsing_note(),
|
Self::Notetype => i18n.browsing_note(),
|
||||||
}
|
}
|
||||||
.into()
|
.into()
|
||||||
|
|
|
@ -122,18 +122,18 @@ impl From<SortKindProto> for SortKind {
|
||||||
SortKindProto::NoteInterval => SortKind::NoteInterval,
|
SortKindProto::NoteInterval => SortKind::NoteInterval,
|
||||||
SortKindProto::NoteLapses => SortKind::NoteLapses,
|
SortKindProto::NoteLapses => SortKind::NoteLapses,
|
||||||
SortKindProto::NoteMod => SortKind::NoteMod,
|
SortKindProto::NoteMod => SortKind::NoteMod,
|
||||||
SortKindProto::NoteField => SortKind::NoteField,
|
SortKindProto::SortField => SortKind::SortField,
|
||||||
SortKindProto::NoteReps => SortKind::NoteReps,
|
SortKindProto::NoteReps => SortKind::NoteReps,
|
||||||
SortKindProto::NoteTags => SortKind::NoteTags,
|
SortKindProto::Tags => SortKind::Tags,
|
||||||
SortKindProto::Notetype => SortKind::Notetype,
|
SortKindProto::Notetype => SortKind::Notetype,
|
||||||
SortKindProto::CardMod => SortKind::CardMod,
|
SortKindProto::CardMod => SortKind::CardMod,
|
||||||
SortKindProto::CardReps => SortKind::CardReps,
|
SortKindProto::Reps => SortKind::Reps,
|
||||||
SortKindProto::CardDue => SortKind::CardDue,
|
SortKindProto::Due => SortKind::Due,
|
||||||
SortKindProto::CardEase => SortKind::CardEase,
|
SortKindProto::Ease => SortKind::Ease,
|
||||||
SortKindProto::CardLapses => SortKind::CardLapses,
|
SortKindProto::Lapses => SortKind::Lapses,
|
||||||
SortKindProto::CardInterval => SortKind::CardInterval,
|
SortKindProto::Interval => SortKind::Interval,
|
||||||
SortKindProto::CardDeck => SortKind::CardDeck,
|
SortKindProto::Deck => SortKind::Deck,
|
||||||
SortKindProto::CardTemplate => SortKind::CardTemplate,
|
SortKindProto::Cards => SortKind::Cards,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,30 +30,33 @@ pub enum Column {
|
||||||
Custom,
|
Custom,
|
||||||
Question,
|
Question,
|
||||||
Answer,
|
Answer,
|
||||||
#[strum(serialize = "deck")]
|
Deck,
|
||||||
CardDeck,
|
#[strum(serialize = "cardDue")]
|
||||||
CardDue,
|
Due,
|
||||||
CardEase,
|
#[strum(serialize = "cardEase")]
|
||||||
CardLapses,
|
Ease,
|
||||||
|
#[strum(serialize = "cardLapses")]
|
||||||
|
Lapses,
|
||||||
#[strum(serialize = "cardIvl")]
|
#[strum(serialize = "cardIvl")]
|
||||||
CardInterval,
|
Interval,
|
||||||
CardMod,
|
CardMod,
|
||||||
CardReps,
|
#[strum(serialize = "cardReps")]
|
||||||
|
Reps,
|
||||||
#[strum(serialize = "template")]
|
#[strum(serialize = "template")]
|
||||||
CardTemplate,
|
Cards,
|
||||||
NoteCards,
|
NoteCards,
|
||||||
#[strum(serialize = "noteCrt")]
|
#[strum(serialize = "noteCrt")]
|
||||||
NoteCreation,
|
NoteCreation,
|
||||||
NoteDue,
|
NoteDue,
|
||||||
NoteEase,
|
NoteEase,
|
||||||
#[strum(serialize = "noteFld")]
|
#[strum(serialize = "noteFld")]
|
||||||
NoteField,
|
SortField,
|
||||||
#[strum(serialize = "noteIvl")]
|
#[strum(serialize = "noteIvl")]
|
||||||
NoteInterval,
|
NoteInterval,
|
||||||
NoteLapses,
|
NoteLapses,
|
||||||
NoteMod,
|
NoteMod,
|
||||||
NoteReps,
|
NoteReps,
|
||||||
NoteTags,
|
Tags,
|
||||||
#[strum(serialize = "note")]
|
#[strum(serialize = "note")]
|
||||||
Notetype,
|
Notetype,
|
||||||
}
|
}
|
||||||
|
@ -291,22 +294,22 @@ impl RowContext {
|
||||||
Ok(match column {
|
Ok(match column {
|
||||||
Column::Question => self.question_str(),
|
Column::Question => self.question_str(),
|
||||||
Column::Answer => self.answer_str(),
|
Column::Answer => self.answer_str(),
|
||||||
Column::CardDeck => self.deck_str(),
|
Column::Deck => self.deck_str(),
|
||||||
Column::CardDue | Column::NoteDue => self.due_str(),
|
Column::Due | Column::NoteDue => self.due_str(),
|
||||||
Column::CardEase | Column::NoteEase => self.ease_str(),
|
Column::Ease | Column::NoteEase => self.ease_str(),
|
||||||
Column::CardInterval | Column::NoteInterval => self.interval_str(),
|
Column::Interval | Column::NoteInterval => self.interval_str(),
|
||||||
Column::CardLapses | Column::NoteLapses => {
|
Column::Lapses | Column::NoteLapses => {
|
||||||
self.cards.iter().map(|c| c.lapses).sum::<u32>().to_string()
|
self.cards.iter().map(|c| c.lapses).sum::<u32>().to_string()
|
||||||
}
|
}
|
||||||
Column::CardMod => self.card_mod_str(),
|
Column::CardMod => self.card_mod_str(),
|
||||||
Column::CardReps | Column::NoteReps => {
|
Column::Reps | Column::NoteReps => {
|
||||||
self.cards.iter().map(|c| c.reps).sum::<u32>().to_string()
|
self.cards.iter().map(|c| c.reps).sum::<u32>().to_string()
|
||||||
}
|
}
|
||||||
Column::CardTemplate | Column::NoteCards => self.cards_str()?,
|
Column::Cards | Column::NoteCards => self.cards_str()?,
|
||||||
Column::NoteCreation => self.note_creation_str(),
|
Column::NoteCreation => self.note_creation_str(),
|
||||||
Column::NoteField => self.note_field_str(),
|
Column::SortField => self.note_field_str(),
|
||||||
Column::NoteMod => self.note.mtime.date_string(),
|
Column::NoteMod => self.note.mtime.date_string(),
|
||||||
Column::NoteTags => self.note.tags.join(" "),
|
Column::Tags => self.note.tags.join(" "),
|
||||||
Column::Notetype => self.notetype.name.to_owned(),
|
Column::Notetype => self.notetype.name.to_owned(),
|
||||||
Column::Custom => "".to_string(),
|
Column::Custom => "".to_string(),
|
||||||
})
|
})
|
||||||
|
@ -323,7 +326,7 @@ impl RowContext {
|
||||||
|
|
||||||
fn get_is_rtl(&self, column: Column) -> bool {
|
fn get_is_rtl(&self, column: Column) -> bool {
|
||||||
match column {
|
match column {
|
||||||
Column::NoteField => {
|
Column::SortField => {
|
||||||
let index = self.notetype.config.sort_field_idx as usize;
|
let index = self.notetype.config.sort_field_idx as usize;
|
||||||
self.notetype.fields[index].config.rtl
|
self.notetype.fields[index].config.rtl
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,22 +282,26 @@ pub enum SortKind {
|
||||||
NoteLapses,
|
NoteLapses,
|
||||||
NoteMod,
|
NoteMod,
|
||||||
#[serde(rename = "noteFld")]
|
#[serde(rename = "noteFld")]
|
||||||
NoteField,
|
SortField,
|
||||||
NoteReps,
|
NoteReps,
|
||||||
#[serde(rename = "note")]
|
#[serde(rename = "note")]
|
||||||
Notetype,
|
Notetype,
|
||||||
NoteTags,
|
#[serde(rename = "noteTags")]
|
||||||
|
Tags,
|
||||||
CardMod,
|
CardMod,
|
||||||
CardReps,
|
#[serde(rename = "cardReps")]
|
||||||
CardDue,
|
Reps,
|
||||||
CardEase,
|
#[serde(rename = "cardDue")]
|
||||||
CardLapses,
|
Due,
|
||||||
|
#[serde(rename = "cardEase")]
|
||||||
|
Ease,
|
||||||
|
#[serde(rename = "cardLapses")]
|
||||||
|
Lapses,
|
||||||
#[serde(rename = "cardIvl")]
|
#[serde(rename = "cardIvl")]
|
||||||
CardInterval,
|
Interval,
|
||||||
#[serde(rename = "deck")]
|
Deck,
|
||||||
CardDeck,
|
|
||||||
#[serde(rename = "template")]
|
#[serde(rename = "template")]
|
||||||
CardTemplate,
|
Cards,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SortKind {
|
impl Default for SortKind {
|
||||||
|
@ -338,7 +342,7 @@ mod test {
|
||||||
fn defaults() {
|
fn defaults() {
|
||||||
let col = open_test_collection();
|
let col = open_test_collection();
|
||||||
assert_eq!(col.get_current_deck_id(), DeckId(1));
|
assert_eq!(col.get_current_deck_id(), DeckId(1));
|
||||||
assert_eq!(col.get_browser_sort_kind(), SortKind::NoteField);
|
assert_eq!(col.get_browser_sort_kind(), SortKind::SortField);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -92,21 +92,21 @@ impl SortKind {
|
||||||
| SortKind::NoteCreation
|
| SortKind::NoteCreation
|
||||||
| SortKind::NoteDue
|
| SortKind::NoteDue
|
||||||
| SortKind::NoteEase
|
| SortKind::NoteEase
|
||||||
| SortKind::NoteField
|
| SortKind::SortField
|
||||||
| SortKind::NoteInterval
|
| SortKind::NoteInterval
|
||||||
| SortKind::NoteLapses
|
| SortKind::NoteLapses
|
||||||
| SortKind::NoteMod
|
| SortKind::NoteMod
|
||||||
| SortKind::NoteReps
|
| SortKind::NoteReps
|
||||||
| SortKind::NoteTags
|
| SortKind::Tags
|
||||||
| SortKind::Notetype => RequiredTable::Notes,
|
| SortKind::Notetype => RequiredTable::Notes,
|
||||||
SortKind::CardTemplate => RequiredTable::CardsAndNotes,
|
SortKind::Cards => RequiredTable::CardsAndNotes,
|
||||||
SortKind::CardMod
|
SortKind::CardMod
|
||||||
| SortKind::CardReps
|
| SortKind::Reps
|
||||||
| SortKind::CardDue
|
| SortKind::Due
|
||||||
| SortKind::CardEase
|
| SortKind::Ease
|
||||||
| SortKind::CardLapses
|
| SortKind::Lapses
|
||||||
| SortKind::CardInterval
|
| SortKind::Interval
|
||||||
| SortKind::CardDeck => RequiredTable::Cards,
|
| SortKind::Deck => RequiredTable::Cards,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,17 +233,17 @@ fn card_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
||||||
match kind {
|
match kind {
|
||||||
SortKind::NoteCreation => "n.id asc, c.ord asc".into(),
|
SortKind::NoteCreation => "n.id asc, c.ord asc".into(),
|
||||||
SortKind::NoteMod => "n.mod asc, c.ord asc".into(),
|
SortKind::NoteMod => "n.mod asc, c.ord asc".into(),
|
||||||
SortKind::NoteField => "n.sfld collate nocase asc, c.ord asc".into(),
|
SortKind::SortField => "n.sfld collate nocase asc, c.ord asc".into(),
|
||||||
SortKind::CardMod => "c.mod asc".into(),
|
SortKind::CardMod => "c.mod asc".into(),
|
||||||
SortKind::CardReps => "c.reps asc".into(),
|
SortKind::Reps => "c.reps asc".into(),
|
||||||
SortKind::CardDue => "c.type asc, c.due asc".into(),
|
SortKind::Due => "c.type asc, c.due asc".into(),
|
||||||
SortKind::CardEase => format!("c.type = {} asc, c.factor asc", CardType::New as i8).into(),
|
SortKind::Ease => format!("c.type = {} asc, c.factor asc", CardType::New as i8).into(),
|
||||||
SortKind::CardLapses => "c.lapses asc".into(),
|
SortKind::Lapses => "c.lapses asc".into(),
|
||||||
SortKind::CardInterval => "c.ivl asc".into(),
|
SortKind::Interval => "c.ivl asc".into(),
|
||||||
SortKind::NoteTags => "n.tags asc".into(),
|
SortKind::Tags => "n.tags asc".into(),
|
||||||
SortKind::CardDeck => "(select pos from sort_order where did = c.did) asc".into(),
|
SortKind::Deck => "(select pos from sort_order where did = c.did) asc".into(),
|
||||||
SortKind::Notetype => "(select pos from sort_order where ntid = n.mid) asc".into(),
|
SortKind::Notetype => "(select pos from sort_order where ntid = n.mid) asc".into(),
|
||||||
SortKind::CardTemplate => concat!(
|
SortKind::Cards => concat!(
|
||||||
"coalesce((select pos from sort_order where ntid = n.mid and ord = c.ord),",
|
"coalesce((select pos from sort_order where ntid = n.mid and ord = c.ord),",
|
||||||
// need to fall back on ord 0 for cloze cards
|
// need to fall back on ord 0 for cloze cards
|
||||||
"(select pos from sort_order where ntid = n.mid and ord = 0)) asc"
|
"(select pos from sort_order where ntid = n.mid and ord = 0)) asc"
|
||||||
|
@ -255,7 +255,7 @@ fn card_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
||||||
|
|
||||||
fn note_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
fn note_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
||||||
match kind {
|
match kind {
|
||||||
SortKind::CardDeck
|
SortKind::Deck
|
||||||
| SortKind::CardMod
|
| SortKind::CardMod
|
||||||
| SortKind::NoteCards
|
| SortKind::NoteCards
|
||||||
| SortKind::NoteDue
|
| SortKind::NoteDue
|
||||||
|
@ -264,9 +264,9 @@ fn note_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
||||||
| SortKind::NoteLapses
|
| SortKind::NoteLapses
|
||||||
| SortKind::NoteReps => "(select pos from sort_order where nid = n.id) asc".into(),
|
| SortKind::NoteReps => "(select pos from sort_order where nid = n.id) asc".into(),
|
||||||
SortKind::NoteCreation => "n.id asc".into(),
|
SortKind::NoteCreation => "n.id asc".into(),
|
||||||
SortKind::NoteField => "n.sfld collate nocase asc".into(),
|
SortKind::SortField => "n.sfld collate nocase asc".into(),
|
||||||
SortKind::NoteMod => "n.mod asc".into(),
|
SortKind::NoteMod => "n.mod asc".into(),
|
||||||
SortKind::NoteTags => "n.tags asc".into(),
|
SortKind::Tags => "n.tags asc".into(),
|
||||||
SortKind::Notetype => "(select pos from sort_order where ntid = n.mid) asc".into(),
|
SortKind::Notetype => "(select pos from sort_order where ntid = n.mid) asc".into(),
|
||||||
_ => "".into(),
|
_ => "".into(),
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ fn prepare_sort(col: &mut Collection, kind: SortKind, items: SearchItems) -> Res
|
||||||
use SortKind::*;
|
use SortKind::*;
|
||||||
let notes_mode = items == SearchItems::Notes;
|
let notes_mode = items == SearchItems::Notes;
|
||||||
let sql = match kind {
|
let sql = match kind {
|
||||||
CardDeck => {
|
Deck => {
|
||||||
if notes_mode {
|
if notes_mode {
|
||||||
include_str!("note_decks_order.sql")
|
include_str!("note_decks_order.sql")
|
||||||
} else {
|
} else {
|
||||||
|
@ -284,7 +284,7 @@ fn prepare_sort(col: &mut Collection, kind: SortKind, items: SearchItems) -> Res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CardMod if notes_mode => include_str!("card_mod_order.sql"),
|
CardMod if notes_mode => include_str!("card_mod_order.sql"),
|
||||||
CardTemplate => include_str!("template_order.sql"),
|
Cards => include_str!("template_order.sql"),
|
||||||
NoteCards => include_str!("note_cards_order.sql"),
|
NoteCards => include_str!("note_cards_order.sql"),
|
||||||
NoteDue => include_str!("note_due_order.sql"),
|
NoteDue => include_str!("note_due_order.sql"),
|
||||||
NoteEase => include_str!("note_ease_order.sql"),
|
NoteEase => include_str!("note_ease_order.sql"),
|
||||||
|
|
Loading…
Reference in a new issue