Add last_modified evaluation for PIO import

This commit is contained in:
Jure Grabnar 2018-11-23 17:51:47 +01:00
parent 87d5e5029a
commit 2c8a7f8eca
2 changed files with 8 additions and 1 deletions

View file

@ -155,6 +155,13 @@ module ProtocolsIoHelper
text.map { |auth| auth['name'] }.join(', ')
end
def eval_last_modified(steps)
timestamps = steps.map do |step|
step['modified_on'] if step['modified_on'].present?
end
Time.at(timestamps.max).utc.to_datetime
end
# Checks so that null values are returned as zero length strings
# Did this so views arent as ugly (i avoid using if present statements)
def not_null(attribute)

View file

@ -59,7 +59,7 @@
<div class="col-xs-4">
<label><%= t('protocols.import_export.import_modal.updated_at_label') %></label>
<% display_last_modified=Time.at(not_null(@json_object['last_modified']).to_i) %>
<% display_last_modified=eval_last_modified(@json_object['steps']) %>
<%= f.text_field :last_modified, :value =>
display_last_modified.to_s,readonly: true, class:
"form-control" %>