Implemented permanent link, at least for facets' states.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@147 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
f5ff9044cf
commit
f0b8268809
@ -1,4 +1,4 @@
|
|||||||
function ListFacet(div, config, options) {
|
function ListFacet(div, config, options, selection) {
|
||||||
this._div = div;
|
this._div = div;
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
|
||||||
@ -7,12 +7,28 @@ function ListFacet(div, config, options) {
|
|||||||
this._options.sort = "name";
|
this._options.sort = "name";
|
||||||
}
|
}
|
||||||
|
|
||||||
this._selection = [];
|
this._selection = selection || [];
|
||||||
this._data = null;
|
this._data = null;
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListFacet.reconstruct = function(div, uiState) {
|
||||||
|
return new ListFacet(div, uiState.c, uiState.o, uiState.s);
|
||||||
|
};
|
||||||
|
|
||||||
|
ListFacet.prototype.getUIState = function() {
|
||||||
|
var json = {
|
||||||
|
c: this.getJSON(),
|
||||||
|
o: this._options
|
||||||
|
};
|
||||||
|
|
||||||
|
json.s = json.c.selection;
|
||||||
|
delete json.c.selection;
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
ListFacet.prototype.getJSON = function() {
|
ListFacet.prototype.getJSON = function() {
|
||||||
var o = {
|
var o = {
|
||||||
type: "list",
|
type: "list",
|
||||||
|
@ -26,6 +26,20 @@ RangeFacet.prototype._setDefaults = function() {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RangeFacet.reconstruct = function(div, uiState) {
|
||||||
|
return new RangeFacet(div, uiState.c, uiState.o);
|
||||||
|
};
|
||||||
|
|
||||||
|
RangeFacet.prototype.getUIState = function() {
|
||||||
|
var json = {
|
||||||
|
c: this.getJSON(),
|
||||||
|
o: this._options
|
||||||
|
};
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RangeFacet.prototype.getJSON = function() {
|
RangeFacet.prototype.getJSON = function() {
|
||||||
var o = {
|
var o = {
|
||||||
type: "range",
|
type: "range",
|
||||||
|
@ -3,16 +3,25 @@ function TextSearchFacet(div, config, options) {
|
|||||||
this._config = config;
|
this._config = config;
|
||||||
this._options = options;
|
this._options = options;
|
||||||
|
|
||||||
this._setDefaults();
|
this._query = config.query || null;
|
||||||
this._timerID = null;
|
this._timerID = null;
|
||||||
|
|
||||||
this._initializeUI();
|
this._initializeUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextSearchFacet.prototype._setDefaults = function() {
|
TextSearchFacet.reconstruct = function(div, uiState) {
|
||||||
this._query = null;
|
return new TextSearchFacet(div, uiState.c, uiState.o);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TextSearchFacet.prototype.getUIState = function() {
|
||||||
|
var json = {
|
||||||
|
c: this.getJSON(),
|
||||||
|
o: this._options
|
||||||
|
};
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
TextSearchFacet.prototype.getJSON = function() {
|
TextSearchFacet.prototype.getJSON = function() {
|
||||||
var o = {
|
var o = {
|
||||||
type: "text",
|
type: "text",
|
||||||
@ -58,7 +67,7 @@ TextSearchFacet.prototype.render = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TextSearchFacet.prototype._reset = function() {
|
TextSearchFacet.prototype._reset = function() {
|
||||||
this._setDefaults();
|
this._query = null;
|
||||||
this._updateRest();
|
this._updateRest();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ Gridworks.reportException = function(e) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
var params = URL.getParameters();
|
var params = URL.getParameters();
|
||||||
if ("project" in params) {
|
if ("project" in params) {
|
||||||
@ -18,15 +17,36 @@ function onLoad() {
|
|||||||
id: parseInt(params.project)
|
id: parseInt(params.project)
|
||||||
};
|
};
|
||||||
|
|
||||||
Gridworks.reinitializeProjectData(initializeUI);
|
var uiState = {};
|
||||||
|
if ("ui" in params) {
|
||||||
|
try {
|
||||||
|
uiState = JSON.parse(params.ui);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gridworks.reinitializeProjectData(function() {
|
||||||
|
initializeUI(uiState);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(onLoad);
|
$(onLoad);
|
||||||
|
|
||||||
function initializeUI() {
|
function initializeUI(uiState) {
|
||||||
document.title = theProject.metadata.name + " - Gridworks";
|
document.title = theProject.metadata.name + " - Gridworks";
|
||||||
$('<span></span>').text(theProject.metadata.name).addClass("app-path-section").appendTo($("#path"));
|
|
||||||
$('<span></span>').text(" project").appendTo($("#path"));
|
var path = $("#path");
|
||||||
|
$('<span></span>').text(theProject.metadata.name).addClass("app-path-section").appendTo(path);
|
||||||
|
$('<span></span>').text(" project").appendTo(path);
|
||||||
|
|
||||||
|
$('<span>').html(" » ").appendTo(path);
|
||||||
|
$('<a href="javascript:{}"></a>')
|
||||||
|
.addClass("app-path-section")
|
||||||
|
.text("current view")
|
||||||
|
.mouseenter(function() {
|
||||||
|
this.href = Gridworks.getPermanentLink();
|
||||||
|
})
|
||||||
|
.appendTo(path);
|
||||||
|
|
||||||
var body = $("#body").empty();
|
var body = $("#body").empty();
|
||||||
|
|
||||||
@ -47,7 +67,7 @@ function initializeUI() {
|
|||||||
ui.processPanel = $('<div></div>').addClass("process-panel").appendTo(document.body);
|
ui.processPanel = $('<div></div>').addClass("process-panel").appendTo(document.body);
|
||||||
ui.menuBarPanel = $('<div></div>'); $("#header").after(ui.menuBarPanel);
|
ui.menuBarPanel = $('<div></div>'); $("#header").after(ui.menuBarPanel);
|
||||||
|
|
||||||
ui.browsingEngine = new BrowsingEngine(ui.facetPanel);
|
ui.browsingEngine = new BrowsingEngine(ui.facetPanel, uiState.facets || []);
|
||||||
ui.processWidget = new ProcessWidget(ui.processPanel);
|
ui.processWidget = new ProcessWidget(ui.processPanel);
|
||||||
ui.historyWidget = new HistoryWidget(ui.historyPanel);
|
ui.historyWidget = new HistoryWidget(ui.historyPanel);
|
||||||
ui.dataTableView = new DataTableView(ui.viewPanel);
|
ui.dataTableView = new DataTableView(ui.viewPanel);
|
||||||
@ -220,3 +240,13 @@ Gridworks.fetchRows = function(start, limit, onDone) {
|
|||||||
"json"
|
"json"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Gridworks.getPermanentLink = function() {
|
||||||
|
var params = [
|
||||||
|
"project=" + escape(theProject.id),
|
||||||
|
"ui=" + escape(JSON.stringify({
|
||||||
|
facets: ui.browsingEngine.getFacetUIStates()
|
||||||
|
}))
|
||||||
|
];
|
||||||
|
return "project.html?" + params.join("&");
|
||||||
|
};
|
||||||
|
@ -1,8 +1,40 @@
|
|||||||
function BrowsingEngine(div) {
|
function BrowsingEngine(div, facetConfigs) {
|
||||||
this._div = div;
|
this._div = div;
|
||||||
this._facets = [];
|
this._facets = [];
|
||||||
|
|
||||||
this._initializeUI();
|
this._initializeUI();
|
||||||
|
|
||||||
|
if (facetConfigs.length > 0) {
|
||||||
|
for (var i = 0; i < facetConfigs.length; i++) {
|
||||||
|
var facetConfig = facetConfigs[i];
|
||||||
|
var type = facetConfig.c.type;
|
||||||
|
|
||||||
|
var div = $('<div></div>').addClass("facet-container").appendTo(this._div);
|
||||||
|
var facet;
|
||||||
|
switch (type) {
|
||||||
|
case "range":
|
||||||
|
facet = RangeFacet.reconstruct(div, facetConfig);
|
||||||
|
break;
|
||||||
|
case "text":
|
||||||
|
facet = TextSearchFacet.reconstruct(div, facetConfig);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
facet = ListFacet.reconstruct(div, facetConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._facets.push({ elmt: div, facet: facet });
|
||||||
|
}
|
||||||
|
this.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BrowsingEngine.prototype.getFacetUIStates = function() {
|
||||||
|
var f = [];
|
||||||
|
for (var i = 0; i < this._facets.length; i++) {
|
||||||
|
var facet = this._facets[i];
|
||||||
|
f.push(facet.facet.getUIState());
|
||||||
|
}
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowsingEngine.prototype._initializeUI = function() {
|
BrowsingEngine.prototype._initializeUI = function() {
|
||||||
@ -59,7 +91,7 @@ BrowsingEngine.prototype.update = function(onDone) {
|
|||||||
|
|
||||||
$.post(
|
$.post(
|
||||||
"/command/compute-facets?" + $.param({ project: theProject.id }),
|
"/command/compute-facets?" + $.param({ project: theProject.id }),
|
||||||
{ engine: JSON.stringify(ui.browsingEngine.getJSON(true)) },
|
{ engine: JSON.stringify(this.getJSON(true)) },
|
||||||
function(data) {
|
function(data) {
|
||||||
var facetData = data.facets;
|
var facetData = data.facets;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user