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

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';
return;
}
if (!f.type) {
error = 'type_required';
return;
}
f.set('id', id.underscore());
if (f.label === '') delete f.label;
@ -97,6 +103,8 @@ const CustomWizard = Discourse.Model.extend({
error = 'field.need_choices';
return;
}
if (f.dropdown_none === '') delete f.dropdown_none;
}
delete f.isNew;

Datei anzeigen

@ -39,7 +39,7 @@
<h3>{{i18n 'admin.wizard.type'}}</h3>
</div>
<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>

Datei anzeigen

@ -50,6 +50,7 @@ en:
name_required: "Wizards must have a name."
steps_required: "Wizards must have at least one step."
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_invalid: "After time is invalid."
field:
@ -62,6 +63,7 @@ en:
banner_placeholder: "Image url"
description: "Description"
field:
type: "Choose a type"
header: "Fields"
label: "Label"
description: "Description"

Datei anzeigen

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