Skip to content

Commit

Permalink
Fix the "Details" links in the download contents table in the
Browse files Browse the repository at this point in the history
MetadataView. The links were:

* inserted in multiple places in the DOM
* broken/unnecessary when the metadata does not have "Other Entity"
details
  • Loading branch information
laurenwalker committed Sep 11, 2014
1 parent 28e1a4c commit b2da660
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
11 changes: 7 additions & 4 deletions metacatui/src/main/webapp/js/templates/downloadContents.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@
readCount = object.read_count_i + " downloads";
}
formatType = '<i class="icon-table"></i>' + formatType;
moreInfo = '<a href="#' + object.id + '">Details <i class="icon-info-sign"></i></a>';
if(_.indexOf(dataWithDetailsOnPage, object.id) > -1)
moreInfo = '<a href="#' + object.id + '">Details <i class="icon-info-sign"></i></a>';
else
moreInfo = null;
}


Expand All @@ -128,10 +131,10 @@
print('<td class="id">' + id + '</td>');
print('<td class="file-type">' + fileType + '</td>');
print('<td class="size">' + size + '</td>');
if(readCount.length > 0){
if(readCount.length > 0)
print('<td class="readCount">' + readCount + '</td>');
}
print('<td class="more-info">' + moreInfo + '</td>');
if(moreInfo)
print('<td class="more-info">' + moreInfo + '</td>');
print('</tr>');

});
Expand Down
29 changes: 21 additions & 8 deletions metacatui/src/main/webapp/js/views/MetadataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ define(['jquery',
viewRef.insertVisuals(images, "image");
viewRef.insertVisuals(pdfs, "pdf");

//Replace Ecogrid Links with DataONE API links
viewRef.replaceEcoGridLinks(pids);

//Now go through all of our objects and add them to our map
_.each(objects, function(object){
Expand All @@ -228,15 +226,27 @@ define(['jquery',
//For each resource map package, add a table of its contents to the page
var count = 0;
_.each(maps, function(thisMap){
var dataWithDetailsOnPage = [];
//If a data object in this package is mentioned in the metadata, insert a link to its details
_.each(packages[thisMap.id], function(object){
if(viewRef.$el.find(":contains(" + object.id + ")").length){
dataWithDetailsOnPage.push(object.id);
}
});

$('#downloadContents').append(viewRef.downloadContentsTemplate({
objects: packages[thisMap.id],
resourceMap: thisMap,
package_service: packageServiceUrl,
object_service: objectServiceUrl,
EMLRoute: EMLRoute
}));
EMLRoute: EMLRoute,
dataWithDetailsOnPage: dataWithDetailsOnPage
}));
});

//Replace Ecogrid Links with DataONE API links
viewRef.replaceEcoGridLinks(pids);

//Move the download button to our download content list area
$("#downloadPackage").detach();

Expand Down Expand Up @@ -283,7 +293,6 @@ define(['jquery',
var labelEl = $(parentEl).find('label:contains("' + direction + '")');
if(labelEl){
var coordinate = $(labelEl).next().html();
console.log('coordinate: ' + coordinate);
coordinate = coordinate.substring(0, coordinate.indexOf("&nbsp;"));
coordinates.push(coordinate);
}
Expand Down Expand Up @@ -678,9 +687,13 @@ define(['jquery',
$(thisLink).attr('href', appModel.get('objectServiceUrl') + encodeURIComponent(pids[i]));
$(thisLink).text(pids[i]);

//Insert an anchor near this spot in the DOM
$(thisLink).parents().find('.dataTableContainer').prepend('<a name="' + pids[i] + '"></a>');

//Insert an anchor at the parent element that contains the data object detials
var parents = $(thisLink).parents();
_.each(parents, function(parent){
if($(parent).hasClass("dataTableContainer"))
$(parent).prepend('<a name="' + pids[i] + '"></a>');
});

//We can stop looking at the pids now
i = pids.length;
}
Expand Down

0 comments on commit b2da660

Please sign in to comment.