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