1
0
Fork 0

Improve checks and edge cases

Dieser Commit ist enthalten in:
Angus McLeod 2017-11-23 17:02:25 +08:00
Ursprung c9b8403569
Commit 37b1b73f90
4 geänderte Dateien mit 16 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -86,6 +86,12 @@ const CustomWizard = Discourse.Model.extend({
error = 'id_required'; error = 'id_required';
return; return;
} }
if (!f.type) {
error = 'type_required';
return;
}
f.set('id', id.underscore()); f.set('id', id.underscore());
if (f.label === '') delete f.label; if (f.label === '') delete f.label;
@ -97,6 +103,8 @@ const CustomWizard = Discourse.Model.extend({
error = 'field.need_choices'; error = 'field.need_choices';
return; return;
} }
if (f.dropdown_none === '') delete f.dropdown_none;
} }
delete f.isNew; delete f.isNew;

Datei anzeigen

@ -39,7 +39,7 @@
<h3>{{i18n 'admin.wizard.type'}}</h3> <h3>{{i18n 'admin.wizard.type'}}</h3>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{combo-box value=field.type content=types}} {{combo-box value=field.type content=types none="admin.wizard.field.type"}}
</div> </div>
</div> </div>

Datei anzeigen

@ -50,6 +50,7 @@ en:
name_required: "Wizards must have a name." name_required: "Wizards must have a name."
steps_required: "Wizards must have at least one step." steps_required: "Wizards must have at least one step."
id_required: "All wizards, steps, fields and actions need an id." id_required: "All wizards, steps, fields and actions need an id."
type_required: "All fields need a type."
after_time_need_time: "After time is enabled but no time is set." after_time_need_time: "After time is enabled but no time is set."
after_time_invalid: "After time is invalid." after_time_invalid: "After time is invalid."
field: field:
@ -62,6 +63,7 @@ en:
banner_placeholder: "Image url" banner_placeholder: "Image url"
description: "Description" description: "Description"
field: field:
type: "Choose a type"
header: "Fields" header: "Fields"
label: "Label" label: "Label"
description: "Description" description: "Description"

Datei anzeigen

@ -53,6 +53,11 @@ class CustomWizard::AdminController < ::ApplicationController
break break
end end
if f["type"].blank?
error = 'type_required'
break
end
if f["type"] === 'dropdown' if f["type"] === 'dropdown'
choices = f["choices"] choices = f["choices"]
if (!choices || choices.length < 1) && !f["choices_key"] && !f["choices_preset"] if (!choices || choices.length < 1) && !f["choices_key"] && !f["choices_preset"]