Display deck names when deleting (#3058)

* -  update remove decks function to return names of all deleted decks
- update protobuf message to display deck names
- update python files to receive message in the frontend.
- add message template to ftl

* update CONTRIBUTORS

* format

* refactor: move up deck names concatenation to tooltip api call
to fix type expectations

* restore core behavior and get deck name from view

* fix type specs

* remove new type and use str instead
restore incorrectly removed lines
This commit is contained in:
Pedro Schreiber 2024-03-13 02:29:06 -03:00 committed by GitHub
parent e8d95de426
commit 6ff42155ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 3 deletions

View file

@ -162,6 +162,7 @@ Lucas Scharenbroch <lucasscharenbroch@gmail.com>
Antonio Cavallo <a.cavallo@cavallinux.eu>
Han Yeong-woo <han@yeongwoo.dev>
Jean Khawand <jk@jeankhawand.com>
Pedro Schreiber <schreiber.mmb@gmail.com>
Foxy_null <https://github.com/Foxy-null>
Arbyste <arbyste@outlook.com>
********************

View file

@ -20,6 +20,11 @@ browsing-cards-deleted =
[one] { $count } card deleted.
*[other] { $count } cards deleted.
}
browsing-cards-deleted-with-deckname =
{ $count ->
[one] { $count } card deleted from {$deck_name}.
*[other] { $count } cards deleted from {$deck_name}.
}
browsing-change-deck = Change Deck
browsing-change-deck2 = Change Deck...
browsing-change-note-type = Change Note Type

View file

@ -1083,7 +1083,9 @@ class SidebarTreeView(QTreeView):
).run_in_background()
def delete_decks(self, _item: SidebarItem) -> None:
remove_decks(parent=self, deck_ids=self._selected_decks()).run_in_background()
remove_decks(
parent=self, deck_name=_item.name, deck_ids=self._selected_decks()
).run_in_background()
# Tags
###########################

View file

@ -356,7 +356,12 @@ class DeckBrowser:
).run_in_background()
def _delete(self, did: DeckId) -> None:
remove_decks(parent=self.mw, deck_ids=[did]).run_in_background()
deck_name = self.mw.col.decks.find_deck_in_tree(
self._render_data.tree, did
).name
remove_decks(
parent=self.mw, deck_ids=[did], deck_name=deck_name
).run_in_background()
# Top buttons
######################################################################

View file

@ -16,9 +16,16 @@ def remove_decks(
*,
parent: QWidget,
deck_ids: Sequence[DeckId],
deck_name: str,
) -> CollectionOp[OpChangesWithCount]:
return CollectionOp(parent, lambda col: col.decks.remove(deck_ids)).success(
lambda out: tooltip(tr.browsing_cards_deleted(count=out.count), parent=parent)
lambda out: tooltip(
tr.browsing_cards_deleted_with_deckname(
count=out.count,
deck_name=deck_name,
),
parent=parent,
)
)