Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-10 04:12:53 +01:00
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"
|
||||
|
|
|
@ -327,6 +327,10 @@ class CustomWizard::Builder
|
|||
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]
|
||||
validator[:block].call(field, updater, step_template)
|
||||
|
@ -340,6 +344,15 @@ class CustomWizard::Builder
|
|||
.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']
|
||||
end
|
||||
|
|
|
@ -11,6 +11,7 @@ class CustomWizard::Field
|
|||
min_length: nil
|
||||
},
|
||||
text_only: {},
|
||||
date: {},
|
||||
number: {},
|
||||
checkbox: {},
|
||||
url: {
|
||||
|
|
Laden …
In neuem Issue referenzieren