]> git.joonet.de Git - adminer.git/commitdiff
Allow editing single value enums (bug #334)
authorJakub Vrana <jakub@vrana.cz>
Sat, 21 Dec 2013 02:02:56 +0000 (18:02 -0800)
committerJakub Vrana <jakub@vrana.cz>
Sat, 21 Dec 2013 02:02:56 +0000 (18:02 -0800)
adminer/static/editing.js

index b2336a75757b77fd6fc0231d1a32a36569851f4d..1416b43dcb8974ade38a1b3b38c8e35e791bb7ff 100644 (file)
@@ -332,7 +332,7 @@ function editingLengthFocus(field) {
        if (/(enum|set)$/.test(selectValue(td.previousSibling.firstChild))) {
                var edit = document.getElementById('enum-edit');
                var val = field.value;
-               edit.value = (/^'.+','.+'$/.test(val) ? val.substr(1, val.length - 2).replace(/','/g, "\n").replace(/''/g, "'") : val);
+               edit.value = (/^'.+'$/.test(val) ? val.substr(1, val.length - 2).replace(/','/g, "\n").replace(/''/g, "'") : val); //! doesn't handle 'a'',''b' correctly
                td.appendChild(edit);
                field.style.display = 'none';
                edit.style.display = 'inline';
@@ -346,7 +346,7 @@ function editingLengthFocus(field) {
 function editingLengthBlur(edit) {
        var field = edit.parentNode.firstChild;
        var val = edit.value;
-       field.value = (/\n/.test(val) ? "'" + val.replace(/\n+$/, '').replace(/'/g, "''").replace(/\n/g, "','") + "'" : val);
+       field.value = (/^'[^\n]+'$/.test(val) ? val : "'" + val.replace(/\n+$/, '').replace(/'/g, "''").replace(/\n/g, "','") + "'");
        field.style.display = 'inline';
        edit.style.display = 'none';
 }