0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00

Fix: new items may not have type on creation

Dieser Commit ist enthalten in:
Angus McLeod 2020-04-21 07:21:44 +10:00
Ursprung de8b4f9b2e
Commit b74a46a89f

Datei anzeigen

@ -197,7 +197,6 @@ if (Discourse.SiteSettings.wizard_apis_enabled) {
export function setWizardDefaults(obj, itemType, opts={}) { export function setWizardDefaults(obj, itemType, opts={}) {
const objSchema = wizardSchema[itemType]; const objSchema = wizardSchema[itemType];
const basicDefaults = objSchema.basic; const basicDefaults = objSchema.basic;
const typeDefaults = objSchema.types[obj.type];
Object.keys(basicDefaults).forEach(property => { Object.keys(basicDefaults).forEach(property => {
let defaultValue = get(basicDefaults, property); let defaultValue = get(basicDefaults, property);
@ -206,6 +205,9 @@ export function setWizardDefaults(obj, itemType, opts={}) {
} }
}); });
if (objSchema.types) {
const typeDefaults = objSchema.types[obj.type];
if (typeDefaults) { if (typeDefaults) {
Object.keys(typeDefaults).forEach(property => { Object.keys(typeDefaults).forEach(property => {
if (typeDefaults.hasOwnProperty(property)) { if (typeDefaults.hasOwnProperty(property)) {
@ -213,6 +215,7 @@ export function setWizardDefaults(obj, itemType, opts={}) {
} }
}); });
} }
}
return obj; return obj;
} }