From 2766e2d60f49cd58868fa0c54983928f7f0945d7 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 23 Dec 2012 15:59:01 -0800 Subject: [PATCH] newui: kinda wiring up the create button Change-Id: Ib114da06c89543fda71104eef49433c100f60112 --- .../camlistored/newui/blob_item_container.js | 19 ++++++++++++++++--- server/camlistored/newui/index.js | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/server/camlistored/newui/blob_item_container.js b/server/camlistored/newui/blob_item_container.js index 44b9bf5ff..e3d40ad3d 100644 --- a/server/camlistored/newui/blob_item_container.js +++ b/server/camlistored/newui/blob_item_container.js @@ -12,7 +12,7 @@ goog.require('goog.events.EventHandler'); goog.require('goog.events.EventType'); goog.require('goog.ui.Container'); goog.require('camlistore.BlobItem'); - +goog.require('camlistore.CreateItem'); /** @@ -41,6 +41,13 @@ camlistore.BlobItemContainer = function(connection, opt_domHelper) { goog.inherits(camlistore.BlobItemContainer, goog.ui.Container); +camlistore.BlobItemContainer.prototype.hasCreateItem_ = false; + +camlistore.BlobItemContainer.prototype.setHasCreateItem = function(v) { + this.hasCreateItem_ = v; +}; + + /** * @enum {string} */ @@ -82,6 +89,7 @@ camlistore.BlobItemContainer.prototype.disposeInternal = function() { camlistore.BlobItemContainer.prototype.enterDocument = function() { camlistore.BlobItemContainer.superClass_.enterDocument.call(this); + this.resetChildren_(); this.eh_.listen( this, camlistore.BlobItemContainer.EventType.SHOW_RECENT, this.showRecent_); @@ -107,13 +115,18 @@ camlistore.BlobItemContainer.prototype.showRecent_ = function() { 100); // TODO(bslatkin): Use instance variable for thumbnail size }; +camlistore.BlobItemContainer.prototype.resetChildren_ = function(result) { + this.removeChildren(true); + if (this.hasCreateItem_) { + this.addChild(new camlistore.CreateItem(), true); + } +} /** * @param {Object} result JSON response to this request. */ camlistore.BlobItemContainer.prototype.showRecentDone_ = function(result) { - this.removeChildren(true); - + this.resetChildren_(); for (var i = 0, n = result.recent.length; i < n; i++) { var blobRef = result.recent[i].blobref; var item = new camlistore.BlobItem(blobRef, result); diff --git a/server/camlistored/newui/index.js b/server/camlistored/newui/index.js index de5c81a3e..57256df20 100644 --- a/server/camlistored/newui/index.js +++ b/server/camlistored/newui/index.js @@ -43,6 +43,7 @@ camlistore.IndexPage = function(config, opt_domHelper) { */ this.blobItemContainer_ = new camlistore.BlobItemContainer( this.connection_); + this.blobItemContainer_.setHasCreateItem(true); /** * @type {goog.events.EventHandler}