DEV: Use new bookmark modal (#252)
The new glimmer bookmark modal using d-modal is introduced in: https://github.com/discourse/discourse/pull/22532
This commit is contained in:
parent
b56065f989
commit
b8b66ded0e
|
@ -1,3 +1,4 @@
|
|||
3.1.0.beta4: 2cc87a10157852112712b7df1f7135b71023ad92
|
||||
3.1.0.beta3: 3907c4926383303ff85d992bb276e2b173cf0843
|
||||
3.1.0.beta1: 0f6b30c2d84d44978be1c845267609446ca9dbf2
|
||||
2.9.0.beta8: 729e5a2add46fb4e2d8ed092da05a87ebbfcf05b
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import Controller from "@ember/controller";
|
||||
import BookmarkModal from "discourse/components/modal/bookmark";
|
||||
import { BookmarkFormData } from "discourse/lib/bookmark";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import {
|
||||
NO_REMINDER_ICON,
|
||||
WITH_REMINDER_ICON,
|
||||
} from "discourse/models/bookmark";
|
||||
import { openBookmarkModal } from "discourse/controllers/bookmark";
|
||||
import { action } from "@ember/object";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
|
@ -13,6 +14,7 @@ import { inject as service } from "@ember/service";
|
|||
|
||||
export default class GroupReportsShowController extends Controller {
|
||||
@service currentUser;
|
||||
@service modal;
|
||||
|
||||
@tracked showResults = false;
|
||||
@tracked loading = false;
|
||||
|
@ -79,15 +81,17 @@ export default class GroupReportsShowController extends Controller {
|
|||
|
||||
@action
|
||||
toggleBookmark() {
|
||||
return openBookmarkModal(
|
||||
const modalBookmark =
|
||||
this.queryGroupBookmark ||
|
||||
this.store.createRecord("bookmark", {
|
||||
bookmarkable_type: "DiscourseDataExplorer::QueryGroup",
|
||||
bookmarkable_id: this.queryGroup.id,
|
||||
user_id: this.currentUser.id,
|
||||
}),
|
||||
{
|
||||
onAfterSave: (savedData) => {
|
||||
this.store.createRecord("bookmark", {
|
||||
bookmarkable_type: "DiscourseDataExplorer::QueryGroup",
|
||||
bookmarkable_id: this.queryGroup.id,
|
||||
user_id: this.currentUser.id,
|
||||
});
|
||||
return this.modal.show(BookmarkModal, {
|
||||
model: {
|
||||
bookmark: new BookmarkFormData(modalBookmark),
|
||||
afterSave: (savedData) => {
|
||||
const bookmark = this.store.createRecord("bookmark", savedData);
|
||||
this.queryGroupBookmark = bookmark;
|
||||
this.appEvents.trigger(
|
||||
|
@ -96,11 +100,11 @@ export default class GroupReportsShowController extends Controller {
|
|||
bookmark.attachedTo()
|
||||
);
|
||||
},
|
||||
onAfterDelete: () => {
|
||||
afterDelete: () => {
|
||||
this.queryGroupBookmark = null;
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// This is necessary with glimmer's one way data stream to get the child's
|
||||
|
|
Loading…
Reference in New Issue