Skip to content

FlashFork: ability to copy all currently selected records #14

@pconstrictor

Description

@pconstrictor

Menu option in Browse view: Duplicate selected records

[UPDATE: The essential functionality is pretty much covered by #15 now. Could maybe close this.]

This will copy each selected Note into whichever deck it was already in. (If feasible, highlight just the new records when finished.)

Under the hood, provide a public function for copying a single Note. Accept these parameters (for the sake of the Copy Deck feature) optionally specifying:

  • a different Note-type to be assigned to the copy
  • a different target deck in which to place the copy

[UPDATE: It may not be worth implementing this. The Anki developer believes it would encourage users to create more notes instead of more card templates. And the main use case is covered by the ability to duplicate entire decks.]

If switching Note-types, all fields in Note-type A must exist in B. (That is, A must be the same set as B, or a proper subset of it.)

Pseudocode:

Build a list of Note-type mappings. 
(Mappings such as `MyType1 --> MyType1` would mean 'no change'.)
But if any target Note-type is not compatible:
  Don't add a mapping for it
  Ask the user:
    "Note-type B cannot receive the data from Note-type A. All such records will be skipped. Continue anyway?"

For each card in the currently selected flashcard(s):
  Get the corresponding Note record
  If this Note isn't in "already processed", and its Note-type has a mapping:
    Copy the Note (passing any parameters relevant to its Note-type)
    If any error was caught, abort (this happens if the Note's fields don't perfectly match up with the target Note-type)
    Put this Note's ID in the "already processed" list

In the function that copies a single record, we'll probably want this logic

Create a Note of Note-type B. (Make sure that this generates all fields as empty fields.)
For each field in the source Note:
  Copy the value into the new Note

In other words, we don't want to be missing any fields if Note-type A's fields are exactly a subset of B's fields.

NOTE: Consider also adding a separate feature to the UI allowing the user to change the Note-type of all selected notes. This would create the same kind of mappings but wouldn't make a copy.

Menu option in Browse view: Change Note Type

See also: issue #9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions