mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Show custom data in stats screen
https://forums.ankiweb.net/t/feature-request-display-custom-data-in-card-info/27187
This commit is contained in:
parent
14da816857
commit
567ba06b5c
4 changed files with 19 additions and 0 deletions
|
@ -23,6 +23,7 @@ card-stats-review-log-type-relearn = Relearn
|
|||
card-stats-review-log-type-filtered = Filtered
|
||||
card-stats-review-log-type-manual = Manual
|
||||
card-stats-no-card = (No card to display.)
|
||||
card-stats-custom-data = Custom Data
|
||||
|
||||
## Window Titles
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ message CardStatsResponse {
|
|||
float total_secs = 15;
|
||||
string card_type = 16;
|
||||
string notetype = 17;
|
||||
string custom_data = 18;
|
||||
}
|
||||
|
||||
message GraphsRequest {
|
||||
|
|
|
@ -44,6 +44,7 @@ impl Collection {
|
|||
card_type: nt.get_template(card.template_idx)?.name.clone(),
|
||||
notetype: nt.name.clone(),
|
||||
revlog: revlog.iter().rev().map(stats_revlog_entry).collect(),
|
||||
custom_data: card.custom_data,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,22 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
statsRows.push({ label: tr2.cardStatsCardId(), value: stats.cardId });
|
||||
statsRows.push({ label: tr2.cardStatsNoteId(), value: stats.noteId });
|
||||
|
||||
if (stats.customData) {
|
||||
let value: string;
|
||||
try {
|
||||
const obj = JSON.parse(stats.customData);
|
||||
value = Object.entries(obj)
|
||||
.map(([k, v]) => `${k}=${v}`)
|
||||
.join(" ");
|
||||
} catch (exc) {
|
||||
value = stats.customData;
|
||||
}
|
||||
statsRows.push({
|
||||
label: tr2.cardStatsCustomData(),
|
||||
value: value,
|
||||
});
|
||||
}
|
||||
|
||||
return statsRows;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue