From b0d95c8c78e276680fa6cc17738291fac4ce9220 Mon Sep 17 00:00:00 2001 From: Amanda Alves Branquinho Date: Wed, 22 May 2024 12:50:21 -0300 Subject: [PATCH] FEATURE: Add bulk action to bookmark (#26856) This PR aims to add bulk actions to the user's bookmarks. After this feature, all users should be able to select multiple bookmarks and perform the actions of "deleting" or "clear reminders" --- .../app/components/bookmark-list.hbs | 62 ++++++++++- .../discourse/app/components/bookmark-list.js | 88 +++++++++++++++ .../controllers/user-activity-bookmarks.js | 13 +++ .../discourse/app/lib/bulk-select-helper.js | 1 + .../discourse/app/models/bookmark.js | 12 +++ .../app/templates/user/bookmarks.hbs | 1 + .../user-bookmark-bulk-actions-test.js | 63 +++++++++++ .../bulk-select-bookmarks-dropdown.js | 101 ++++++++++++++++++ .../common/base/_bookmark-list.scss | 13 +++ .../stylesheets/common/base/_index.scss | 1 + app/controllers/bookmarks_controller.rb | 20 ++++ config/locales/client.en.yml | 23 ++++ config/routes.rb | 2 + lib/bookmark_reminder_notification_handler.rb | 2 - lib/bookmarks_bulk_action.rb | 54 ++++++++++ spec/lib/bookmarks_bulk_action_spec.rb | 51 +++++++++ spec/requests/bookmarks_controller_spec.rb | 100 ++++++++++++++++- 17 files changed, 602 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/discourse/tests/acceptance/user-bookmark-bulk-actions-test.js create mode 100644 app/assets/javascripts/select-kit/addon/components/bulk-select-bookmarks-dropdown.js create mode 100644 app/assets/stylesheets/common/base/_bookmark-list.scss create mode 100644 lib/bookmarks_bulk_action.rb create mode 100644 spec/lib/bookmarks_bulk_action_spec.rb diff --git a/app/assets/javascripts/discourse/app/components/bookmark-list.hbs b/app/assets/javascripts/discourse/app/components/bookmark-list.hbs index 69c5dadac97..2f42a9a49ad 100644 --- a/app/assets/javascripts/discourse/app/components/bookmark-list.hbs +++ b/app/assets/javascripts/discourse/app/components/bookmark-list.hbs @@ -7,7 +7,55 @@ {{#if this.site.desktopView}} - {{i18n "topic.title"}} + {{#if this.bulkSelectEnabled}} + + + + {{/if}} + + + {{#if this.bulkSelectEnabled}} + + {{~#if this.canDoBulkActions}} +
+ + {{i18n + "bookmarks.bulk.selected_count" + count=this.selectedCount + }} + + +
+ + {{/if~}} + + +
+ {{else}} + + {{i18n "topic.title"}} + {{/if~}} +   {{i18n "post.bookmarks.updated" @@ -20,6 +68,18 @@ {{#each this.content as |bookmark|}} + {{#if this.bulkSelectEnabled}} + + + + {{/if}}