Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jl form functionality cleanup #157

Merged
merged 8 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/helpers/additional_details/application_helper.rb
@@ -1,2 +1,6 @@
module AdditionalDetails::ApplicationHelper

def convert_time(time)
DateTime.strptime(time, '%H:%M').strftime('%l:%M %p')
end
end
Expand Up @@ -9,6 +9,10 @@
%p.list-group-item-text
- if item.item_type == 'multiple_dropdown'
= qr.content.delete('[]').delete('\"')
- elsif item.item_type == 'time'
= convert_time(qr.content)
- elsif item.item_type == 'checkbox'
= qr.content.gsub(/["\[\]]/, '')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested qr.content.delete('[]').delete('\"') and qr.content.gsub(/["\[\]]/, '') and they appear to be doing the same thing: Replacing/removing the characters []". We should combine this block and the if block into a single statement.
if ['checkbox', 'multiple_dropdown'].include?(item.item_type)
qr.content.delete('[]\"') or qr.content.gsub(/["\[\]]/, '')

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would label that a refactor and make another pull request. Not necessary to proceed. In the same thought you could change 'qr.content.gsub' to another method call similar to convert_time.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

- else
= qr.content
- unless item == @items.last
Expand Down
@@ -1,5 +1,5 @@
%br
- item.item_options.each do |item_option|
= qr.label :content, class: 'checkbox-inline' do
= qr.check_box :content, {}, item_option.content, nil
= qr.check_box :content, { multiple: true, checked: (qr.object.content.include?(item_option.content) unless qr.object.content.nil?)}, item_option.content, nil
= item_option.content
1 change: 1 addition & 0 deletions config/constants.yml
Expand Up @@ -840,6 +840,7 @@ additional_detail_question_types: {
'Text': 'text',
'Text Area': 'textarea',
'Radio Button': 'radio_button',
'Checkbox': 'checkbox',
'Yes/No': 'yes_no',
'Email': 'email',
'Date': 'date',
Expand Down