From 0ef0aec0c57a0ee553e6e6d0df3a3bb2c053c40c Mon Sep 17 00:00:00 2001 From: David Huynh Date: Mon, 8 Mar 2010 19:07:16 +0000 Subject: [PATCH] Implemented list facet choice edit. git-svn-id: http://google-refine.googlecode.com/svn/trunk@238 7d457c2a-affb-35e4-300a-418c747d4874 --- src/main/webapp/scripts/facets/list-facet.js | 114 ++++++++++++++++++- src/main/webapp/styles/project/browsing.css | 14 +++ 2 files changed, 123 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/scripts/facets/list-facet.js b/src/main/webapp/scripts/facets/list-facet.js index 00f49fe45..374e6c193 100644 --- a/src/main/webapp/scripts/facets/list-facet.js +++ b/src/main/webapp/scripts/facets/list-facet.js @@ -133,6 +133,7 @@ ListFacet.prototype.render = function() { ); } + var renderEdit = this._config.expression == "value"; var renderChoice = function(choice, customLabel) { var label = customLabel || choice.v.l; var count = choice.c; @@ -170,11 +171,25 @@ ListFacet.prototype.render = function() { a.click(selectOnly); // include link - $('').addClass("facet-choice-link").text("include").click(select).appendTo(choiceDiv); + $('').addClass("facet-choice-link").text("include").click(select).prependTo(choiceDiv); } else { a.click(select); } + if (renderEdit && customLabel === undefined) { + // edit link + var editLink = $('').addClass("facet-choice-edit").text("edit").click(function() { + self._editChoice(choice, choiceDiv); + }).appendTo(choiceDiv); + + choiceDiv + .mouseenter(function() { + editLink.css("visibility", "visible"); + }) + .mouseleave(function() { + editLink.css("visibility", "hidden"); + }); + } }; var choices = this._data.choices; @@ -208,10 +223,12 @@ ListFacet.prototype.render = function() { }).appendTo(footerDiv); } - $('').html(" • ").appendTo(footerDiv); - $('').addClass("action").text("edit").click(function() { - self._doEdit(); - }).appendTo(footerDiv); + if (this._config.expression == "value") { + $('').html(" • ").appendTo(footerDiv); + $('').addClass("action").text("cluster").click(function() { + self._doEdit(); + }).appendTo(footerDiv); + } } }; @@ -219,6 +236,93 @@ ListFacet.prototype._doEdit = function() { new FacetBasedEditDialog(this._config.columnName, this._config.expression); }; +ListFacet.prototype._editChoice = function(choice, choiceDiv) { + var self = this; + + var menu = MenuSystem.createMenu().addClass("data-table-cell-editor").width("400px"); + menu.html( + '' + + '' + + '
' + + '