mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
REFACTOR: Remove requirejs
calls
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import { ajax } from 'discourse/lib/ajax';
|
import { ajax } from 'discourse/lib/ajax';
|
||||||
|
import AdminUser from 'admin/models/admin-user';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNames: ["ip-lookup"],
|
classNames: ["ip-lookup"],
|
||||||
@ -44,7 +45,6 @@ export default Ember.Component.extend({
|
|||||||
self.set("totalOthersWithSameIP", result.total);
|
self.set("totalOthersWithSameIP", result.total);
|
||||||
});
|
});
|
||||||
|
|
||||||
const AdminUser = requirejs('admin/models/admin-user').default;
|
|
||||||
AdminUser.findAll("active", data).then(function (users) {
|
AdminUser.findAll("active", data).then(function (users) {
|
||||||
self.setProperties({
|
self.setProperties({
|
||||||
other_accounts: users,
|
other_accounts: users,
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import Permalink from 'admin/models/permalink';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNames: ['permalink-form'],
|
classNames: ['permalink-form'],
|
||||||
formSubmitted: false,
|
formSubmitted: false,
|
||||||
@ -18,8 +20,6 @@ export default Ember.Component.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
submit: function() {
|
submit: function() {
|
||||||
const Permalink = requirejs('admin/models/permalink').default;
|
|
||||||
|
|
||||||
if (!this.get('formSubmitted')) {
|
if (!this.get('formSubmitted')) {
|
||||||
const self = this;
|
const self = this;
|
||||||
self.set('formSubmitted', true);
|
self.set('formSubmitted', true);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
import AdminUser from 'admin/models/admin-user';
|
||||||
import { ajax } from 'discourse/lib/ajax';
|
import { ajax } from 'discourse/lib/ajax';
|
||||||
|
|
||||||
const ApiKey = Discourse.Model.extend({
|
const ApiKey = Discourse.Model.extend({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,8 +38,7 @@ ApiKey.reopenClass({
|
|||||||
@param {...} var_args the properties to initialize this with
|
@param {...} var_args the properties to initialize this with
|
||||||
@returns {ApiKey} the ApiKey instance
|
@returns {ApiKey} the ApiKey instance
|
||||||
**/
|
**/
|
||||||
create: function() {
|
create() {
|
||||||
const AdminUser = requirejs('admin/models/admin-user').default;
|
|
||||||
var result = this._super.apply(this, arguments);
|
var result = this._super.apply(this, arguments);
|
||||||
if (result.user) {
|
if (result.user) {
|
||||||
result.user = AdminUser.create(result.user);
|
result.user = AdminUser.create(result.user);
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
/**
|
import Report from 'admin/models/report';
|
||||||
Handles routes for admin reports
|
|
||||||
|
|
||||||
@class AdminReportsRoute
|
|
||||||
@extends Discourse.Route
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
queryParams: { mode: {}, "start_date": {}, "end_date": {}, "category_id": {}, "group_id": {} },
|
queryParams: { mode: {}, "start_date": {}, "end_date": {}, "category_id": {}, "group_id": {} },
|
||||||
|
|
||||||
model: function(params) {
|
model(params) {
|
||||||
const Report = requirejs('admin/models/report').default;
|
|
||||||
return Report.find(params.type, params['start_date'], params['end_date'], params['category_id'], params['group_id']);
|
return Report.find(params.type, params['start_date'], params['end_date'], params['category_id'], params['group_id']);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -27,15 +27,21 @@
|
|||||||
//= require ./discourse/lib/eyeline
|
//= require ./discourse/lib/eyeline
|
||||||
//= require ./discourse/lib/show-modal
|
//= require ./discourse/lib/show-modal
|
||||||
//= require ./discourse/mixins/scrolling
|
//= require ./discourse/mixins/scrolling
|
||||||
|
//= require ./discourse/lib/ajax-error
|
||||||
//= require ./discourse/models/model
|
//= require ./discourse/models/model
|
||||||
//= require ./discourse/models/rest
|
//= require ./discourse/models/rest
|
||||||
|
//= require ./discourse/models/result-set
|
||||||
|
//= require ./discourse/models/store
|
||||||
|
//= require ./discourse/models/action-summary
|
||||||
|
//= require ./discourse/models/topic
|
||||||
|
//= require ./discourse/models/draft
|
||||||
|
//= require ./discourse/models/composer
|
||||||
//= require ./discourse/models/badge-grouping
|
//= require ./discourse/models/badge-grouping
|
||||||
//= require ./discourse/models/badge
|
//= require ./discourse/models/badge
|
||||||
//= require ./discourse/models/permission-type
|
//= require ./discourse/models/permission-type
|
||||||
//= require ./discourse/models/user-action-group
|
//= require ./discourse/models/user-action-group
|
||||||
//= require ./discourse/models/category
|
//= require ./discourse/models/category
|
||||||
//= require ./discourse/models/input-validation
|
//= require ./discourse/models/input-validation
|
||||||
//= require ./discourse/lib/ajax-error
|
|
||||||
//= require ./discourse/lib/search
|
//= require ./discourse/lib/search
|
||||||
//= require ./discourse/lib/user-search
|
//= require ./discourse/lib/user-search
|
||||||
//= require ./discourse/lib/export-csv
|
//= require ./discourse/lib/export-csv
|
||||||
@ -44,10 +50,7 @@
|
|||||||
//= require ./discourse/lib/debounce
|
//= require ./discourse/lib/debounce
|
||||||
//= require ./discourse/lib/safari-hacks
|
//= require ./discourse/lib/safari-hacks
|
||||||
//= require_tree ./discourse/adapters
|
//= require_tree ./discourse/adapters
|
||||||
//= require ./discourse/models/result-set
|
|
||||||
//= require ./discourse/models/store
|
|
||||||
//= require ./discourse/models/post-action-type
|
//= require ./discourse/models/post-action-type
|
||||||
//= require ./discourse/models/action-summary
|
|
||||||
//= require ./discourse/models/post
|
//= require ./discourse/models/post
|
||||||
//= require ./discourse/lib/posts-with-placeholders
|
//= require ./discourse/lib/posts-with-placeholders
|
||||||
//= require ./discourse/models/post-stream
|
//= require ./discourse/models/post-stream
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
|
// ensure Discourse is added as a global
|
||||||
(function() {
|
(function() {
|
||||||
var Discourse = requirejs('discourse').default;
|
window.Discourse = requirejs('discourse').default;
|
||||||
|
|
||||||
Discourse.dialect_deprecated = true;
|
|
||||||
|
|
||||||
window.Discourse = Discourse;
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { observes } from 'ember-addons/ember-computed-decorators';
|
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||||
import { escapeExpression } from 'discourse/lib/utilities';
|
import { escapeExpression } from 'discourse/lib/utilities';
|
||||||
|
import Group from 'discourse/models/group';
|
||||||
|
import Badge from 'discourse/models/badge';
|
||||||
|
|
||||||
const REGEXP_BLOCKS = /(([^" \t\n\x0B\f\r]+)?(("[^"]+")?))/g;
|
const REGEXP_BLOCKS = /(([^" \t\n\x0B\f\r]+)?(("[^"]+")?))/g;
|
||||||
|
|
||||||
@ -525,12 +527,10 @@ export default Em.Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
groupFinder(term) {
|
groupFinder(term) {
|
||||||
const Group = requirejs('discourse/models/group').default;
|
|
||||||
return Group.findAll({search: term, ignore_automatic: false});
|
return Group.findAll({search: term, ignore_automatic: false});
|
||||||
},
|
},
|
||||||
|
|
||||||
badgeFinder(term) {
|
badgeFinder(term) {
|
||||||
const Badge = requirejs('discourse/models/badge').default;
|
|
||||||
return Badge.findAll({search: term});
|
return Badge.findAll({search: term});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -4,6 +4,7 @@ import BulkTopicSelection from 'discourse/mixins/bulk-topic-selection';
|
|||||||
import { endWith } from 'discourse/lib/computed';
|
import { endWith } from 'discourse/lib/computed';
|
||||||
import showModal from 'discourse/lib/show-modal';
|
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';
|
||||||
|
|
||||||
const controllerOpts = {
|
const controllerOpts = {
|
||||||
discovery: Ember.inject.controller(),
|
discovery: Ember.inject.controller(),
|
||||||
@ -60,7 +61,6 @@ const controllerOpts = {
|
|||||||
|
|
||||||
this.topicTrackingState.resetTracking();
|
this.topicTrackingState.resetTracking();
|
||||||
this.store.findFiltered('topicList', {filter}).then(list => {
|
this.store.findFiltered('topicList', {filter}).then(list => {
|
||||||
const TopicList = requirejs('discourse/models/topic-list').default;
|
|
||||||
TopicList.hideUniformCategory(list, this.get('category'));
|
TopicList.hideUniformCategory(list, this.get('category'));
|
||||||
|
|
||||||
this.setProperties({ model: list });
|
this.setProperties({ model: list });
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||||
import { emailValid } from 'discourse/lib/utilities';
|
import { emailValid } from 'discourse/lib/utilities';
|
||||||
import computed from 'ember-addons/ember-computed-decorators';
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
import Group from 'discourse/models/group';
|
||||||
|
import Invite from 'discourse/models/invite';
|
||||||
|
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
userInvitedShow: Ember.inject.controller('user-invited-show'),
|
userInvitedShow: Ember.inject.controller('user-invited-show'),
|
||||||
@ -144,7 +146,6 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
}.property('isPrivateTopic'),
|
}.property('isPrivateTopic'),
|
||||||
|
|
||||||
groupFinder(term) {
|
groupFinder(term) {
|
||||||
const Group = requirejs('discourse/models/group').default;
|
|
||||||
return Group.findAll({search: term, ignore_automatic: true});
|
return Group.findAll({search: term, ignore_automatic: true});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -191,9 +192,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
createInvite() {
|
createInvite() {
|
||||||
const Invite = requirejs('discourse/models/invite').default;
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
if (this.get('disabled')) { return; }
|
if (this.get('disabled')) { return; }
|
||||||
|
|
||||||
const groupNames = this.get('model.groupNames'),
|
const groupNames = this.get('model.groupNames'),
|
||||||
@ -237,7 +236,6 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
generateInvitelink() {
|
generateInvitelink() {
|
||||||
const Invite = requirejs('discourse/models/invite').default;
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
if (this.get('disabled')) { return; }
|
if (this.get('disabled')) { return; }
|
||||||
|
@ -6,13 +6,11 @@ import Category from 'discourse/models/category';
|
|||||||
import { search as searchCategoryTag } from 'discourse/lib/category-tag-search';
|
import { search as searchCategoryTag } from 'discourse/lib/category-tag-search';
|
||||||
import userSearch from 'discourse/lib/user-search';
|
import userSearch from 'discourse/lib/user-search';
|
||||||
import { userPath } from 'discourse/lib/url';
|
import { userPath } from 'discourse/lib/url';
|
||||||
|
import User from 'discourse/models/user';
|
||||||
|
import Post from 'discourse/models/post';
|
||||||
|
import Topic from 'discourse/models/topic';
|
||||||
|
|
||||||
export function translateResults(results, opts) {
|
export function translateResults(results, opts) {
|
||||||
|
|
||||||
const User = requirejs('discourse/models/user').default;
|
|
||||||
const Post = requirejs('discourse/models/post').default;
|
|
||||||
const Topic = requirejs('discourse/models/topic').default;
|
|
||||||
|
|
||||||
if (!opts) opts = {};
|
if (!opts) opts = {};
|
||||||
|
|
||||||
// Topics might not be included
|
// Topics might not be included
|
||||||
|
@ -8,6 +8,7 @@ import computed from 'ember-addons/ember-computed-decorators';
|
|||||||
import { postUrl } from 'discourse/lib/utilities';
|
import { postUrl } from 'discourse/lib/utilities';
|
||||||
import { cook } from 'discourse/lib/text';
|
import { cook } from 'discourse/lib/text';
|
||||||
import { userPath } from 'discourse/lib/url';
|
import { userPath } from 'discourse/lib/url';
|
||||||
|
import Composer from 'discourse/models/composer';
|
||||||
|
|
||||||
const Post = RestModel.extend({
|
const Post = RestModel.extend({
|
||||||
|
|
||||||
@ -104,7 +105,6 @@ const Post = RestModel.extend({
|
|||||||
|
|
||||||
createProperties() {
|
createProperties() {
|
||||||
// composer only used once, defer the dependency
|
// composer only used once, defer the dependency
|
||||||
const Composer = requirejs('discourse/models/composer').default;
|
|
||||||
const data = this.getProperties(Composer.serializedFieldsForCreate());
|
const data = this.getProperties(Composer.serializedFieldsForCreate());
|
||||||
data.reply_to_post_number = this.get('reply_to_post_number');
|
data.reply_to_post_number = this.get('reply_to_post_number');
|
||||||
data.image_sizes = this.get('imageSizes');
|
data.image_sizes = this.get('imageSizes');
|
||||||
|
@ -8,6 +8,7 @@ import mobile from 'discourse/lib/mobile';
|
|||||||
import { findAll } from 'discourse/models/login-method';
|
import { findAll } from 'discourse/models/login-method';
|
||||||
import { getOwner } from 'discourse-common/lib/get-owner';
|
import { getOwner } from 'discourse-common/lib/get-owner';
|
||||||
import { userPath } from 'discourse/lib/url';
|
import { userPath } from 'discourse/lib/url';
|
||||||
|
import Composer from 'discourse/models/composer';
|
||||||
|
|
||||||
function unlessReadOnly(method, message) {
|
function unlessReadOnly(method, message) {
|
||||||
return function() {
|
return function() {
|
||||||
@ -58,7 +59,6 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
|
|||||||
reply = post ? window.location.protocol + "//" + window.location.host + post.get("url") : null;
|
reply = post ? window.location.protocol + "//" + window.location.host + post.get("url") : null;
|
||||||
|
|
||||||
// used only once, one less dependency
|
// used only once, one less dependency
|
||||||
const Composer = requirejs('discourse/models/composer').default;
|
|
||||||
return this.controllerFor('composer').open({
|
return this.controllerFor('composer').open({
|
||||||
action: Composer.PRIVATE_MESSAGE,
|
action: Composer.PRIVATE_MESSAGE,
|
||||||
usernames: recipient,
|
usernames: recipient,
|
||||||
|
Reference in New Issue
Block a user