FIX: Mobile raw templates were not being resolved
This commit is contained in:
parent
a149913c4d
commit
ea3db56d1c
|
@ -10,6 +10,10 @@ export function setResolverOption(name, value) {
|
|||
_options[name] = value;
|
||||
}
|
||||
|
||||
export function getResolverOption(name) {
|
||||
return _options[name];
|
||||
}
|
||||
|
||||
function parseName(fullName) {
|
||||
const nameParts = fullName.split(":");
|
||||
const type = nameParts[0];
|
||||
|
|
|
@ -6,7 +6,6 @@ const _pluginCallbacks = [];
|
|||
const Discourse = Ember.Application.extend({
|
||||
rootElement: '#main',
|
||||
_docTitle: document.title,
|
||||
__TAGS_INCLUDED__: true,
|
||||
RAW_TEMPLATES: {},
|
||||
|
||||
getURL(url) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
@computed('placeholderKey')
|
||||
|
@ -17,7 +18,6 @@ export default Ember.Component.extend({
|
|||
var self = this;
|
||||
var selectedBadges;
|
||||
|
||||
var template = Discourse.RAW_TEMPLATES['badge-selector-autocomplete'];
|
||||
self.$('input').autocomplete({
|
||||
allowAny: false,
|
||||
items: _.isArray(this.get('badgeNames')) ? this.get('badgeNames') : [this.get('badgeNames')],
|
||||
|
@ -42,7 +42,7 @@ export default Ember.Component.extend({
|
|||
});
|
||||
});
|
||||
},
|
||||
template: template
|
||||
template: findRawTemplate('badge-selector-autocomplete')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
|
||||
import Category from 'discourse/models/category';
|
||||
import { on, observes } from 'ember-addons/ember-computed-decorators';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
@observes('categories')
|
||||
|
@ -12,7 +13,6 @@ export default Ember.Component.extend({
|
|||
@on('didInsertElement')
|
||||
_initializeAutocomplete(opts) {
|
||||
const self = this,
|
||||
template = Discourse.RAW_TEMPLATES['category-selector-autocomplete'],
|
||||
regexp = new RegExp(`href=['\"]${Discourse.getURL('/c/')}([^'\"]+)`);
|
||||
|
||||
this.$('input').autocomplete({
|
||||
|
@ -40,7 +40,7 @@ export default Ember.Component.extend({
|
|||
self.set('categories', categories);
|
||||
});
|
||||
},
|
||||
template,
|
||||
template: findRawTemplate('category-selector-autocomplete'),
|
||||
transformComplete(category) {
|
||||
return categoryBadgeHTML(category, {allowUncategorized: true});
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { linkSeenTagHashtags, fetchUnseenTagHashtags } from 'discourse/lib/link-
|
|||
import { load } from 'pretty-text/oneboxer';
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import InputValidation from 'discourse/models/input-validation';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
import { tinyAvatar,
|
||||
displayErrorForUpload,
|
||||
getUploadMarkdown,
|
||||
|
@ -61,10 +62,9 @@ export default Ember.Component.extend({
|
|||
@on('didInsertElement')
|
||||
_composerEditorInit() {
|
||||
const topicId = this.get('topic.id');
|
||||
const template = Discourse.RAW_TEMPLATES['user-selector-autocomplete'];
|
||||
const $input = this.$('.d-editor-input');
|
||||
$input.autocomplete({
|
||||
template,
|
||||
template: findRawTemplate('user-selector-autocomplete'),
|
||||
dataSource: term => userSearch({ term, topicId, includeGroups: true }),
|
||||
key: "@",
|
||||
transformComplete: v => v.username || v.name
|
||||
|
|
|
@ -11,6 +11,7 @@ import { translations } from 'pretty-text/emoji/data';
|
|||
import { emojiSearch } from 'pretty-text/emoji';
|
||||
import { emojiUrlFor } from 'discourse/lib/text';
|
||||
import { getRegister } from 'discourse-common/lib/get-owner';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
import deprecated from 'discourse-common/lib/deprecated';
|
||||
|
||||
// Our head can be a static string or a function that returns a string
|
||||
|
@ -297,11 +298,10 @@ export default Ember.Component.extend({
|
|||
},
|
||||
|
||||
_applyCategoryHashtagAutocomplete() {
|
||||
const template = Discourse.RAW_TEMPLATES['category-tag-autocomplete'];
|
||||
const siteSettings = this.siteSettings;
|
||||
|
||||
this.$('.d-editor-input').autocomplete({
|
||||
template: template,
|
||||
template: findRawTemplate('category-tag-autocomplete'),
|
||||
key: '#',
|
||||
transformComplete(obj) {
|
||||
if (obj.model) {
|
||||
|
@ -323,11 +323,10 @@ export default Ember.Component.extend({
|
|||
if (!this.siteSettings.enable_emoji) { return; }
|
||||
|
||||
const register = this.register;
|
||||
const template = Discourse.RAW_TEMPLATES['emoji-selector-autocomplete'];
|
||||
const self = this;
|
||||
|
||||
$editorInput.autocomplete({
|
||||
template: template,
|
||||
template: findRawTemplate('emoji-selector-autocomplete'),
|
||||
key: ":",
|
||||
afterComplete(text) {
|
||||
self.set('value', text);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
@computed('placeholderKey')
|
||||
placeholder(placeholderKey) {
|
||||
|
@ -17,7 +19,6 @@ export default Ember.Component.extend({
|
|||
var selectedGroups;
|
||||
var groupNames = this.get('groupNames');
|
||||
|
||||
var template = Discourse.RAW_TEMPLATES['group-selector-autocomplete'];
|
||||
self.$('input').autocomplete({
|
||||
allowAny: false,
|
||||
items: _.isArray(groupNames) ? groupNames : (Ember.isEmpty(groupNames)) ? [] : [groupNames],
|
||||
|
@ -42,7 +43,7 @@ export default Ember.Component.extend({
|
|||
});
|
||||
});
|
||||
},
|
||||
template: template
|
||||
template: findRawTemplate('group-selector-autocomplete')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { bufferedRender } from 'discourse-common/lib/buffered-render';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
|
||||
export function showEntrance(e) {
|
||||
let target = $(e.target);
|
||||
|
||||
|
@ -30,7 +32,7 @@ export default Ember.Component.extend(bufferedRender({
|
|||
},
|
||||
|
||||
buildBuffer(buffer) {
|
||||
const template = Discourse.RAW_TEMPLATES['list/topic-list-item'];
|
||||
const template = findRawTemplate('list/topic-list-item');
|
||||
if (template) {
|
||||
buffer.push(template(this));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||
import TextField from 'discourse/components/text-field';
|
||||
import userSearch from 'discourse/lib/user-search';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
|
||||
export default TextField.extend({
|
||||
@observes('usernames')
|
||||
_update() {
|
||||
|
@ -29,7 +31,7 @@ export default TextField.extend({
|
|||
}
|
||||
|
||||
this.$().val(this.get('usernames')).autocomplete({
|
||||
template: Discourse.RAW_TEMPLATES['user-selector-autocomplete'],
|
||||
template: findRawTemplate('user-selector-autocomplete'),
|
||||
disabled: this.get('disabled'),
|
||||
single: this.get('single'),
|
||||
allowAny: this.get('allowAny'),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { registerUnbound } from 'discourse-common/lib/helpers';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
|
||||
let _injections;
|
||||
|
||||
|
@ -33,7 +34,7 @@ registerUnbound('raw', function(templateName, params) {
|
|||
templateName = templateName.replace('.', '/');
|
||||
|
||||
const container = Discourse.__container__;
|
||||
const template = Discourse.RAW_TEMPLATES[templateName];
|
||||
const template = findRawTemplate(templateName);
|
||||
if (!template) {
|
||||
console.warn('Could not find raw template: ' + templateName);
|
||||
return;
|
||||
|
|
|
@ -2,6 +2,7 @@ import groups from 'discourse/lib/emoji/groups';
|
|||
import KeyValueStore from "discourse/lib/key-value-store";
|
||||
import { emojiList } from 'pretty-text/emoji';
|
||||
import { emojiUrlFor } from 'discourse/lib/text';
|
||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||
|
||||
const keyValueStore = new KeyValueStore("discourse_emojis_");
|
||||
const EMOJI_USAGE = "emojiUsage";
|
||||
|
@ -151,7 +152,7 @@ function render(page, offset, options) {
|
|||
};
|
||||
|
||||
$('.emoji-modal', options.appendTo).remove();
|
||||
const template = Discourse.RAW_TEMPLATES['emoji-toolbar'];
|
||||
const template = findRawTemplate('emoji-toolbar');
|
||||
options.appendTo.append(template(model));
|
||||
|
||||
bindEvents(page, offset, options);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import { getResolverOption } from 'discourse-common/resolver';
|
||||
|
||||
export function findRawTemplate(name) {
|
||||
if (getResolverOption('mobileView')) {
|
||||
return Discourse.RAW_TEMPLATES[`mobile/${name}`] ||
|
||||
Discourse.RAW_TEMPLATES[name];
|
||||
}
|
||||
|
||||
return Discourse.RAW_TEMPLATES[name];
|
||||
}
|
Loading…
Reference in New Issue