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-border">
<div class="dialog-header" bind="dialogHeader">Extract Operation History</div> <div class="dialog-header" bind="dialogHeader">Extract Operation History</div>
<div class="dialog-body" bind="dialogBody"> <div class="dialog-body" bind="dialogBody">
<div class="grid-layout layout-normal layout-full"> <div class="grid-layout layout-normal layout-full"><table>
<table> <tr>
<tr> <td colspan="2">
<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.
Extract and save parts of your operation history as JSON that you can apply to this or other projects in the future. </td>
</td> </tr>
</tr> <tr>
<tr> <td width="50%" style="vertical-align: top" class="history-extract-dialog-panel">
<td width="50%" style="vertical-align: top"> <table class="history-extract-dialog-entries" bind="entryTable"></table>
<div class="extract-operation-dialog-entries"> </td>
<table cellspacing="5" bind="entryTable"></table> <td width="50%" rowspan="2" style="vertical-align: top">
</div> <div class="input-container"><textarea wrap="off" class="history-operation-json" bind="textarea" /></div>
<button class="button" bind="selectAllButton">Select All</button> </td>
<button class="button" bind="unselectAllButton">Unselect All</button> </tr>
</td> <tr>
<td width="50%" style="vertical-align: top"> <td>
<div class="input-container"><textarea wrap="off" class="history-operation-json" bind="textarea" /></div> <button class="button" bind="selectAllButton">Select All</button>
</td> <button class="button" bind="unselectAllButton">Unselect All</button>
</tr> </td>
</table> </tr>
</div> </table></div>
</div> </div>
<div class="dialog-footer" bind="dialogFooter"> <div class="dialog-footer" bind="dialogFooter">
<button class="button" bind="closeButton">Close</button> <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 frame = $(DOM.loadHTML("core", "scripts/project/history-apply-dialog.html"));
var elmts = DOM.bind(frame); 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() { elmts.applyButton.click(function() {
var json; var json;
try { try {
json = JSON.parse(elmts.textarea[0].value); json = elmts.textarea[0].value;
json = fixJson(json);
json = JSON.parse(json);
} catch (e) { } catch (e) {
alert("The JSON you pasted is invalid."); alert("The JSON you pasted is invalid.");
return; return;

View File

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