Anki/pylib/anki
Damien Elmes be994f4102 add support for custom undo steps, and merging multiple actions
Allows add-on authors to define their own label for a group of undoable
operations. For example:

def mark_and_bury(
    *,
    parent: QWidget,
    card_id: CardId,
) -> CollectionOp[OpChanges]:
    def op(col: Collection) -> OpChanges:
        target = col.add_custom_undo_entry("Mark and Bury")
        col.sched.bury_cards([card_id])
        card = col.get_card(card_id)
        col.tags.bulk_add(note_ids=[card.nid], tags="marked")
        return col.merge_undo_entries(target)

    return CollectionOp(parent, op)

The .add_custom_undo_entry() is for adding your own custom actions.
When extending a standard Anki action, instead store `target = 
col.undo_status().last_step` after executing the standard operation.

This started out as a bigger refactor that required a separate
.commit_undoable() call to be run after each operation, instead of
having each operation return changes directly. But that proved to be
somewhat cumbersome in unit tests, and ran the risk of unexpected
behaviour if the caller invoked an operation without remembering to
finalize it.
2021-05-06 16:39:06 +10:00
..
_backend implement deck config saving on JS end 2021-04-20 19:50:05 +10:00
importing switch NoteType to Notetype 2021-03-27 22:03:19 +10:00
scheduler support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
syncserver update to latest mypy_protobuf 2021-02-03 13:31:52 +10:00
__init__.py minor code cleanups with pyupgrade 2021-02-11 09:43:40 +10:00
BUILD.bazel move markdown dep into pylib 2021-03-24 22:19:14 +10:00
buildinfo.py run black/isort on Python scripts 2021-04-14 18:22:02 +10:00
cards.py add Dict suffix to Dict aliases in models.py 2021-03-27 21:46:49 +10:00
collection.py add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
config.py 'set due date' now undoable 2021-03-12 14:50:31 +10:00
consts.py move filtered deck labels to backend 2021-04-01 23:53:38 +10:00
db.py add some typehints, and remove some unused code 2021-01-31 20:56:21 +10:00
dbproxy.py commit immediately when there's no active checkpoint 2021-03-10 11:47:53 +10:00
decks.py implement deck config saving on JS end 2021-04-20 19:50:05 +10:00
errors.py simplify errors 2021-04-03 16:06:46 +10:00
exporting.py solve missing escape of ' (fixes #1144) 2021-04-22 00:54:11 -04:00
find.py ID -> Id in protobuf and Python 2021-03-27 21:38:20 +10:00
hooks.py add more typing, and enable checks for missing types for most of pylib 2021-01-31 21:38:36 +10:00
hooks_gen.py symlink generated .py/.pyi into tree to fix Python code completion 2020-12-16 11:36:42 +10:00
httpclient.py minor code cleanups with pyupgrade 2021-02-11 09:43:40 +10:00
lang.py update no-arg tr references in qt/ 2021-03-26 13:48:26 +10:00
latex.py add Dict suffix to Dict aliases in models.py 2021-03-27 21:46:49 +10:00
media.py switch NoteType to Notetype 2021-03-27 22:03:19 +10:00
models.py notetype removal undoable 2021-04-30 16:01:47 +10:00
notes.py update GUI to allow notetype addition undo 2021-04-30 15:58:08 +10:00
py.typed mark anki and aqt modules as having typing info 2020-01-13 13:03:37 +10:00
rsbackend.py fix rsbackend compat issues 2021-02-08 09:51:51 +10:00
sound.py support speed control in tts tags 2020-01-26 14:31:07 +10:00
stats.py update TR references with args in *.ts; fix average answer time 2021-03-26 19:10:39 +10:00
statsbg.py tweaking the folder names again 2020-01-03 07:48:38 +10:00
stdmodels.py update GUI to allow notetype addition undo 2021-04-30 15:58:08 +10:00
storage.py storage->collection 2020-05-20 17:58:28 +10:00
sync.py start work on more clearly defining backend/protobuf boundaries 2021-01-31 18:55:45 +10:00
tags.py undo support for tag collapse; expand->collapse for consistency w/ decks 2021-04-05 11:47:12 +10:00
template.py add Dict suffix to Dict aliases in models.py 2021-03-27 21:46:49 +10:00
types.py add missing copyright headers to *.py 2021-04-13 18:45:35 +10:00
utils.py Revert "ensure fields normalized before checksumming" 2021-03-17 22:21:13 +10:00
wheel_description.txt move aqt_data into source folder; implement wheel building 2020-11-04 12:14:03 +10:00