Merge "Render containers with the camliContentImage attr as folders for now."

This commit is contained in:
Aaron Boodman 2014-08-01 18:54:59 +00:00 committed by Gerrit Code Review
commit 6c78cb5c22
4 changed files with 22 additions and 8 deletions

View File

@ -103,6 +103,7 @@ cam.BlobItemGenericContent.Handler.prototype.getAspectRatio = function() {
}; };
cam.BlobItemGenericContent.Handler.prototype.createContent = function(size) { cam.BlobItemGenericContent.Handler.prototype.createContent = function(size) {
// TODO(aa): In the case of a permanode that is a container (cam.permanodeUtils.isContainer()) and has a camliContentImage, it would be nice to show that image somehow along with the folder icon.
return cam.BlobItemGenericContent({ return cam.BlobItemGenericContent({
href: this.href_, href: this.href_,
size: size, size: size,
@ -127,6 +128,7 @@ cam.BlobItemGenericContent.Handler.prototype.getThumbType_ = function() {
} }
// Using the directory icon for any random permanode is a bit weird. Ideally we'd use file for that. The problem is that we can't tell the difference between a permanode that is representing an empty dynamic set and a permanode that is representing something else entirely. // Using the directory icon for any random permanode is a bit weird. Ideally we'd use file for that. The problem is that we can't tell the difference between a permanode that is representing an empty dynamic set and a permanode that is representing something else entirely.
// And unfortunately, the UI has a big prominent button that says 'new set', and it looks funny if the new set is shown as a file icon :(
if (m.camliType == 'permanode') { if (m.camliType == 'permanode') {
return 'folder'; return 'folder';
} }

View File

@ -19,6 +19,7 @@ goog.provide('cam.BlobItemImageContent');
goog.require('goog.math.Size'); goog.require('goog.math.Size');
goog.require('cam.math'); goog.require('cam.math');
goog.require('cam.permanodeUtils');
goog.require('cam.PyramidThrobber'); goog.require('cam.PyramidThrobber');
goog.require('cam.Thumber'); goog.require('cam.Thumber');
@ -110,13 +111,20 @@ cam.BlobItemImageContent.getHandler = function(blobref, searchSession, href) {
} }
var m = searchSession.getMeta(blobref); var m = searchSession.getMeta(blobref);
if (m.camliType == 'permanode') { if (m.camliType != 'permanode') {
var cci = cam.permanodeUtils.getSingleAttr(m.permanode, 'camliContentImage'); return null;
if (cci) { }
var ccim = searchSession.getResolvedMeta(cci);
if (ccim) { // Sets can have the camliContentImage attr to indicate a user-chosen "cover image" for the entire set. Until we have some rendering for those, the folder in the generic handler is a better fit than the single image.
return new cam.BlobItemImageContent.Handler(ccim, href, searchSession.getTitle(blobref)); if (cam.permanodeUtils.isContainer(m.permanode)) {
} return null;
}
var cci = cam.permanodeUtils.getSingleAttr(m.permanode, 'camliContentImage');
if (cci) {
var ccim = searchSession.getResolvedMeta(cci);
if (ccim) {
return new cam.BlobItemImageContent.Handler(ccim, href, searchSession.getTitle(blobref));
} }
} }

View File

@ -27,7 +27,7 @@ cam.ContainerDetail.getAspect = function(detailURL, handlers, history, getSearch
} }
// TODO(aa): Also handle directories and static sets. // TODO(aa): Also handle directories and static sets.
if (!goog.object.some(m.permanode.attr, function(v, k) { return k == 'camliMember' || goog.string.startsWith(k, 'camliPath:'); })) { if (!cam.permanodeUtils.isContainer(m.permanode)) {
return null; return null;
} }

View File

@ -25,3 +25,7 @@ cam.permanodeUtils.getSingleAttr = function(permanode, name) {
} }
return null; return null;
}; };
cam.permanodeUtils.isContainer = function(permanode) {
return goog.object.some(permanode.attr, function(v, k) { return k == 'camliMember' || goog.string.startsWith(k, 'camliPath:'); });
};