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/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
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{date-picker
|
||||||
|
value=field.value
|
||||||
|
id=field.id
|
||||||
|
}}
|
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -11,6 +11,7 @@ class CustomWizard::Field
|
||||||
min_length: nil
|
min_length: nil
|
||||||
},
|
},
|
||||||
text_only: {},
|
text_only: {},
|
||||||
|
date: {},
|
||||||
number: {},
|
number: {},
|
||||||
checkbox: {},
|
checkbox: {},
|
||||||
url: {
|
url: {
|
||||||
|
|
Laden …
In neuem Issue referenzieren