diff --git a/ftl/core/change-notetype.ftl b/ftl/core/change-notetype.ftl index 82df06249..419030389 100644 --- a/ftl/core/change-notetype.ftl +++ b/ftl/core/change-notetype.ftl @@ -1,5 +1,8 @@ change-notetype-current = Current change-notetype-new = New +change-notetype-nothing = (Nothing) +change-notetype-collapse = Collapse +change-notetype-expand = Expand change-notetype-will-discard-content = Will discard content on the following fields: change-notetype-will-discard-cards = Will remove the following cards: change-notetype-fields = Fields diff --git a/proto/anki/notetypes.proto b/proto/anki/notetypes.proto index 2b8dc9146..85592cbc0 100644 --- a/proto/anki/notetypes.proto +++ b/proto/anki/notetypes.proto @@ -167,6 +167,7 @@ message ChangeNotetypeRequest { int64 old_notetype_id = 4; int64 new_notetype_id = 5; int64 current_schema = 6; + string old_notetype_name = 7; } message ChangeNotetypeInfo { @@ -175,4 +176,5 @@ message ChangeNotetypeInfo { repeated string new_field_names = 3; repeated string new_template_names = 4; ChangeNotetypeRequest input = 5; + string old_notetype_name = 6; } diff --git a/pylib/anki/models.py b/pylib/anki/models.py index 02e39a1b3..71c2c75af 100644 --- a/pylib/anki/models.py +++ b/pylib/anki/models.py @@ -415,6 +415,7 @@ and notes.mid = ? and cards.ord = ?""", note_ids=nids, new_fields=field_map, new_templates=template_map, + old_notetype_name=notetype["name"], old_notetype_id=notetype["id"], new_notetype_id=newModel["id"], current_schema=self.col.db.scalar("select scm from col"), diff --git a/qt/aqt/changenotetype.py b/qt/aqt/changenotetype.py index d66209931..4876e4013 100644 --- a/qt/aqt/changenotetype.py +++ b/qt/aqt/changenotetype.py @@ -45,7 +45,7 @@ class ChangeNotetypeDialog(QDialog): def _setup_ui(self, notetype_id: NotetypeId) -> None: self.setWindowModality(Qt.WindowModality.ApplicationModal) self.mw.garbage_collect_on_dialog_finish(self) - self.setMinimumWidth(400) + self.setMinimumSize(400, 300) disable_help_button(self) restoreGeom(self, self.TITLE) addCloseShortcut(self) diff --git a/rslib/src/backend/notetypes.rs b/rslib/src/backend/notetypes.rs index 3e2e85047..ee8f2938b 100644 --- a/rslib/src/backend/notetypes.rs +++ b/rslib/src/backend/notetypes.rs @@ -190,6 +190,7 @@ impl From for Notetype { impl From for pb::ChangeNotetypeInfo { fn from(i: NotetypeChangeInfo) -> Self { pb::ChangeNotetypeInfo { + old_notetype_name: i.old_notetype_name, old_field_names: i.old_field_names, old_template_names: i.old_template_names, new_field_names: i.new_field_names, @@ -204,6 +205,7 @@ impl From for ChangeNotetypeInput { ChangeNotetypeInput { current_schema: i.current_schema.into(), note_ids: i.note_ids.into_newtype(NoteId), + old_notetype_name: i.old_notetype_name, old_notetype_id: i.old_notetype_id.into(), new_notetype_id: i.new_notetype_id.into(), new_fields: i @@ -232,6 +234,7 @@ impl From for pb::ChangeNotetypeRequest { pb::ChangeNotetypeRequest { current_schema: i.current_schema.into(), note_ids: i.note_ids.into_iter().map(Into::into).collect(), + old_notetype_name: i.old_notetype_name, old_notetype_id: i.old_notetype_id.into(), new_notetype_id: i.new_notetype_id.into(), new_fields: i diff --git a/rslib/src/notetype/notetypechange.rs b/rslib/src/notetype/notetypechange.rs index 50cbf627a..a910c6ca0 100644 --- a/rslib/src/notetype/notetypechange.rs +++ b/rslib/src/notetype/notetypechange.rs @@ -16,6 +16,7 @@ use crate::{ pub struct ChangeNotetypeInput { pub current_schema: TimestampMillis, pub note_ids: Vec, + pub old_notetype_name: String, pub old_notetype_id: NotetypeId, pub new_notetype_id: NotetypeId, pub new_fields: Vec>, @@ -25,6 +26,7 @@ pub struct ChangeNotetypeInput { #[derive(Debug)] pub struct NotetypeChangeInfo { pub input: ChangeNotetypeInput, + pub old_notetype_name: String, pub old_field_names: Vec, pub old_template_names: Vec, pub new_field_names: Vec, @@ -77,18 +79,20 @@ impl Collection { .ok_or(AnkiError::NotFound)?; let current_schema = self.storage.get_collection_timestamps()?.schema_change; + let old_notetype_name = &old_notetype.name; let new_fields = default_field_map(&old_notetype, &new_notetype); let new_templates = default_template_map(&old_notetype, &new_notetype); - Ok(NotetypeChangeInfo { input: ChangeNotetypeInput { current_schema, note_ids: vec![], + old_notetype_name: old_notetype_name.clone(), old_notetype_id, new_notetype_id, new_fields, new_templates, }, + old_notetype_name: old_notetype_name.clone(), old_field_names: old_notetype.fields.iter().map(|f| f.name.clone()).collect(), old_template_names: old_notetype .templates diff --git a/sass/_vars.scss b/sass/_vars.scss index a92eefccc..1821b4e12 100644 --- a/sass/_vars.scss +++ b/sass/_vars.scss @@ -5,6 +5,7 @@ --text-fg: black; --window-bg: #ececec; --frame-bg: white; + --pane-bg: #e5e5e5; --border: #aaa; --medium-border: #b6b6b6; --faint-border: #e7e7e7; @@ -44,6 +45,7 @@ --text-fg: white; --window-bg: #2f2f31; --frame-bg: #3a3a3a; + --pane-bg: #3a3a3a; --border: #777; --medium-border: #444; --faint-border: #29292b; diff --git a/ts/change-notetype/Alert.svelte b/ts/change-notetype/Alert.svelte new file mode 100644 index 000000000..1054a2be2 --- /dev/null +++ b/ts/change-notetype/Alert.svelte @@ -0,0 +1,60 @@ + + + +
+ {#if unused.length > maxItems} +
(collapsed = !collapsed)}> + + {@html icon} + + {collapseMsg} +
+ {/if} + {unusedMsg} + {#if collapsed} +
+ {unused.slice(0, maxItems).join(", ")} + {#if unused.length > maxItems} + ... (+{unused.length - maxItems}) + {/if} +
+ {:else} +
    + {#each unused as entry} +
  • {entry}
  • + {/each} +
+ {/if} +
+ + diff --git a/ts/change-notetype/BUILD.bazel b/ts/change-notetype/BUILD.bazel index a52ddc8bc..7bb2fbed8 100644 --- a/ts/change-notetype/BUILD.bazel +++ b/ts/change-notetype/BUILD.bazel @@ -2,6 +2,7 @@ load("//ts:prettier.bzl", "prettier_test") load("//ts:eslint.bzl", "eslint_test") load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check") load("//ts:esbuild.bzl", "esbuild") +load("//ts:vendor.bzl", "copy_bootstrap_icons") load("//ts:compile_sass.bzl", "compile_sass") load("//ts:typescript.bzl", "typescript") load("//ts:jest.bzl", "jest_test") @@ -48,6 +49,7 @@ esbuild( visibility = ["//visibility:public"], deps = [ ":base_css", + "@npm//bootstrap-icons", ":index", ":svelte", ], diff --git a/ts/change-notetype/ChangeNotetypePage.svelte b/ts/change-notetype/ChangeNotetypePage.svelte index 03dc13305..11519372f 100644 --- a/ts/change-notetype/ChangeNotetypePage.svelte +++ b/ts/change-notetype/ChangeNotetypePage.svelte @@ -4,31 +4,54 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - +
+ + +
-
{tr.changeNotetypeFields()}
- - - -
{tr.changeNotetypeTemplates()}
- -{#if $info.templates} - -{:else} -
{@html marked(tr.changeNotetypeToFromCloze())}
-{/if} +
+ + + + + + + + + + + {#if $info.templates} + + {:else} +
{@html marked(tr.changeNotetypeToFromCloze())}
+ {/if} +
+ +
+
diff --git a/ts/change-notetype/Mapper.svelte b/ts/change-notetype/Mapper.svelte index d90cf1030..82a8cfd26 100644 --- a/ts/change-notetype/Mapper.svelte +++ b/ts/change-notetype/Mapper.svelte @@ -4,43 +4,20 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - - - {tr.changeNotetypeCurrent()} - {tr.changeNotetypeNew()} - + + {#each $info.mapForContext(ctx) as _, newIndex} {/each} - -{#if unused.length > 0} -
- {unusedMsg} -
    - {#each unused as entry} -
  • {entry}
  • - {/each} -
-
-{/if} diff --git a/ts/change-notetype/NotetypeSelector.svelte b/ts/change-notetype/NotetypeSelector.svelte index b0a8608a5..b7e9dfc9d 100644 --- a/ts/change-notetype/NotetypeSelector.svelte +++ b/ts/change-notetype/NotetypeSelector.svelte @@ -4,19 +4,21 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - + + + + + {$info.oldNotetypeName} + + + + + + {#if window.getComputedStyle(document.body).direction == "rtl"} + {@html arrowLeftIcon} + {:else} + {@html arrowRightIcon} + {/if} + + diff --git a/ts/change-notetype/StickyNav.svelte b/ts/change-notetype/StickyNav.svelte new file mode 100644 index 000000000..f9412030f --- /dev/null +++ b/ts/change-notetype/StickyNav.svelte @@ -0,0 +1,61 @@ + + + + +

+ {heading} + {#if unused.length > 0} + + {@html exclamationIcon} + + {/if} +

+ + {#if unused.length > 0} + + {/if} + + {#if $info.templates} + + + {tr.changeNotetypeCurrent()} + {tr.changeNotetypeNew()} + + + {/if} +
+ + diff --git a/ts/change-notetype/change-notetype-base.scss b/ts/change-notetype/change-notetype-base.scss index 782311aa0..846e31503 100644 --- a/ts/change-notetype/change-notetype-base.scss +++ b/ts/change-notetype/change-notetype-base.scss @@ -15,10 +15,8 @@ } body { - width: min(100vw, 35em); + width: min(100vw, 70em); margin: 0 auto; - // leave some space for rounded screens - margin-bottom: 2em; } html { @@ -26,8 +24,8 @@ html { } #main { - padding: 0.5em; - padding-top: 0; + padding: 0.5em 1em 1em 1em; + height: 100vh; } // override the default down arrow colour in