Commit c959b708 authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_code_mirror: Refresh Component history revisions (used for merge mode)...

erp5_code_mirror: Refresh Component history revisions (used for merge mode) when saving with CTRL+s.
parent 06c09cbb
...@@ -201,6 +201,8 @@ ...@@ -201,6 +201,8 @@
* result as well\n * result as well\n
*/\n */\n
function successHandler(data) {\n function successHandler(data) {\n
generateHistorySelectElement();\n
\n
transition_message = $(\'#transition_message\');\n transition_message = $(\'#transition_message\');\n
transition_message.css(\'opacity\', 0.0);\n transition_message.css(\'opacity\', 0.0);\n
transition_message.html(data);\n transition_message.html(data);\n
...@@ -466,70 +468,51 @@ ...@@ -466,70 +468,51 @@
maximize();\n maximize();\n
}\n }\n
\n \n
function generateHistorySelectElement(data) {\n function generateHistorySelectElement() {\n
container_elem = $(\'<p style="margin: 0; padding: 0;"></p>\');\n function successHandler(data) {\n
for(var i = 0; i < 2; i++)\n container_elem = $(\'#history_select_container\');\n
{\n if(container_elem.length == 0)\n
var is_right = (i == 1);\n container_elem = $(\'<p style="margin: 0; padding: 0;" id="history_select_container"></p>\');\n
if(is_right)\n
attrs = \'id="history_select_right" style="float: right"\'\n
else\n else\n
attrs = \'id="history_select_left" style="float: left"\'\n container_elem.empty();\n
\n
select_revision_element = $(\n
"<select class=\'editor_action_button\' " + attrs + "></select>");\n
\n
if(is_right)\n
select_revision_element.append($("<option value=\'\'></option>"));\n
\n
$.each(\n
data,\n
function(j, d) {\n
select_revision_element.append(\n
$("<option value=\'" + d[\'key\'] + "\'>" + j + ": " +\n
new Date(d[\'time\'] * 1000).toString() + " (" + d[\'user_name\'] + ")" +\n
"</option>"));\n
});\n
\n \n
function selectHistoryTextContent(event) {\n for(var i = 0; i < 2; i++)\n
function loadTextContent(data) {\n {\n
cm.setValue(data);\n var is_right = (i == 1);\n
cm.save();\n if(is_right)\n
\n attrs = \'id="history_select_right" style="float: right"\'\n
if(merge_mode_elem) {\n else\n
merge_mode_elem.edit.setValue(data);\n attrs = \'id="history_select_left" style="float: left"\'\n
merge_mode_elem.edit.refresh();\n \n
merge_mode_elem.right.orig.refresh();\n select_revision_element = $(\n
"<select class=\'editor_action_button\' " + attrs + "></select>");\n
\n
if(is_right)\n
select_revision_element.append($("<option value=\'\'></option>"));\n
\n
$.each(\n
data,\n
function(j, d) {\n
select_revision_element.append(\n
$("<option value=\'" + d[\'key\'] + "\'>" + j + ": " +\n
new Date(d[\'time\'] * 1000).toString() + " (" + d[\'user_name\'] + ")" +\n
"</option>"));\n
});\n
\n
function selectHistoryTextContent(event) {\n
function loadTextContent(data) {\n
cm.setValue(data);\n
cm.save();\n
\n
if(merge_mode_elem) {\n
merge_mode_elem.edit.setValue(data);\n
merge_mode_elem.edit.refresh();\n
merge_mode_elem.right.orig.refresh();\n
}\n
\n
displayLoadSourceCodeMessage();\n
}\n }\n
\n \n
displayLoadSourceCodeMessage();\n
}\n
\n
// TODO: failure\n
$.ajax({type: \'GET\',\n
async: true,\n
dataType: \'text\',\n
data: {key: this.value},\n
url: \'getTextContentHistory\',\n
success: loadTextContent});\n
}\n
\n
function selectHistoryTextContentMerge(event) {\n
function loadTextContent(data) {\n
if(merge_mode_elem) {\n
merge_mode_elem.right.orig.setValue(data);\n
merge_mode_elem.edit.refresh();\n
merge_mode_elem.right.orig.refresh();\n
}\n
else\n
enterMerge(data);\n
\n
displayLoadSourceCodeMessage();\n
}\n
\n
if(!this.value)\n
leaveMerge();\n
else\n
// TODO: failure\n // TODO: failure\n
$.ajax({type: \'GET\',\n $.ajax({type: \'GET\',\n
async: true,\n async: true,\n
...@@ -537,25 +520,53 @@ ...@@ -537,25 +520,53 @@
data: {key: this.value},\n data: {key: this.value},\n
url: \'getTextContentHistory\',\n url: \'getTextContentHistory\',\n
success: loadTextContent});\n success: loadTextContent});\n
}\n }\n
\n \n
if(!is_right)\n function selectHistoryTextContentMerge(event) {\n
select_revision_element.bind(\'change\', selectHistoryTextContent);\n function loadTextContent(data) {\n
else\n if(merge_mode_elem) {\n
select_revision_element.bind(\'change\', selectHistoryTextContentMerge);\n merge_mode_elem.right.orig.setValue(data);\n
merge_mode_elem.edit.refresh();\n
merge_mode_elem.right.orig.refresh();\n
}\n
else\n
enterMerge(data);\n
\n
displayLoadSourceCodeMessage();\n
}\n
\n \n
select_revision_element.appendTo(container_elem);\n if(!this.value)\n
}\n leaveMerge();\n
else\n
// TODO: failure\n
$.ajax({type: \'GET\',\n
async: true,\n
dataType: \'text\',\n
data: {key: this.value},\n
url: \'getTextContentHistory\',\n
success: loadTextContent});\n
}\n
\n \n
container_elem.append($(\'<div style="clear: both;"></div>\'));\n if(!is_right)\n
container_elem.prependTo($(\'#merge\'));\n select_revision_element.bind(\'change\', selectHistoryTextContent);\n
}\n else\n
select_revision_element.bind(\'change\', selectHistoryTextContentMerge);\n
\n
select_revision_element.appendTo(container_elem);\n
}\n
\n
container_elem.append($(\'<div style="clear: both;"></div>\'));\n
container_elem.prependTo($(\'#merge\'));\n
}\n
\n \n
$.ajax({type: \'GET\',\n $.ajax({type: \'GET\',\n
async: true,\n async: true,\n
dataType: \'json\',\n dataType: \'json\',\n
url: \'Component_getTextContentHistoryRevisionDictListAsJSON\',\n url: \'Component_getTextContentHistoryRevisionDictListAsJSON\',\n
success: generateHistorySelectElement});\n success: successHandler});\n
}\n
\n
generateHistorySelectElement();\n
</script>\n </script>\n
......
2014-12-26 arnaud.fontaine
* Refresh Component history revisions when saving with CTRL+s.
2014-12-26 arnaud.fontaine 2014-12-26 arnaud.fontaine
* Fix layout of warnings/errors div to make it consistent with maximize info div. * Fix layout of warnings/errors div to make it consistent with maximize info div.
......
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