mirror of
https://github.com/discourse/discourse.git
synced 2025-03-20 18:35:35 +08:00
REFACTOR: Remove Discourse.Topic
constant
This commit is contained in:
parent
9d457fa51f
commit
d74546f50e
@ -5,6 +5,7 @@ import { inject } from "@ember/controller";
|
|||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
import Topic from "discourse/models/topic";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
export default Controller.extend(ModalFunctionality, {
|
export default Controller.extend(ModalFunctionality, {
|
||||||
@ -37,10 +38,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||||||
username: this.new_user
|
username: this.new_user
|
||||||
};
|
};
|
||||||
|
|
||||||
Discourse.Topic.changeOwners(
|
Topic.changeOwners(this.get("topicController.model.id"), options).then(
|
||||||
this.get("topicController.model.id"),
|
|
||||||
options
|
|
||||||
).then(
|
|
||||||
() => {
|
() => {
|
||||||
this.send("closeModal");
|
this.send("closeModal");
|
||||||
this.topicController.send("deselectAll");
|
this.topicController.send("deselectAll");
|
||||||
|
@ -758,8 +758,8 @@ export default Controller.extend({
|
|||||||
@method open
|
@method open
|
||||||
@param {Object} opts Options for creating a post
|
@param {Object} opts Options for creating a post
|
||||||
@param {String} opts.action The action we're performing: edit, reply or createTopic
|
@param {String} opts.action The action we're performing: edit, reply or createTopic
|
||||||
@param {Discourse.Post} [opts.post] The post we're replying to
|
@param {Post} [opts.post] The post we're replying to
|
||||||
@param {Discourse.Topic} [opts.topic] The topic we're replying to
|
@param {Topic} [opts.topic] The topic we're replying to
|
||||||
@param {String} [opts.quote] If we're opening a reply from a quote, the quote we're making
|
@param {String} [opts.quote] If we're opening a reply from a quote, the quote we're making
|
||||||
**/
|
**/
|
||||||
open(opts) {
|
open(opts) {
|
||||||
|
@ -8,6 +8,7 @@ import showModal from "discourse/lib/show-modal";
|
|||||||
import { userPath } from "discourse/lib/url";
|
import { userPath } from "discourse/lib/url";
|
||||||
import TopicList from "discourse/models/topic-list";
|
import TopicList from "discourse/models/topic-list";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
import Topic from "discourse/models/topic";
|
||||||
|
|
||||||
const controllerOpts = {
|
const controllerOpts = {
|
||||||
discovery: inject(),
|
discovery: inject(),
|
||||||
@ -83,7 +84,7 @@ const controllerOpts = {
|
|||||||
|
|
||||||
resetNew() {
|
resetNew() {
|
||||||
this.topicTrackingState.resetNew();
|
this.topicTrackingState.resetNew();
|
||||||
Discourse.Topic.resetNew().then(() => this.send("refresh"));
|
Topic.resetNew().then(() => this.send("refresh"));
|
||||||
},
|
},
|
||||||
|
|
||||||
dismissReadPosts() {
|
dismissReadPosts() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { empty, alias } from "@ember/object/computed";
|
import { empty, alias } from "@ember/object/computed";
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
|
import Topic from "discourse/models/topic";
|
||||||
|
|
||||||
const _buttons = [];
|
const _buttons = [];
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||||||
this.set("loading", true);
|
this.set("loading", true);
|
||||||
|
|
||||||
const topics = this.get("model.topics");
|
const topics = this.get("model.topics");
|
||||||
return Discourse.Topic.bulkOperation(topics, operation)
|
return Topic.bulkOperation(topics, operation)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
this.set("loading", false);
|
this.set("loading", false);
|
||||||
if (result && result.topic_ids) {
|
if (result && result.topic_ids) {
|
||||||
|
@ -2,6 +2,7 @@ import { alias } from "@ember/object/computed";
|
|||||||
import { NotificationLevels } from "discourse/lib/notification-levels";
|
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||||
import { on } from "ember-addons/ember-computed-decorators";
|
import { on } from "ember-addons/ember-computed-decorators";
|
||||||
import Mixin from "@ember/object/mixin";
|
import Mixin from "@ember/object/mixin";
|
||||||
|
import Topic from "discourse/models/topic";
|
||||||
|
|
||||||
export default Mixin.create({
|
export default Mixin.create({
|
||||||
bulkSelectEnabled: false,
|
bulkSelectEnabled: false,
|
||||||
@ -33,9 +34,9 @@ export default Mixin.create({
|
|||||||
|
|
||||||
let promise;
|
let promise;
|
||||||
if (this.selected.length > 0) {
|
if (this.selected.length > 0) {
|
||||||
promise = Discourse.Topic.bulkOperation(this.selected, operation);
|
promise = Topic.bulkOperation(this.selected, operation);
|
||||||
} else {
|
} else {
|
||||||
promise = Discourse.Topic.bulkOperationByFilter(
|
promise = Topic.bulkOperationByFilter(
|
||||||
"unread",
|
"unread",
|
||||||
operation,
|
operation,
|
||||||
this.get("category.id"),
|
this.get("category.id"),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import PreloadStore from "preload-store";
|
import PreloadStore from "preload-store";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
import Topic from "discourse/models/topic";
|
||||||
|
|
||||||
const CategoryList = Ember.ArrayProxy.extend({
|
const CategoryList = Ember.ArrayProxy.extend({
|
||||||
init() {
|
init() {
|
||||||
@ -39,7 +40,7 @@ CategoryList.reopenClass({
|
|||||||
|
|
||||||
if (c.topics) {
|
if (c.topics) {
|
||||||
c.topics = c.topics.map(t => {
|
c.topics = c.topics.map(t => {
|
||||||
const topic = Discourse.Topic.create(t);
|
const topic = Topic.create(t);
|
||||||
topic.set("category", c);
|
topic.set("category", c);
|
||||||
return topic;
|
return topic;
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,7 @@ import { ajax } from "discourse/lib/ajax";
|
|||||||
import Badge from "discourse/models/badge";
|
import Badge from "discourse/models/badge";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import Topic from "discourse/models/topic";
|
||||||
|
|
||||||
const UserBadge = Discourse.Model.extend({
|
const UserBadge = Discourse.Model.extend({
|
||||||
@computed
|
@computed
|
||||||
@ -35,7 +36,7 @@ UserBadge.reopenClass({
|
|||||||
}
|
}
|
||||||
var topics = {};
|
var topics = {};
|
||||||
json.topics.forEach(function(topicJson) {
|
json.topics.forEach(function(topicJson) {
|
||||||
topics[topicJson.id] = Discourse.Topic.create(topicJson);
|
topics[topicJson.id] = Topic.create(topicJson);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create the badges.
|
// Create the badges.
|
||||||
|
@ -93,7 +93,6 @@ JS
|
|||||||
"discourse/models/user",
|
"discourse/models/user",
|
||||||
"discourse/models/session",
|
"discourse/models/session",
|
||||||
"discourse/models/model",
|
"discourse/models/model",
|
||||||
"discourse/models/topic",
|
|
||||||
"discourse/models/post",
|
"discourse/models/post",
|
||||||
"discourse/views/grouped"]
|
"discourse/views/grouped"]
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user