FIX: Remove more of those pesky View classes

This commit is contained in:
Robin Ward
2016-11-11 16:31:08 -05:00
parent cc93cd76ef
commit a9ed15e11a
15 changed files with 65 additions and 130 deletions

View File

@ -6,29 +6,12 @@ var get = Ember.get;
var LOADING_WHITELIST = ['badges', 'userActivity', 'userPrivateMessages', 'admin', 'adminFlags',
'user', 'preferences', 'adminEmail', 'adminUsersList'];
var _dummyRoute;
var _loadingView;
const _options = {};
export function setResolverOption(name, value) {
_options[name] = value;
}
function loadingResolver(cb) {
return function(parsedName) {
var fullNameWithoutType = parsedName.fullNameWithoutType;
if (fullNameWithoutType.indexOf('Loading') >= 0) {
fullNameWithoutType = fullNameWithoutType.replace('Loading', '');
if (LOADING_WHITELIST.indexOf(fullNameWithoutType) !== -1) {
return cb(fullNameWithoutType);
}
}
};
}
function parseName(fullName) {
const nameParts = fullName.split(":"),
type = nameParts[0], fullNameWithoutType = nameParts[1],
@ -113,7 +96,7 @@ export function buildResolver(baseName) {
},
resolveView(parsedName) {
return this.findLoadingView(parsedName) || this.customResolve(parsedName) || this._super(parsedName);
return this.customResolve(parsedName) || this._super(parsedName);
},
resolveHelper(parsedName) {
@ -135,7 +118,13 @@ export function buildResolver(baseName) {
},
resolveRoute(parsedName) {
return this.findLoadingRoute(parsedName) || this.customResolve(parsedName) || this._super(parsedName);
return this.customResolve(parsedName) || this._super(parsedName);
},
findLoadingTemplate(parsedName) {
if (parsedName.fullNameWithoutType.match(/loading$/)) {
return Ember.TEMPLATES.loading;
}
},
resolveTemplate(parsedName) {
@ -143,22 +132,10 @@ export function buildResolver(baseName) {
this.findPluginTemplate(parsedName) ||
this.findMobileTemplate(parsedName) ||
this.findTemplate(parsedName) ||
this.findLoadingTemplate(parsedName) ||
Ember.TEMPLATES.not_found;
},
findLoadingRoute: loadingResolver(function() {
_dummyRoute = _dummyRoute || Ember.Route.extend();
return _dummyRoute;
}),
findLoadingView: loadingResolver(function() {
if (!_loadingView) {
_loadingView = require('discourse/views/loading', null, null, true /* force sync */);
if (_loadingView && _loadingView['default']) { _loadingView = _loadingView['default']; }
}
return _loadingView;
}),
findPluginTemplate(parsedName) {
var pluginParsedName = this.parseName(parsedName.fullName.replace("template:", "template:javascripts/"));
return this.findTemplate(pluginParsedName);