Styling tweaks to history extract dialog. Apply some heuristics to pasted operation json to fix common json problems, such as missing commas or extra commas

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1631 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-10-25 04:31:28 +00:00
parent 1cc2097cf1
commit ad2a03a106
3 changed files with 51 additions and 34 deletions

View File

@ -2,27 +2,27 @@
<div class="dialog-border">
<div class="dialog-header" bind="dialogHeader">Extract Operation History</div>
<div class="dialog-body" bind="dialogBody">
<div class="grid-layout layout-normal layout-full">
<table>
<tr>
<td colspan="2">
Extract and save parts of your operation history as JSON that you can apply to this or other projects in the future.
</td>
</tr>
<tr>
<td width="50%" style="vertical-align: top">
<div class="extract-operation-dialog-entries">
<table cellspacing="5" bind="entryTable"></table>
</div>
<button class="button" bind="selectAllButton">Select All</button>
<button class="button" bind="unselectAllButton">Unselect All</button>
</td>
<td width="50%" style="vertical-align: top">
<div class="input-container"><textarea wrap="off" class="history-operation-json" bind="textarea" /></div>
</td>
</tr>
</table>
</div>
<div class="grid-layout layout-normal layout-full"><table>
<tr>
<td colspan="2">
Extract and save parts of your operation history as JSON that you can apply to this or other projects in the future.
</td>
</tr>
<tr>
<td width="50%" style="vertical-align: top" class="history-extract-dialog-panel">
<table class="history-extract-dialog-entries" bind="entryTable"></table>
</td>
<td width="50%" rowspan="2" style="vertical-align: top">
<div class="input-container"><textarea wrap="off" class="history-operation-json" bind="textarea" /></div>
</td>
</tr>
<tr>
<td>
<button class="button" bind="selectAllButton">Select All</button>
<button class="button" bind="unselectAllButton">Unselect All</button>
</td>
</tr>
</table></div>
</div>
<div class="dialog-footer" bind="dialogFooter">
<button class="button" bind="closeButton">Close</button>

View File

@ -251,11 +251,25 @@ HistoryPanel.prototype._showApplyOperationsDialog = function() {
var frame = $(DOM.loadHTML("core", "scripts/project/history-apply-dialog.html"));
var elmts = DOM.bind(frame);
var fixJson = function(json) {
json = json.trim();
if (!json.startsWith("[")) {
json = "[" + json;
}
if (!json.endsWith("[")) {
json = json + "]";
}
return json.replace(/\}\s*\,\s*\]/g, "} ]").replace(/\}\s*\{/g, "}, {");
};
elmts.applyButton.click(function() {
var json;
try {
json = JSON.parse(elmts.textarea[0].value);
json = elmts.textarea[0].value;
json = fixJson(json);
json = JSON.parse(json);
} catch (e) {
alert("The JSON you pasted is invalid.");
return;

View File

@ -187,16 +187,19 @@ a.history-entry.filtered-out > * {
border-bottom: 1px solid @selected_primary;
}
.history-extract-dialog-panel {
border: 1px solid @chrome_primary;
height: 400px;
overflow: auto;
}
table.history-extract-dialog-entries {
border-collapse: separate;
border-spacing: @padding_tight;
}
.extract-operation-dialog-entries {
height: 400px;
padding: 2px;
border: 1px inset;
max-width: 400px !important;
overflow: auto;
}
textarea.history-operation-json {
white-space: pre;
font-family: monospace;
height: 400px;
}
white-space: pre;
font-family: monospace;
height: 450px;
}