Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
986e271
MMT-2313: Added loss reporting route, added a display action to the c…
Jul 10, 2020
57b82a3
MMT-2313: added nokogiri/diff to gemfile, added hidden url endpoint f…
Jul 13, 2020
49c7dd9
MMT-2313: added loss reporting for arrays
Jul 13, 2020
67676fc
MMT-2313: Added comment to collections_controller
Jul 13, 2020
d767d9f
MMT-2313: made changes as per MMT-2311-1 PR change requests
Jul 14, 2020
83f5057
MMT-2313: Updated comparison logic to use nokogiri for array paths
Jul 15, 2020
affd9ab
MMT-2313: removed some comments and test code
Jul 15, 2020
7cae6d6
MMT-2313: Added custom function for hash mapping, finds the path for …
Jul 16, 2020
e23bb6a
MMT-2313: adjusted whitespace
Jul 16, 2020
50c0c0f
MMT-2313: added some comments
Jul 17, 2020
748631e
MMT-2313: increased readability of loss_report_output
Jul 20, 2020
d6d5077
MMT-2313: improved readability
Jul 20, 2020
db730a0
MMT-2313: attempting to fix asterisk problem
Jul 21, 2020
d1854c8
MMT-2313 attempting to fix asterisk problem
Jul 21, 2020
1bc3d15
MMT-2313: fix nokogiri problems
Jul 22, 2020
be69b30
MMT-2313: cleaned up inefficiencies, fixed bugs
Jul 22, 2020
34bb5fe
MMT-2313: fixed bugs, improved accuracy
Jul 24, 2020
a267e4c
MMT-2313: added some test code to be removed later
Jul 27, 2020
937342d
MMT-2313: Added some exception handling
Jul 28, 2020
fa56d22
MMT-2313: created specs and stored some sample reports
Jul 29, 2020
20fd9e2
MMT-2313: moved loss_report_samples_helper.rb and added it to the rai…
Jul 29, 2020
34891ec
MMT-2313: made changes per PR change requests
Jul 31, 2020
758e8fa
MMT-2313: removed unneeded comment
Jul 31, 2020
aa3e768
MMT-2313: removed an unecessary cmr call
Jul 31, 2020
3a7591c
MMT-2346: added loss-report modal
Aug 3, 2020
c5be602
MMT-2346: loss reporting - link and modal options
Aug 3, 2020
91103d3
MMT-2346: MVP modal access to loss report
Aug 5, 2020
a242f66
MMT-2346: completed modal specs
Aug 10, 2020
28c5f34
MMT-2346: adjusted modal styling
Aug 10, 2020
2d4c2aa
MMT-2346: fixed merge conflicts
Aug 12, 2020
afe1331
MMT-2346: fixed another conflict
Aug 12, 2020
d4c872e
MMT-2346: adjusted some styling
Aug 13, 2020
76fb366
MMT-2346: adjusted specs and styling
Aug 13, 2020
3e0c54e
MMT-2346: Fixed affected specs
Aug 13, 2020
bbd315a
MMT-2346: completed PR change requests
Aug 14, 2020
1faafc0
MMT-2346: remove LARC from available context
Aug 17, 2020
365a903
MMT-2346: made specs more readable, improved styling of loss-report-m…
Aug 19, 2020
ce63e8c
MMT-2346: adjusted modal Edit button and coffee script
Aug 20, 2020
c626849
MMT-2346: updated spec to match change requests
Aug 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ gem 'aasm'

gem 'browser'

gem 'nokogiri-diff', '~> 0.2.0' # for comparing xml documents

# collections metadata preview
# run this command to work from a local copy of the gem's repo
# bundle config local.cmr_metadata_preview /path/to/local/git/repository
Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/change_current_provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ $(document).ready ->
overlay: 0.6
closeButton: '.modal-close'

$('a.loss-report').on 'click', (element) ->
$('#loss-report-modal').hide()

# Handle not-current-provider-modal
$('a.not-current-provider').on 'click', (element) ->
provider = $(element.target).data('provider')
Expand Down Expand Up @@ -106,7 +109,7 @@ $(document).ready ->
# Click the link that the user needs
if linkType == 'delete-collection' && $('.collection-granule-count').text() != 'Granules (0)'
$('#display-granules-modal').click()
else
else
$(link)[0].click()

# Change current provider
Expand Down
20 changes: 18 additions & 2 deletions app/assets/stylesheets/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,23 @@
&:hover {
background-color: darken($red, 6%);
}
}
}

.eui-btn--steel-blue {
@extend .eui-btn;

background-color: $steel-blue;
color: $white !important;
padding: 0.5em 1em;

&:hover {
background-color: darken($steel-blue, 6%);
}
}

.button-spacing {
margin-right: 0.625em;
}

button {
&:disabled {
Expand All @@ -36,4 +52,4 @@ button {
background-color: lighten($dolphin-grey, 10%);
}
}
}
}
10 changes: 5 additions & 5 deletions app/assets/stylesheets/components/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
}
}
}
.search-dropdown-short { /* smaller dropdown if radio buttons are hidden in DMMT */
.search-dropdown-short { /* smaller dropdown if radio buttons are hidden in DMMT */
width: 100%;
height: 45px;
}
.search-dropdown-wide { /* wider dropdown if UMM-T is enabled */

.search-dropdown-wide { /* wider dropdown if UMM-T is enabled */
right: 0px; // causes dropdown width to extend to the left
max-width: 440px;
}
Expand All @@ -79,12 +79,12 @@
border-right: 1px solid $dolphin-grey;
border-bottom: 1px solid $steel-blue;
}

#search-submit-button {
text-align: left;
width: 172px; // 11.92em
}

.search-field-wide {
width: 241px;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def loss_report
# When a user wants to use MMT to edit metadata that currently exists in a non-UMM form,
# it's important that they're able to see if any data loss occurs in the translation to umm.
# This method is needed to reference the appropriate helper and view for the lossiness report.
# If translated_collections contains an :error field, the error message will appear.
# If translated_collections contains an :error field, the error message will appear.

# this checks the 'hide_items' url parameter that is can be manually added. Its primary use is for developers
# that need to debug using the text_output
Expand Down
24 changes: 18 additions & 6 deletions app/views/collections/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@
<section class="action wide-content">
<div class="wide-content-inside">
<p>
<% if current_provider?(@provider_id) %>
<%= link_to 'Edit Collection Record', edit_collection_path(revision_id: @revision_id), class: 'eui-btn--link bar-after' %>
<% elsif available_provider?(@provider_id) %>
<%= link_to 'Edit Collection Record', '#not-current-provider-modal', class: 'display-modal not-current-provider eui-btn--link bar-after', data: { provider: @provider_id, record_action: 'edit-collection' } %>
<% native_format = @revisions.first.fetch('meta', {})['format'] %>
<% if !native_format.include?('umm') && (current_provider?(@provider_id) || available_provider?(@provider_id)) %>
<%= link_to 'Edit Collection Record', '#loss-report-modal', class: 'display-modal eui-btn--link bar-after' %>
<% else %>
<% if current_provider?(@provider_id) %>
<%= link_to 'Edit Collection Record', edit_collection_path(revision_id: @revision_id), class: 'eui-btn--link bar-after' %>
<% elsif available_provider?(@provider_id) %>
<%= link_to 'Edit Collection Record', '#not-current-provider-modal', class: 'display-modal not-current-provider eui-btn--link bar-after', data: { provider: @provider_id, record_action: 'edit-collection' } %>
<% end %>
<% end %>

<% if current_provider?(@provider_id) %>
Expand Down Expand Up @@ -112,12 +117,19 @@
draft: @draft,
draft_id: @draft.try(:id) }
} %>
<%= render partial: 'shared/loss_report_modal', locals: {
options: {
provider_id: @provider_id,
native_format: native_format,
concept_id: @concept_id,
revision_id: @revision_id }
} %>
<!-- Hidden link to allow modal to be shown -->
<a href="#granules-modal" id="display-granules-modal" class="display-modal is-invisible"></a>
<div id="granules-modal" class="eui-modal-content">
<a href=<%=current_provider?(@provider_id) ? "javascript:void(0);" : collection_path %> class="modal-close float-r"><i class="fa fa-times"></i><span class="is-invisible">Close</span></a>
<p>This collection has <%= @num_granules %> associated <%= 'granule'.pluralize(@num_granules) %>.</p>
<p id="danger-warning">Deleting this collection will delete all associated granules.</p>
<p>This collection has <%= @num_granules %> associated <%= 'granule'.pluralize(@num_granules) %>.</p>
<p id="danger-warning">Deleting this collection will delete all associated granules.</p>
<p>Please confirm that you wish to continue by entering '<%= CollectionsHelper::DELETE_CONFIRMATION_TEXT %>' below.</p>
<%= form_tag(collection_path, method: :delete, class: 'granules-confirmation-form') do %>
<%= text_field_tag('confirmation-text', nil, class: 'full-width') %>
Expand Down
18 changes: 18 additions & 0 deletions app/views/shared/_loss_report_modal.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div id="loss-report-modal" class="eui-modal-content" >
<a href="javascript:void(0);" class="modal-close float-r" id="close-loss-report-modal"><i class="fa fa-times"></i><span class="is-invisible">Close</span></a>
<div>
<h4>Conversion to UMM Format Required</h4>
<p>The native format of this collection is <%= options[:native_format].split('/').last.gsub('+xml','').upcase %>. Editing this record using the MMT will convert it to UMM-JSON, which may result in data loss. Select 'View Loss Report' to see how the conversion will affect this record.</p>
<p>
<%= link_to 'View Loss Report', loss_report_collections_path(options[:concept_id], format: 'json'), class: 'eui-btn eui-btn--steel-blue', target: :_blank %>

<% if current_provider?(options[:provider_id]) %>
<%= link_to 'Edit Collection', edit_collection_path(revision_id: options[:revision_id]), class: 'eui-btn--blue modal-close button-spacing' %>
<% elsif available_provider?(options[:provider_id]) %>
<%= link_to 'Edit Collection', '#not-current-provider-modal', class: 'eui-btn--blue loss-report button-spacing display-modal not-current-provider', data: { provider: options[:provider_id], record_action: 'edit-collection' } %>
<% end %>

<%= link_to 'Cancel', 'javascript:void(0);', class: 'eui-btn modal-close' %>
</p>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
before do
click_on 'Edit Collection Record'

within '#loss-report-modal' do
click_on 'Edit Collection'
end

within '.metadata' do
click_on 'Spatial Information', match: :first
end
Expand Down
127 changes: 127 additions & 0 deletions spec/features/collections/loss_report_modal_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@

describe 'loss report modal', js: true do
# this is an echo collection (SEDAC provider)
let(:cmr_response) { cmr_client.get_collections({'EntryTitle': 'Anthropogenic Biomes of the World, Version 2: 1700'}) }
let(:concept_id) { cmr_response.body.dig('items',0,'meta','concept-id') }

context 'when user clicks Edit Collection Record for a non-UMM collection' do
context 'when provider context does not need to be changed' do

before do
login(provider: 'SEDAC', providers: %w[SEDAC])
visit collection_path(concept_id)
click_on 'Edit Collection Record'
end

it 'displays the loss-report-modal with correct links' do
within '#loss-report-modal' do
expect(page).to have_content("The native format of this collection is ECHO10. Editing this record using the MMT will convert it to UMM-JSON, which may result in data loss. Select 'View Loss Report' to see how the conversion will affect this record.")
expect(page).to have_link('View Loss Report', href: loss_report_collections_path(concept_id, format: 'json'))
expect(page).to have_link('Edit Collection', href: edit_collection_path(id: concept_id))
expect(page).to have_link('Cancel', href: 'javascript:void(0);')
end
end

context 'when the "Edit Collection" button is clicked' do
before do
within '#loss-report-modal' do
click_on 'Edit Collection'
end
end
it 'opens collection draft without displaying the not-current-provider-modal' do
expect(page).to have_content('Metadata Fields')
expect(page).to have_content('Collection Information')
expect(page).to have_content('Acquisition Information')
expect(page).to have_content('Data Contacts')
expect(page).to have_content('Metadata Information')
expect(page).to have_no_css('#not-current-provider-modal')
end
end

context 'when the "View Loss Report" button is clicked' do
before do
within '#loss-report-modal' do
click_on 'View Loss Report'
end
end
it 'does not close the loss-report-modal and does not open the not-current-provider-modal' do
expect(page).to have_no_css('#not-current-provider-modal')
within '#loss-report-modal' do
expect(page).to have_content("The native format of this collection is ECHO10. Editing this record using the MMT will convert it to UMM-JSON, which may result in data loss. Select 'View Loss Report' to see how the conversion will affect this record.")
end
end
end

context 'when the "Cancel" button is clicked' do
before do
within '#loss-report-modal' do
click_on 'Cancel'
end
end
it 'closes loss-report-modal and does not open the not-current-provider-modal' do
expect(page).to have_no_content('Metadata Preview')
expect(page).to have_link('Edit Collection Record', href: '#loss-report-modal')
expect(page).to have_no_css('#not-current-provider-modal')
expect(page).to have_no_css('#loss-report-modal')
end
end
end

context 'when provider context needs to be changed and the required provider context is available' do

before do
login(provider: 'LARC', providers: %w[SEDAC LARC])
visit collection_path(concept_id)
click_on 'Edit Collection Record'
end

it 'displays the loss-report-modal with correct links' do
within '#loss-report-modal' do
expect(page).to have_content("The native format of this collection is ECHO10. Editing this record using the MMT will convert it to UMM-JSON, which may result in data loss. Select 'View Loss Report' to see how the conversion will affect this record.")
expect(page).to have_link('View Loss Report', href: loss_report_collections_path(concept_id, format: 'json'))
expect(page).to have_link('Edit Collection', href: '#not-current-provider-modal')
expect(page).to have_link('Cancel', href: 'javascript:void(0);')
end
end

context 'when the "Edit Collection" button is clicked' do
before do
within '#loss-report-modal' do
click_on 'Edit Collection'
end
end
it 'closes loss-report-modal and opens the not-current-provider-modal' do
expect(page).to have_no_css('#loss-report-modal')
within '#not-current-provider-modal' do
expect(page).to have_link('Yes', href: '#')
expect(page).to have_link('No', href: 'javascript:void(0)')
end
end
end

context 'when the "View Loss Report" button is clicked' do
before do
within '#loss-report-modal' do
click_on 'View Loss Report'
end
end
it 'does not close the loss-report-modal and does not open the not-current-provider-modal' do
expect(page).to have_content("The native format of this collection is ECHO10. Editing this record using the MMT will convert it to UMM-JSON, which may result in data loss. Select 'View Loss Report' to see how the conversion will affect this record.")
expect(page).to have_no_css('#not-current-provider-modal')
end
end

context 'when the "Cancel" button is clicked' do
before do
within '#loss-report-modal' do
click_on 'Cancel'
end
end
it 'closes loss-report-modal and does not open the not-current-provider-modal' do
expect(page).to have_no_css('#not-current-provider-modal')
expect(page).to have_no_css('#loss-report-modal')
end
end
end
end
end