Angus McLeod 7 лет назад
Родитель
Сommit
37b1b73f90

+ 8 - 0
assets/javascripts/discourse/models/custom-wizard.js.es6

@@ -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;

+ 1 - 1
assets/javascripts/discourse/templates/components/wizard-custom-field.hbs

@@ -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>
 

+ 2 - 0
config/locales/client.en.yml

@@ -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"

+ 5 - 0
controllers/admin.rb

@@ -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"]