1
0
Fork 0
Dieser Commit ist enthalten in:
Angus McLeod 2020-07-02 15:25:17 +10:00
Ursprung fb06c0def2
Commit 1f7f17ee30
5 geänderte Dateien mit 20 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -96,6 +96,7 @@
//= require discourse/app/templates/components/conditional-loading-spinner //= require discourse/app/templates/components/conditional-loading-spinner
//= require discourse/app/templates/components/d-button //= require discourse/app/templates/components/d-button
//= require discourse/app/templates/components/d-editor //= require discourse/app/templates/components/d-editor
//= require discourse/app/templates/components/date-picker
//= require discourse/app/templates/components/emoji-picker //= require discourse/app/templates/components/emoji-picker
//= require discourse/app/templates/components/popup-input-tip //= require discourse/app/templates/components/popup-input-tip
//= require discourse/app/templates/category-tag-autocomplete //= require discourse/app/templates/category-tag-autocomplete

Datei anzeigen

@ -0,0 +1,4 @@
{{date-picker
value=field.value
id=field.id
}}

Datei anzeigen

@ -163,6 +163,7 @@ en:
category: Category category: Category
group: Group group: Group
user_selector: User Selector user_selector: User Selector
date: Date
connector: connector:
and: "and" and: "and"

Datei anzeigen

@ -327,6 +327,10 @@ class CustomWizard::Builder
updater.errors.add(id, I18n.t('wizard.field.invalid_file', label: label, types: file_types)) updater.errors.add(id, I18n.t('wizard.field.invalid_file', label: label, types: file_types))
end end
if type === 'date' && value.present? && !validate_date(value)
updater.errors.add(id, I18n.t('wizard.field.invalid_date'))
end
CustomWizard::Builder.field_validators.each do |validator| CustomWizard::Builder.field_validators.each do |validator|
if type === validator[:type] if type === validator[:type]
validator[:block].call(field, updater, step_template) validator[:block].call(field, updater, step_template)
@ -340,6 +344,15 @@ class CustomWizard::Builder
.include?(File.extname(value['original_filename'])[1..-1]) .include?(File.extname(value['original_filename'])[1..-1])
end end
def validate_date(value)
begin
Date.parse(value)
true
rescue ArgumentError
false
end
end
def is_text_type(field) def is_text_type(field)
['text', 'textarea'].include? field['type'] ['text', 'textarea'].include? field['type']
end end

Datei anzeigen

@ -11,6 +11,7 @@ class CustomWizard::Field
min_length: nil min_length: nil
}, },
text_only: {}, text_only: {},
date: {},
number: {}, number: {},
checkbox: {}, checkbox: {},
url: { url: {