Bug fix: editing one facet choice while some other choices are selected resulted in no change.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@429 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-04-08 22:16:12 +00:00
parent c4460fdfdd
commit 759824e1b4
4 changed files with 41 additions and 29 deletions

View File

@ -47,28 +47,34 @@ public class Engine implements Jsonizable {
} }
public void initializeFromJSON(JSONObject o) throws Exception { public void initializeFromJSON(JSONObject o) throws Exception {
JSONArray a = o.getJSONArray("facets"); if (o == null) {
int length = a.length(); return;
}
for (int i = 0; i < length; i++) {
JSONObject fo = a.getJSONObject(i); if (o.has("facets") && !o.isNull("facets")) {
String type = fo.has("type") ? fo.getString("type") : "list"; JSONArray a = o.getJSONArray("facets");
int length = a.length();
Facet facet = null;
if ("list".equals(type)) { for (int i = 0; i < length; i++) {
facet = new ListFacet(); JSONObject fo = a.getJSONObject(i);
} else if ("range".equals(type)) { String type = fo.has("type") ? fo.getString("type") : "list";
facet = new RangeFacet();
} else if ("text".equals(type)) { Facet facet = null;
facet = new TextSearchFacet(); if ("list".equals(type)) {
} facet = new ListFacet();
} else if ("range".equals(type)) {
if (facet != null) { facet = new RangeFacet();
facet.initializeFromJSON(_project, fo); } else if ("text".equals(type)) {
_facets.add(facet); facet = new TextSearchFacet();
} }
}
if (facet != null) {
facet.initializeFromJSON(_project, fo);
_facets.add(facet);
}
}
}
if (o.has("includeDependent") && !o.isNull("includeDependent")) { if (o.has("includeDependent") && !o.isNull("includeDependent")) {
_includeDependent = o.getBoolean("includeDependent"); _includeDependent = o.getBoolean("includeDependent");
} }

View File

@ -15,7 +15,8 @@ abstract public class EngineDependentOperation extends AbstractOperation {
protected EngineDependentOperation(JSONObject engineConfig) { protected EngineDependentOperation(JSONObject engineConfig) {
_engineConfig = engineConfig; _engineConfig = engineConfig;
_engineConfigString = engineConfig.toString(); _engineConfigString = engineConfig == null || engineConfig.length() == 0
? null : engineConfig.toString();
} }
protected Engine createEngine(Project project) throws Exception { protected Engine createEngine(Project project) throws Exception {
@ -25,7 +26,7 @@ abstract public class EngineDependentOperation extends AbstractOperation {
} }
protected JSONObject getEngineConfig() { protected JSONObject getEngineConfig() {
if (_engineConfig == null) { if (_engineConfig == null && _engineConfigString != null) {
try { try {
_engineConfig = ParsingUtilities.evaluateJsonStringToObject(_engineConfigString); _engineConfig = ParsingUtilities.evaluateJsonStringToObject(_engineConfigString);
} catch (JSONException e) { } catch (JSONException e) {

View File

@ -294,7 +294,10 @@ ListFacet.prototype._editChoice = function(choice, choiceDiv) {
to: text to: text
}]) }])
}, },
{ cellsChanged: true }, {
includeEngine: false, // we're really changing all rows, not just the visible ones
cellsChanged: true
},
{ {
onDone: function(o) { onDone: function(o) {
var selection = []; var selection = [];

View File

@ -186,14 +186,16 @@ Gridworks.update = function(options, onFinallyDone) {
}; };
Gridworks.postProcess = function(command, params, body, updateOptions, callbacks) { Gridworks.postProcess = function(command, params, body, updateOptions, callbacks) {
updateOptions = updateOptions || {};
callbacks = callbacks || {};
params = params || {}; params = params || {};
params.project = theProject.id; params.project = theProject.id;
body = body || {}; body = body || {};
body.engine = JSON.stringify(ui.browsingEngine.getJSON()); if (!("includeEngine" in updateOptions) || updateOptions.includeEngine) {
body.engine = JSON.stringify(ui.browsingEngine.getJSON());
updateOptions = updateOptions || {}; }
callbacks = callbacks || {};
var done = false; var done = false;
var dismissBusy = null; var dismissBusy = null;