diff --git a/app/assets/javascripts/discourse/controllers/user-activity-bookmarks-with-reminders.js b/app/assets/javascripts/discourse/controllers/user-activity-bookmarks-with-reminders.js index ad8ab35a6b5..11cc0bb6225 100644 --- a/app/assets/javascripts/discourse/controllers/user-activity-bookmarks-with-reminders.js +++ b/app/assets/javascripts/discourse/controllers/user-activity-bookmarks-with-reminders.js @@ -1,4 +1,5 @@ import Controller from "@ember/controller"; +import { Promise } from "rsvp"; import { inject } from "@ember/controller"; import discourseComputed from "discourse-common/utils/decorators"; import Bookmark from "discourse/models/bookmark"; @@ -21,17 +22,7 @@ export default Controller.extend({ return this.model .loadItems() .then(response => { - if (response && response.no_results_help) { - this.set("noResultsHelp", response.no_results_help); - } - - if (response && response.bookmarks) { - let bookmarks = []; - response.bookmarks.forEach(bookmark => { - bookmarks.push(Bookmark.create(bookmark)); - }); - this.content.pushObjects(bookmarks); - } + this.processLoadResponse(response); }) .catch(() => { this.set("noResultsHelp", I18n.t("bookmarks.list_permission_denied")); @@ -49,9 +40,46 @@ export default Controller.extend({ return loaded && contentLength === 0; }, + processLoadResponse(response) { + response = response.user_bookmark_list; + + if (response && response.no_results_help) { + this.set("noResultsHelp", response.no_results_help); + } + + this.model.more_bookmarks_url = response.more_bookmarks_url; + + if (response && response.bookmarks) { + let bookmarks = []; + response.bookmarks.forEach(bookmark => { + bookmarks.push(Bookmark.create(bookmark)); + }); + this.content.pushObjects(bookmarks); + } + }, + actions: { removeBookmark(bookmark) { return bookmark.destroy().then(() => this.loadItems()); + }, + + loadMore() { + if (this.loadingMore) { + return Promise.resolve(); + } + this.set("loadingMore", true); + + return this.model + .loadMore() + .then(response => this.processLoadResponse(response)) + .catch(() => { + this.set("noResultsHelp", I18n.t("bookmarks.list_permission_denied")); + }) + .finally(() => + this.setProperties({ + loadingMore: false + }) + ); } } }); diff --git a/app/assets/javascripts/discourse/models/bookmark.js b/app/assets/javascripts/discourse/models/bookmark.js index 1997ab632c4..8a8c09f35f1 100644 --- a/app/assets/javascripts/discourse/models/bookmark.js +++ b/app/assets/javascripts/discourse/models/bookmark.js @@ -117,6 +117,22 @@ const Bookmark = RestModel.extend({ loadItems() { return ajax(`/u/${this.user.username}/bookmarks.json`, { cache: "false" }); + }, + + loadMore() { + if (!this.more_bookmarks_url) { + return Promise.resolve(); + } + + let moreUrl = this.more_bookmarks_url; + if (moreUrl) { + let [url, params] = moreUrl.split("?"); + moreUrl = url; + if (params) { + moreUrl += "?" + params; + } + } + return ajax({ url: moreUrl }); } }); diff --git a/app/assets/javascripts/discourse/templates/user/bookmarks.hbs b/app/assets/javascripts/discourse/templates/user/bookmarks.hbs index 228490bfa4f..92c9979b544 100644 --- a/app/assets/javascripts/discourse/templates/user/bookmarks.hbs +++ b/app/assets/javascripts/discourse/templates/user/bookmarks.hbs @@ -2,50 +2,53 @@
{{i18n "topic.title"}} | -{{i18n "post.bookmarks.created"}} | -{{i18n "activity"}} | -- - - {{#each content as |bookmark|}} - | ||||||
---|---|---|---|---|---|---|---|---|---|
-
-
{{html-safe bookmark.excerpt}} + {{/if}} +
+ {{category-link bookmark.category}}
+ {{discourse-tags bookmark mode="list" tagsForUser=tagsForUser}}
+
+ |
+ {{format-date bookmark.created_at format="tiny"}} | + {{raw "list/activity-column" topic=bookmark class="num" tagName="td"}} ++ {{bookmark-actions-dropdown bookmark=bookmark removeBookmark=(action "removeBookmark")}} + | +