diff --git a/src/main/java/com/metaweb/gridworks/commands/info/GetOperationsCommand.java b/src/main/java/com/metaweb/gridworks/commands/info/GetOperationsCommand.java
index cca378d6c..13552d6c0 100644
--- a/src/main/java/com/metaweb/gridworks/commands/info/GetOperationsCommand.java
+++ b/src/main/java/com/metaweb/gridworks/commands/info/GetOperationsCommand.java
@@ -29,12 +29,16 @@ public class GetOperationsCommand extends Command {
JSONWriter writer = new JSONWriter(response.getWriter());
writer.object();
- writer.key("operations"); writer.array();
+ writer.key("entries"); writer.array();
for (HistoryEntry entry : project.history.getLastPastEntries(-1)) {
+ writer.object();
+ writer.key("description"); writer.value(entry.description);
if (entry.operation != null) {
+ writer.key("operation");
entry.operation.write(writer, options);
}
+ writer.endObject();
}
writer.endArray();
writer.endObject();
diff --git a/src/main/webapp/scripts/project/history-widget.js b/src/main/webapp/scripts/project/history-widget.js
index 6fff05f96..3fe4911a5 100644
--- a/src/main/webapp/scripts/project/history-widget.js
+++ b/src/main/webapp/scripts/project/history-widget.js
@@ -109,8 +109,8 @@ HistoryWidget.prototype._extractOperations = function() {
"/command/get-operations?" + $.param({ project: theProject.id }),
null,
function(data) {
- if ("operations" in data) {
- self._showExtractOperationsDialog(data.operations);
+ if ("entries" in data) {
+ self._showExtractOperationsDialog(data);
}
},
"jsonp"
@@ -130,8 +130,55 @@ HistoryWidget.prototype._showExtractOperationsDialog = function(json) {
"The following JSON code encodes the operations you have done that can be abstracted. " +
"You can copy and save it in order to apply the same operations in the future.").appendTo(body);
- var textarea = $('').attr("wrap", "hard").width("100%").height("400px").appendTo(body);
- textarea.text(JSON.stringify(json, null, 2));
+ var table = $('
').appendTo(body)[0];
+ var leftColumn = table.rows[0].insertCell(0);
+ var rightColumn = table.rows[0].insertCell(1);
+ $(leftColumn).width("50%");
+ $(rightColumn).width("50%").css("padding-left", "20px");
+
+ var entryDiv = $('').height("400px").css("overflow", "auto").appendTo(leftColumn);
+ var entryTable = $('
').appendTo(entryDiv)[0];
+ var createEntry = function(entry) {
+ var tr = entryTable.insertRow(entryTable.rows.length);
+ var td0 = tr.insertCell(0);
+ var td1 = tr.insertCell(1);
+ td0.width = "1%";
+
+ if ("operation" in entry) {
+ entry.selected = true;
+
+ $('
').appendTo(td0).click(function() {
+ entry.selected = !entry.selected;
+ updateJson();
+ });
+
+ $('
').text(entry.operation.description).appendTo(td1);
+ } else {
+ $('').text(entry.description).css("color", "#888").appendTo(td1);
+ }
+ };
+ for (var i = 0; i < json.entries.length; i++) {
+ createEntry(json.entries[i]);
+ }
+
+ var textarea = $('')
+ .attr("wrap", "off")
+ .css("white-space", "pre")
+ .css("font-family", "monospace")
+ .width("100%")
+ .height("400px")
+ .appendTo(rightColumn);
+ var updateJson = function() {
+ var a = [];
+ for (var i = 0; i < json.entries.length; i++) {
+ var entry = json.entries[i];
+ if ("operation" in entry && entry.selected) {
+ a.push(entry.operation);
+ }
+ }
+ textarea.text(JSON.stringify(a, null, 2));
+ };
+ updateJson();
$('').text("Done").click(function() {
DialogSystem.dismissUntil(level - 1);
@@ -154,7 +201,13 @@ HistoryWidget.prototype._showApplyOperationsDialog = function(json) {
$('').text(
"Paste the JSON code encoding the operations to perform.").appendTo(body);
- var textarea = $('').attr("wrap", "hard").width("100%").height("400px").appendTo(body);
+ var textarea = $('')
+ .attr("wrap", "off")
+ .css("white-space", "pre")
+ .css("font-family", "monospace")
+ .width("100%")
+ .height("400px")
+ .appendTo(body);
textarea.text(JSON.stringify(json, null, 2));
$('').text("Apply").click(function() {