0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 10:40:28 +01:00
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/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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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