When sorting, it's now possible to specify where to put blanks and errors relative to the valid values.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@837 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-05-21 04:46:36 +00:00
parent 369a02043c
commit 4e6b915bc1
3 changed files with 58 additions and 6 deletions

View File

@ -33,7 +33,7 @@ abstract public class Criterion {
blankPosition = obj.getInt("blankPosition");
}
if (obj.has("errorPosition") && !obj.isNull("errorPosition")) {
blankPosition = obj.getInt("errorPosition");
errorPosition = obj.getInt("errorPosition");
}
if (obj.has("reverse") && !obj.isNull("reverse")) {

View File

@ -1178,11 +1178,7 @@ DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, ha
'</table></div>' +
'</td>' +
'<td>' +
'<ul>' +
'<li>Valid Values</li>' +
'<li>Blanks</li>' +
'<li>Errors</li>' +
'</ul>' +
'<ul class="sorting-dialog-blank-error-positions" bind="blankErrorPositions"></ul>' +
'<p>Drag and drop to re-order</p>' +
'</td>' +
'</tr>' +
@ -1231,6 +1227,29 @@ DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, ha
bodyElmts.sortAloneContainer.show();
}
var validValuesHtml = '<li kind="value">Valid Values</li>';
var blankValuesHtml = '<li kind="blank">Blanks</li>';
var errorValuesHtml = '<li kind="error">Errors</li>';
var positionsHtml;
if (criterion.blankPosition < 0) {
if (criterion.errorPosition > 0) {
positionsHtml = [ blankValuesHtml, validValuesHtml, errorValuesHtml ];
} else if (criterion.errorPosition < criterion.blankPosition) {
positionsHtml = [ errorValuesHtml, blankValuesHtml, validValuesHtml ];
} else {
positionsHtml = [ blankValuesHtml, errorValuesHtml, validValuesHtml ];
}
} else {
if (criterion.errorPosition < 0) {
positionsHtml = [ errorValuesHtml, validValuesHtml, blankValuesHtml ];
} else if (criterion.errorPosition < criterion.blankPosition) {
positionsHtml = [ validValuesHtml, errorValuesHtml, blankValuesHtml ];
} else {
positionsHtml = [ validValuesHtml, blankValuesHtml, errorValuesHtml ];
}
}
bodyElmts.blankErrorPositions.html(positionsHtml.join("")).sortable().disableSelection();
footer.html(
'<button bind="okButton">&nbsp;&nbsp;OK&nbsp;&nbsp;</button>' +
'<button bind="cancelButton">Cancel</button>'
@ -1252,6 +1271,20 @@ DataTableColumnHeaderUI.prototype._showSortingCriterion = function(criterion, ha
reverse: bodyElmts.directionOptions.find("input[type='radio']:checked")[0].value == "reverse"
};
var valuePosition, blankPosition, errorPosition;
bodyElmts.blankErrorPositions.find("li").each(function(index, elmt) {
var kind = this.getAttribute("kind");
if (kind == "value") {
valuePosition = index;
} else if (kind == "blank") {
blankPosition = index;
} else if (kind == "error") {
errorPosition = index;
}
});
criterion2.blankPosition = blankPosition - valuePosition;
criterion2.errorPosition = errorPosition - valuePosition;
if (criterion2.valueType == "string") {
criterion2.caseSensitive = bodyElmts.caseSensitiveCheckbox[0].checked;
}

View File

@ -252,3 +252,22 @@ iframe.data-table-topic-popup-iframe {
background: #DBE8EB;
border: none;
}
ul.sorting-dialog-blank-error-positions {
margin: 0;
padding: 5px;
height: 10em;
border: 1px solid #ccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
ul.sorting-dialog-blank-error-positions > li {
display: block;
border: 1px solid #ccc;
background: #eee;
padding: 5px;
margin: 2px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
cursor: move;
}