Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-09 20:02:54 +01:00
bugfix
Dieser Commit ist enthalten in:
Ursprung
949b28cecb
Commit
3066c22367
1 geänderte Dateien mit 19 neuen und 16 gelöschten Zeilen
|
@ -3,27 +3,30 @@ import Category from 'discourse/models/category';
|
|||
|
||||
export default Ember.Component.extend({
|
||||
didInsertElement() {
|
||||
const value = this.get('field.value');
|
||||
const property = this.field.property || 'id';
|
||||
const value = this.field.value;
|
||||
|
||||
if (value) {
|
||||
const property = this.get('field.property') || 'id';
|
||||
const categories = [...value].map(v => {
|
||||
return property === 'id' ?
|
||||
Category.findById(v) :
|
||||
Category.findBySlug(v);
|
||||
});
|
||||
this.set('categories', categories);
|
||||
this.set('categories', [...value].reduce((result, v) => {
|
||||
let val = property === 'id' ? Category.findById(v) : Category.findBySlug(v);
|
||||
if (val) result.push(val);
|
||||
return result;
|
||||
}, []));
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@observes('categories')
|
||||
setValue() {
|
||||
const categories = this.get('categories');
|
||||
if (categories.length) {
|
||||
const property = this.get('field.property') || 'id';
|
||||
let value = categories.length === 1 ?
|
||||
categories[0][property] :
|
||||
categories.map(c => c[property]);
|
||||
this.set('field.value', value);
|
||||
const categories = (this.categories || []).filter(c => !!c);
|
||||
const property = this.field.property || 'id';
|
||||
|
||||
if (categories.length) {
|
||||
this.set('field.value', categories.reduce((result, c) => {
|
||||
if (c && c[property]) {
|
||||
result.push(c[property])
|
||||
}
|
||||
return result;
|
||||
}, []));
|
||||
}
|
||||
}
|
||||
});
|
Laden …
In neuem Issue referenzieren