Commit e2cc260a authored by Tristan Cavelier's avatar Tristan Cavelier

Improve OfficeJS, SlickGrid, Basic Conflict Manager

SlickGrid can now show documents that are in conflict or not,
and Basic Conflict Manager shows the last modify date of revisions.
parent 25b9ca5f
...@@ -17,23 +17,25 @@ ...@@ -17,23 +17,25 @@
window.basic_conflict_solver = { window.basic_conflict_solver = {
conflict_object:{}, conflict_object:{},
addRevision: function (revision,content) { addRevision: function (doc) {
document.querySelector ('#basic_conflict_solver_div #revisions'). document.querySelector ('#basic_conflict_solver_div #revisions').
innerHTML += '<div class="row-fluid"><div class="span12">'+ innerHTML += '<div class="row-fluid"><div class="span12">'+
'<div><textarea id="'+revision+'">'+content+'</textarea></div>'+ '<div>'+(new Date(doc.last_modified)).toString()+'</div>'+
'<div><textarea id="'+doc.revision+'">'+doc.content+'</textarea></div>'+
'<div><button onclick="'+ '<div><button onclick="'+
//'console.log('+"'"+revision+"'"+');'+ //'console.log('+"'"+revision+"'"+');'+
"basic_conflict_solver.keepRevision('"+revision+"');"+ "basic_conflict_solver.keepRevision('"+doc.revision+"');"+
'">Save this one</button></div><hr/>'+ '">Save this one</button></div><hr/>'+
'</div></div>'; '</div></div>';
}, },
addRemovedRevision: function (revision) { addRemovedRevision: function (doc) {
document.querySelector ('#basic_conflict_solver_div #revisions'). document.querySelector ('#basic_conflict_solver_div #revisions').
innerHTML += '<div class="row-fluid"><div class="span12">'+ innerHTML += '<div class="row-fluid"><div class="span12">'+
'<div>'+(new Date(doc.last_modified)).toString()+'</div>'+
'<div>Removed</div>'+ '<div>Removed</div>'+
'<div><button onclick="'+ '<div><button onclick="'+
//'console.log('+"'"+revision+"'"+');'+ //'console.log('+"'"+revision+"'"+');'+
"basic_conflict_solver.keepRevision('"+revision+"');"+ "basic_conflict_solver.keepRevision('"+doc.revision+"');"+
'">Save this one</button></div><hr/>'+ '">Save this one</button></div><hr/>'+
'</div></div>'; '</div></div>';
}, },
......
...@@ -82,6 +82,8 @@ window.OfficeJS_slickgrid.reload = function () { ...@@ -82,6 +82,8 @@ window.OfficeJS_slickgrid.reload = function () {
array[i].icon = mime.icon; array[i].icon = mime.icon;
array[i].app = mime.preferred_application || mime.application; array[i].app = mime.preferred_application || mime.application;
} }
array[i].conflict = array[i].revision_object[
array[i].revision].conflict?'X':'';
// dates // dates
// FIXME : we can have 2012/1/1 12:5 // FIXME : we can have 2012/1/1 12:5
// we should have 2012/01/01 12:05 // we should have 2012/01/01 12:05
...@@ -111,6 +113,9 @@ window.OfficeJS_slickgrid.reload = function () { ...@@ -111,6 +113,9 @@ window.OfficeJS_slickgrid.reload = function () {
field:"last_modified",sortable:true}); field:"last_modified",sortable:true});
columns.push({id:"creation_date",name:"Created", columns.push({id:"creation_date",name:"Created",
field:"creation_date",sortable:true}); field:"creation_date",sortable:true});
columns.push({id:'on_conflict',name:'',
field:'conflict',sortable:true,
resizable:false,width:24});
grid = new Slick.Grid("#myDocumentList", grid = new Slick.Grid("#myDocumentList",
document_list, document_list,
......
...@@ -228,21 +228,33 @@ ...@@ -228,21 +228,33 @@
revision: rev, revision: rev,
max_retry:3, max_retry:3,
success: function (result) { success: function (result) {
var doc = {
path:param.conflict_object.path,
content:result.content,
last_modified:result.last_modified,
creation_date:result.creation_date,
revision:rev
};
window.basic_conflict_solver. window.basic_conflict_solver.
conflict_object = conflict_object =
param.conflict_object; param.conflict_object;
window.basic_conflict_solver. window.basic_conflict_solver.
addRevision( addRevision(doc);
rev,result.content);
load(rev_list[i],i); load(rev_list[i],i);
}, },
error: function (error) { error: function (error) {
var doc = {
path:param.conflict_object.path,
last_modified:result.last_modified,
creation_date:result.creation_date,
revision:rev
};
window.basic_conflict_solver. window.basic_conflict_solver.
conflict_object = conflict_object =
param.conflict_object; param.conflict_object;
if (error.status === 404) { if (error.status === 404) {
window.basic_conflict_solver. window.basic_conflict_solver.
addRemovedRevision(rev); addRemovedRevision(doc);
} else { } else {
console.error (error.message); console.error (error.message);
} }
......
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