-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 7 commits
4b33116
0af5194
fb31334
f106c48
c27070d
e900204
8a903a4
343f10f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
module AdditionalDetails::ApplicationHelper | ||
|
||
def convert_time(time) | ||
modifier = '' | ||
((time.first == '0') || (time[0..1] == '10') || (time[0..1] == '11')) ? modifier = ' AM' : modifier = ' PM' | ||
|
||
DateTime.strptime(time.gsub(':', ''), '%H%M').strftime('%l:%M') + modifier | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(/["\[\]]/, '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. |
||
- else | ||
= qr.content | ||
- unless item == @items.last | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a placeholder for AM/PM in DateTime.strptime. %p should do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kind of like my modifier code, so I think I'm going to leave it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what the modifier is doing? I'm a bit confused about the '0' || '10' || '11' part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's converting military time to regular time. So if a time string has either '0', '10', or '11' as the leading characters then it is in the morning. All else are PM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use
DateTime.strptime(time, '%H:%M').strftime('%l:%M %p')
to do the same thing all in 1 lineThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally missed this comment last week. Your suggestion worked great, should be up there now.