FEATURE: Multiple embeddable hosts

- Also refactors two site settings components into one, with tests
This commit is contained in:
Robin Ward
2015-06-09 12:19:41 -04:00
parent 71ee84f848
commit 7b6d6b76eb
35 changed files with 183 additions and 102 deletions
@@ -2,7 +2,7 @@ import BufferedContent from 'discourse/mixins/buffered-content';
import ScrollTop from 'discourse/mixins/scroll-top';
import SiteSetting from 'admin/models/site-setting';
const CustomTypes = ['bool', 'enum', 'list', 'url_list'];
const CustomTypes = ['bool', 'enum', 'list', 'url_list', 'host_list'];
export default Ember.Component.extend(BufferedContent, ScrollTop, {
classNameBindings: [':row', ':setting', 'setting.overridden', 'typeClass'],
@@ -1,32 +0,0 @@
export default Ember.Component.extend({
_setupUrls: function() {
const value = this.get('value');
this.set('urls', (value && value.length) ? value.split("\n") : []);
}.on('init').observes('value'),
_urlsChanged: function() {
this.set('value', this.get('urls').join("\n"));
}.observes('urls.@each'),
urlInvalid: Ember.computed.empty('newUrl'),
keyDown(e) {
if (e.keyCode === 13) {
this.send('addUrl');
}
},
actions: {
addUrl() {
if (this.get('urlInvalid')) { return; }
this.get('urls').addObject(this.get('newUrl'));
this.set('newUrl', '');
},
removeUrl(url) {
const urls = this.get('urls');
urls.removeObject(url);
}
}
});
@@ -0,0 +1,34 @@
export default Ember.Component.extend({
classNameBindings: [':value-list'],
_setupCollection: function() {
const values = this.get('values');
this.set('collection', (values && values.length) ? values.split("\n") : []);
}.on('init').observes('values'),
_collectionChanged: function() {
this.set('values', this.get('collection').join("\n"));
}.observes('collection.@each'),
inputInvalid: Ember.computed.empty('newValue'),
keyDown(e) {
if (e.keyCode === 13) {
this.send('addValue');
}
},
actions: {
addValue() {
if (this.get('inputInvalid')) { return; }
this.get('collection').addObject(this.get('newValue'));
this.set('newValue', '');
},
removeValue(value) {
const collection = this.get('collection');
collection.removeObject(value);
}
}
});