Commit e37edff6 authored by Jérome Perrin's avatar Jérome Perrin

code_mirror: also support yapf for ZMI Python Scripts

parent 77fd986c
......@@ -346,7 +346,28 @@
}
function saveZMIDocument(cm, event) {
$('input[value="Save Changes"]').click();
/* preformat with YAPF before saving */
if (mode == 'python') {
$.ajax({
type: 'POST',
url: '&dtml-portal_url;/ERP5Site_formatPythonSourceCode',
data: {code: cm.getValue()},
success: function refreshTextContent(textContent) {
if (textContent !== cm.getValue()) {
if (cm.hasFocus()) {
const cursorPosition = cm.getCursor();
cm.setValue(textContent);
cm.setCursor(cursorPosition);
} else {
cm.setValue(textContent);
}
}
$('input[value="Save Changes"]').click();
}
});
} else {
$('input[value="Save Changes"]').click();
}
return false;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment