Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
45b7f7d0
Commit
45b7f7d0
authored
Jul 24, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding basic conflict solver to OfficeJS
parent
22e0d7cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
177 additions
and
4 deletions
+177
-4
OfficeJS/component/basic_conflict_solver.html
OfficeJS/component/basic_conflict_solver.html
+65
-0
OfficeJS/index.html
OfficeJS/index.html
+7
-0
OfficeJS/js/officejs.js
OfficeJS/js/officejs.js
+105
-4
No files found.
OfficeJS/component/basic_conflict_solver.html
0 → 100644
View file @
45b7f7d0
<div
id=
"basic_conflict_solver_div"
style=
"text-align:center;"
>
<div
class=
"row-fluid"
>
<div
class=
"span12"
>
A conflict occured while saving this document:
</div>
</div>
<div
class=
"row-fluid"
>
<div
class=
"span6"
>
<div>
<strong>
local revision
</strong>
</div>
<div>
<textarea
id=
"local_revision"
style=
"width:100%;"
>
loading...
</textarea>
</div>
<div>
<button
onclick=
"window.basic_conflict_solver.keepLocalRevision();"
>
keep this revision
</button>
</div>
</div>
<div
class=
"span6"
>
<div>
<strong>
conflicting revision
</strong>
</div>
<div>
<textarea
id=
"conflicting_revision"
style=
"width:100%;"
>
loading...
</textarea>
</div>
<div>
<button
onclick=
"window.basic_conflict_solver.keepOtherRevision();"
>
keep this revision
</button>
</div>
</div>
</div>
<div
class=
"row-fluid"
>
<div
class=
"span12"
>
<button>
Abort
</button>
</div>
</div>
</div>
<script
type=
"text/javascript"
>
<!--
window
.
basic_conflict_solver
=
{
conflict_object
:{},
keepLocalRevision
:
function
()
{
// TODO : keep local
OfficeJS
.
solveConflict
(
this
.
conflict_object
,
document
.
querySelector
(
'
#basic_conflict_solver_div
'
+
'
#local_revision
'
).
textContent
);
delete
window
.
basic_conflict_solver
;
},
keepOtherRevision
:
function
()
{
// TODO : keep other
OfficeJS
.
solveConflict
(
this
.
conflict_object
,
document
.
querySelector
(
'
#basic_conflict_solver_div
'
+
'
#local_revision
'
).
textContent
);
delete
window
.
basic_conflict_solver
;
}
};
//-->
</script>
OfficeJS/index.html
View file @
45b7f7d0
...
@@ -41,6 +41,13 @@
...
@@ -41,6 +41,13 @@
</div>
</div>
<!-- </div> -->
<!-- </div> -->
</div>
</div>
<div
class=
"row-fluid"
>
<div
class=
"span12"
>
<div
id=
"page-conflict"
>
</div>
</div>
</div>
</div>
</div>
<script
type=
"text/javascript"
src=
"js/officejs.js"
></script>
<script
type=
"text/javascript"
src=
"js/officejs.js"
></script>
...
...
OfficeJS/js/officejs.js
View file @
45b7f7d0
...
@@ -24,6 +24,11 @@
...
@@ -24,6 +24,11 @@
img_editor
:
'
svg-edit
'
,
img_editor
:
'
svg-edit
'
,
spreadsheet
:
'
jquery-sheet
'
spreadsheet
:
'
jquery-sheet
'
};
};
priv
.
conflict_solver_object
=
{
// ext: "solver_name"
// default: "basic_conflict_solver"
// ...
};
priv
.
app_object
=
{
priv
.
app_object
=
{
topnavbar
:
{
topnavbar
:
{
type
:
'
nav
'
,
type
:
'
nav
'
,
...
@@ -72,7 +77,7 @@
...
@@ -72,7 +77,7 @@
simplepreferenceeditor
:
{
simplepreferenceeditor
:
{
// NOTE
// NOTE
type
:
'
editor
'
,
type
:
'
editor
'
,
path
:
''
,
path
:
''
// ...
// ...
},
},
elrte
:
{
elrte
:
{
...
@@ -185,6 +190,35 @@
...
@@ -185,6 +190,35 @@
window
.
work_in_progress
.
stop
();
window
.
work_in_progress
.
stop
();
return
true
;
return
true
;
}
}
},
basic_conflict_solver
:
{
type
:
'
solver
'
,
path
:
'
component/basic_conflict_solver.html
'
,
gadget_id
:
'
page-conflict
'
,
onload
:
function
(
param
)
{
priv
.
jio
.
loadDocument
(
param
.
name
,
{
max_retry
:
3
,
onResponse
:
function
(
result
)
{
if
(
!
result
.
status
.
isDone
())
{
console
.
error
(
result
.
error
.
message
);
}
else
{
document
.
querySelector
(
'
#basic_conflict_solver_div
'
+
'
#conflicting_revision
'
).
textContent
=
result
.
value
.
content
;
}
}});
// TODO : add owner, revision, ...
setTimeout
(
function
()
{
window
.
basic_conflict_solver
.
conflict_object
=
param
.
conflict_object
;
document
.
querySelector
(
'
#basic_conflict_solver_div
'
+
'
#local_revision
'
).
textContent
=
param
.
local_content
;
},
500
);
}
}
}
};
};
priv
.
mime_object
=
{
priv
.
mime_object
=
{
...
@@ -206,6 +240,7 @@
...
@@ -206,6 +240,7 @@
gadget_object
:{},
// contains current gadgets id with their location
gadget_object
:{},
// contains current gadgets id with their location
currentFile
:
null
,
currentFile
:
null
,
currentEditor
:
null
,
currentEditor
:
null
,
currentSolver
:
null
,
currentApp
:
null
,
currentApp
:
null
,
currentActivity
:
null
currentActivity
:
null
};
};
...
@@ -288,13 +323,17 @@
...
@@ -288,13 +323,17 @@
*/
*/
that
.
open
=
function
(
option
)
{
that
.
open
=
function
(
option
)
{
var
realapp
,
realgadgetid
,
realpath
,
acientapp
;
var
realapp
,
realgadgetid
,
realpath
,
acientapp
;
if
(
!
option
)
{
console
.
error
(
'
open: This function needs a parameter
'
);
return
null
;
};
realapp
=
priv
.
getRealApplication
(
option
.
app
);
realapp
=
priv
.
getRealApplication
(
option
.
app
);
if
(
!
realapp
)
{
if
(
!
realapp
)
{
// cannot get real app
// cannot get real app
console
.
error
(
'
Unknown application:
'
+
option
.
app
);
console
.
error
(
'
Unknown application:
'
+
option
.
app
);
return
null
;
return
null
;
}
}
realgadgetid
=
realapp
.
gadget_id
;
realgadgetid
=
option
.
gadget_id
||
realapp
.
gadget_id
;
realpath
=
realapp
.
path
;
realpath
=
realapp
.
path
;
if
(
option
.
force
||
priv
.
data_object
.
currentEditor
!==
realapp
)
{
if
(
option
.
force
||
priv
.
data_object
.
currentEditor
!==
realapp
)
{
ancientapp
=
priv
.
data_object
.
gadget_object
[
realgadgetid
];
ancientapp
=
priv
.
data_object
.
gadget_object
[
realgadgetid
];
...
@@ -315,6 +354,9 @@
...
@@ -315,6 +354,9 @@
case
'
editor
'
:
case
'
editor
'
:
priv
.
data_object
.
currentEditor
=
realapp
;
priv
.
data_object
.
currentEditor
=
realapp
;
break
;
break
;
case
'
solver
'
:
priv
.
data_object
.
currentSolver
=
realapp
;
break
;
default
:
default
:
priv
.
data_object
.
currentEditor
=
null
;
priv
.
data_object
.
currentEditor
=
null
;
break
;
break
;
...
@@ -456,7 +498,8 @@
...
@@ -456,7 +498,8 @@
* @param {string} basename The document name without ext.
* @param {string} basename The document name without ext.
*/
*/
that
.
save
=
function
(
basename
)
{
that
.
save
=
function
(
basename
)
{
var
current_editor
=
priv
.
data_object
.
currentEditor
;
var
current_editor
=
priv
.
data_object
.
currentEditor
,
current_content
=
current_editor
.
getContent
();
if
(
!
priv
.
isJioSet
())
{
if
(
!
priv
.
isJioSet
())
{
console
.
error
(
'
No Jio set yet.
'
);
console
.
error
(
'
No Jio set yet.
'
);
return
;
return
;
...
@@ -464,7 +507,7 @@
...
@@ -464,7 +507,7 @@
priv
.
loading_object
.
save
();
priv
.
loading_object
.
save
();
priv
.
jio
.
saveDocument
(
priv
.
jio
.
saveDocument
(
basename
+
'
.
'
+
current_editor
.
ext
,
basename
+
'
.
'
+
current_editor
.
ext
,
current_
editor
.
getContent
()
,
current_
content
,
{
onResponse
:
function
(
result
)
{
{
onResponse
:
function
(
result
)
{
if
(
!
result
.
status
.
isDone
())
{
if
(
!
result
.
status
.
isDone
())
{
priv
.
lastfailure
.
path
=
basename
;
priv
.
lastfailure
.
path
=
basename
;
...
@@ -473,6 +516,13 @@
...
@@ -473,6 +516,13 @@
}
}
priv
.
loading_object
.
end_save
();
priv
.
loading_object
.
end_save
();
that
.
getList
();
that
.
getList
();
},
onConflict
:
function
(
conflict_object
)
{
priv
.
onConflict
({
name
:
basename
,
content
:
current_content
},
current_editor
.
ext
,
conflict_object
);
// TODO : same for remove method
}});
}});
};
};
...
@@ -561,6 +611,57 @@
...
@@ -561,6 +611,57 @@
}
}
};
};
/**
* Called when there is conflict
* @method onConflict
* @param {object} doc The document object
* @param {object} conflict_object The conflict object
*/
priv
.
onConflict
=
function
(
document
,
ext
,
conflict_object
)
{
ext
=
ext
||
''
;
// TODO : load other revision
// get the good conflict solver and load it
if
(
ext
&&
priv
.
conflict_solver_object
[
ext
])
{
that
.
open
({
app
:
priv
.
conflict_solver_object
[
ext
],
name
:
conflict_object
.
path
,
local_content
:
document
.
content
,
conflict_object
:
conflict_object
});
}
else
{
that
.
open
({
app
:
'
basic_conflict_solver
'
,
name
:
conflict_object
.
path
,
local_content
:
document
.
content
,
conflict_object
:
conflict_object
});
}
};
that
.
solveConflict
=
function
(
conflict_object
,
data
)
{
var
current_solver
=
priv
.
data_object
.
currentSolver
;
priv
.
loading_object
.
save
();
priv
.
jio
.
saveDocument
(
conflict_object
.
path
,
data
,
{
onResponse
:
function
(
result
)
{
if
(
!
result
.
status
.
isDone
())
{
priv
.
lastfailure
.
path
=
basename
(
path
);
priv
.
lastfailure
.
method
=
'
saveDocument
'
;
console
.
error
(
result
.
error
.
message
);
}
priv
.
loading_object
.
end_save
();
that
.
getList
();
document
.
querySelector
(
'
#basic_conflict_solver_div
'
).
style
.
display
=
'
none
'
;
priv
.
data_object
.
currentSolver
=
null
;
},
onConflict
:
function
(
conflict_object
)
{
priv
.
onConflict
({
name
:
basename
,
content
:
current_content
},
current_editor
.
ext
,
conflict_object
);
},
known_conflict_list
:[
conflict_object
]});
};
/**
/**
* Get current activity.
* Get current activity.
* @method getActivity
* @method getActivity
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment