Remember sorting

This commit is contained in:
jos 2018-06-02 15:02:24 +02:00
parent bd87ac83d5
commit 95d5d33f56
2 changed files with 15 additions and 4 deletions

View File

@ -276,6 +276,7 @@ div.jsoneditor-contextmenu button.jsoneditor-type-modes > div.jsoneditor-icon {
border-radius: 2px !important; border-radius: 2px !important;
padding: 30px 20px 10px 20px !important; padding: 30px 20px 10px 20px !important;
box-shadow: 2px 2px 12px rgba(128, 128, 128, 0.3) !important;
} }
.jsoneditor-modal table td { .jsoneditor-modal table td {
@ -316,7 +317,7 @@ div.jsoneditor-contextmenu button.jsoneditor-type-modes > div.jsoneditor-icon {
} }
.jsoneditor-modal select { .jsoneditor-modal select {
padding: 6px 28px 6px 10px; padding: 4px 28px 4px 10px;
/* https://stackoverflow.com/questions/20366166/bootstrap-3-styled-select-dropdown-looks-ugly-in-firefox-on-os-x */ /* https://stackoverflow.com/questions/20366166/bootstrap-3-styled-select-dropdown-looks-ugly-in-firefox-on-os-x */
background: #f5f5f5 url("data:image/svg+xml,\ background: #f5f5f5 url("data:image/svg+xml,\
@ -330,5 +331,5 @@ div.jsoneditor-contextmenu button.jsoneditor-type-modes > div.jsoneditor-icon {
} }
.jsoneditor-modal input { .jsoneditor-modal input {
padding: 6px 20px; padding: 4px 20px;
} }

View File

@ -3749,8 +3749,8 @@ Node.prototype._showSortModal = function () {
' <td>Direction:</td>' + ' <td>Direction:</td>' +
' <td class="jsoneditor-modal-input">' + ' <td class="jsoneditor-modal-input">' +
' <select id="direction">' + ' <select id="direction">' +
' <option value="asc" selected>asc</option>' + ' <option value="asc" selected>Ascending</option>' +
' <option value="desc">desc</option>' + ' <option value="desc">Descending</option>' +
' </select>' + ' </select>' +
' </td>' + ' </td>' +
'</tr>' + '</tr>' +
@ -3778,6 +3778,11 @@ Node.prototype._showSortModal = function () {
sortBy.appendChild(option); sortBy.appendChild(option);
}); });
if (node.sortedBy) {
sortBy.value = node.sortedBy.path;
direction.value = node.sortedBy.direction;
}
form.onsubmit = function (event) { form.onsubmit = function (event) {
event.preventDefault(); event.preventDefault();
@ -3786,6 +3791,11 @@ Node.prototype._showSortModal = function () {
var path = sortBy.value; var path = sortBy.value;
var pathArray = (path === '.') ? [] : path.split('.').slice(1); var pathArray = (path === '.') ? [] : path.split('.').slice(1);
node.sortedBy = {
path: path,
direction: direction.value
};
node.sort(pathArray, direction.value) node.sort(pathArray, direction.value)
}; };
}) })