Add date field
Dieser Commit ist enthalten in:
Ursprung
fb06c0def2
Commit
1f7f17ee30
5 geänderte Dateien mit 20 neuen und 0 gelöschten Zeilen
|
@ -96,6 +96,7 @@
|
|||
//= require discourse/app/templates/components/conditional-loading-spinner
|
||||
//= require discourse/app/templates/components/d-button
|
||||
//= 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/popup-input-tip
|
||||
//= require discourse/app/templates/category-tag-autocomplete
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{{date-picker
|
||||
value=field.value
|
||||
id=field.id
|
||||
}}
|
|
@ -163,6 +163,7 @@ en:
|
|||
category: Category
|
||||
group: Group
|
||||
user_selector: User Selector
|
||||
date: Date
|
||||
|
||||
connector:
|
||||
and: "and"
|
||||
|
|
|
@ -326,6 +326,10 @@ class CustomWizard::Builder
|
|||
if type === 'upload' && value.present? && !validate_file_type(value, file_types)
|
||||
updater.errors.add(id, I18n.t('wizard.field.invalid_file', label: label, types: file_types))
|
||||
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|
|
||||
if type === validator[:type]
|
||||
|
@ -339,6 +343,15 @@ class CustomWizard::Builder
|
|||
.map { |t| t.gsub('.', '') }
|
||||
.include?(File.extname(value['original_filename'])[1..-1])
|
||||
end
|
||||
|
||||
def validate_date(value)
|
||||
begin
|
||||
Date.parse(value)
|
||||
true
|
||||
rescue ArgumentError
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def is_text_type(field)
|
||||
['text', 'textarea'].include? field['type']
|
||||
|
|
|
@ -11,6 +11,7 @@ class CustomWizard::Field
|
|||
min_length: nil
|
||||
},
|
||||
text_only: {},
|
||||
date: {},
|
||||
number: {},
|
||||
checkbox: {},
|
||||
url: {
|
||||
|
|
Laden …
In neuem Issue referenzieren