mirror of
https://github.com/ankitects/anki.git
synced 2025-12-10 21:36:55 -05:00
Fix misleading warning when changing notetype from/to cloze (#2744)
This commit is contained in:
parent
dfe0370a2a
commit
bba67fdab4
5 changed files with 9 additions and 6 deletions
|
|
@ -210,6 +210,7 @@ message ChangeNotetypeRequest {
|
|||
int64 new_notetype_id = 5;
|
||||
int64 current_schema = 6;
|
||||
string old_notetype_name = 7;
|
||||
bool is_cloze = 8;
|
||||
}
|
||||
|
||||
message ChangeNotetypeInfo {
|
||||
|
|
|
|||
|
|
@ -422,11 +422,8 @@ and notes.mid = ? and cards.ord = ?""",
|
|||
self.col.mod_schema(check=True)
|
||||
assert fmap
|
||||
field_map = self._convert_legacy_map(fmap, len(newModel["flds"]))
|
||||
if (
|
||||
not cmap
|
||||
or newModel["type"] == MODEL_CLOZE
|
||||
or notetype["type"] == MODEL_CLOZE
|
||||
):
|
||||
is_cloze = newModel["type"] == MODEL_CLOZE or notetype["type"] == MODEL_CLOZE
|
||||
if not cmap or is_cloze:
|
||||
template_map = []
|
||||
else:
|
||||
template_map = self._convert_legacy_map(cmap, len(newModel["tmpls"]))
|
||||
|
|
@ -439,6 +436,7 @@ and notes.mid = ? and cards.ord = ?""",
|
|||
old_notetype_id=notetype["id"],
|
||||
new_notetype_id=newModel["id"],
|
||||
current_schema=self.col.db.scalar("select scm from col"),
|
||||
is_cloze=is_cloze,
|
||||
)
|
||||
|
||||
def _convert_legacy_map(
|
||||
|
|
|
|||
|
|
@ -283,6 +283,7 @@ impl From<ChangeNotetypeInput> for anki_proto::notetypes::ChangeNotetypeRequest
|
|||
.into_iter()
|
||||
.map(|idx| idx.map(|v| v as i32).unwrap_or(-1))
|
||||
.collect(),
|
||||
is_cloze: i.new_templates.is_none(),
|
||||
new_templates: i
|
||||
.new_templates
|
||||
.unwrap_or_default()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
? tr.changeNotetypeFields()
|
||||
: tr.changeNotetypeTemplates();
|
||||
|
||||
$: unused = $info.unusedItems(ctx);
|
||||
$: unused =
|
||||
$info.isCloze && ctx === MapContext.Template ? [] : $info.unusedItems(ctx);
|
||||
</script>
|
||||
|
||||
<StickyContainer
|
||||
|
|
|
|||
|
|
@ -22,11 +22,13 @@ export class ChangeNotetypeInfoWrapper {
|
|||
fields: (number | null)[];
|
||||
templates?: (number | null)[];
|
||||
oldNotetypeName: string;
|
||||
isCloze: boolean;
|
||||
readonly info: ChangeNotetypeInfo;
|
||||
|
||||
constructor(info: ChangeNotetypeInfo) {
|
||||
this.info = info;
|
||||
const templates = info.input?.newTemplates ?? [];
|
||||
this.isCloze = info.input?.isCloze ?? false;
|
||||
if (templates.length > 0) {
|
||||
this.templates = negativeOneToNull(templates);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue