Anki/rslib/src/links.rs
RumovZ f1488b5983
Card type error (#1749)
* TemplateSaveError -> CardTypeError

* Don't show success tooltip if export fails

* Attach help page to error

Show help link if export fails due to card type error.

* Add type (dae)

* Add shared show_exception() (dae)

- Use a shared routine for printing standard backend errors, so that
we can take advantage of the help links in eg. the card layout screen
as well.
- The truthiness check on help in showInfo() would have ignored the
enum 0 value.
- Close the exporting dialog on a documented failure as well

* Fix local variable help_page
2022-03-28 22:17:50 +10:00

46 lines
2.2 KiB
Rust

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
pub use crate::backend_proto::links::help_page_link_request::HelpPage;
static HELP_SITE: &str = "https://docs.ankiweb.net/";
impl HelpPage {
pub fn to_link(self) -> String {
format!("{}{}", HELP_SITE, self.to_link_suffix())
}
pub fn to_link_suffix(self) -> &'static str {
match self {
HelpPage::NoteType => "getting-started.html#note-types",
HelpPage::Browsing => "browsing.html",
HelpPage::BrowsingFindAndReplace => "browsing.html#find-and-replace",
HelpPage::BrowsingNotesMenu => "browsing.html#notes",
HelpPage::KeyboardShortcuts => "studying.html#keyboard-shortcuts",
HelpPage::Editing => "editing.html",
HelpPage::AddingCardAndNote => "editing.html#adding-cards-and-notes",
HelpPage::AddingANoteType => "editing.html#adding-a-note-type",
HelpPage::Latex => "math.html#latex",
HelpPage::Preferences => "preferences.html",
HelpPage::Index => "",
HelpPage::Templates => "templates/intro.html",
HelpPage::FilteredDeck => "filtered-decks.html",
HelpPage::Importing => "importing.html",
HelpPage::CustomizingFields => "editing.html#customizing-fields",
HelpPage::DeckOptions => "deck-options.html",
HelpPage::EditingFeatures => "editing.html#editing-features",
HelpPage::FullScreenIssue => "platform/windows/display-issues.html#full-screen",
HelpPage::CardTypeTemplateError => "templates/errors.html#template-syntax-error",
HelpPage::CardTypeDuplicate => "templates/errors.html#identical-front-sides",
HelpPage::CardTypeNoFrontField => {
"templates/errors.html#no-field-replacement-on-front-side"
}
HelpPage::CardTypeMissingCloze => {
"templates/errors.html#no-cloze-filter-on-cloze-notetype"
}
HelpPage::CardTypeExtraneousCloze => {
"templates/errors.html#cloze-filter-outside-cloze-notetype"
}
}
}
}