summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/js
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-05-17 02:16:33 +0200
committerRobin Appelman <icewind@owncloud.com>2012-05-17 02:16:33 +0200
commitbfdb374a2c8287b4dea80696928d27aef96fa343 (patch)
tree492824ad438bba1e5677efea4a74b60e486655e0 /apps/files_versions/js
parent4ccfd27fa233ca737dbd10f65d680ed853e7efcf (diff)
downloadnextcloud-server-bfdb374a2c8287b4dea80696928d27aef96fa343.tar.gz
nextcloud-server-bfdb374a2c8287b4dea80696928d27aef96fa343.zip
allow reverting file from history dropdown
Diffstat (limited to 'apps/files_versions/js')
-rw-r--r--apps/files_versions/js/versions.js31
1 files changed, 18 insertions, 13 deletions
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js
index eadf7a51039..61090f956f0 100644
--- a/apps/files_versions/js/versions.js
+++ b/apps/files_versions/js/versions.js
@@ -34,7 +34,7 @@ function createVersionsDropdown(filename, files) {
html += '</select>';
html += '</div>';
//html += '<input type="button" value="Revert file" onclick="revertFile()" />';
- html += '<input type="button" value="Revert file..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
+ html += '<input type="button" value="All versions..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
html += '<br />';
html += '<input id="link" style="display:none; width:90%;" />';
@@ -47,7 +47,7 @@ function createVersionsDropdown(filename, files) {
$.ajax({
type: 'GET',
- url: OC.linkTo('files_versions', 'ajax/getVersions.php'),
+ url: OC.filePath('files_versions', 'ajax', 'getVersions.php'),
dataType: 'json',
data: { source: files },
async: false,
@@ -58,34 +58,39 @@ function createVersionsDropdown(filename, files) {
if (versions) {
$.each( versions, function(index, row ) {
-
- addVersion( row );
+ addVersion( row );
});
}
-
+ $('#found_versions').change(function(){
+ var revision=parseInt($(this).val());
+ revertFile(files,revision);
+ })
}
});
- function revertFile() {
+ function revertFile(file, revision) {
$.ajax({
type: 'GET',
url: OC.linkTo('files_versions', 'ajax/rollbackVersion.php'),
dataType: 'json',
- data: {path: file, revision: 'revision'},
+ data: {file: file, revision: revision},
async: false,
- success: function(versions) {
- if (versions) {
+ success: function(response) {
+ if (response.status=='error') {
+ OC.dialogs.alert('Failed to revert '+file+' to revision '+formatDate(revision*1000)+'.','Failed to revert');
}
}
});
}
- function addVersion( name ) {
-
- var version = '<option>'+name+'</option>';
+ function addVersion(revision ) {
+ name=formatDate(revision*1000);
+ var version=$('<option/>');
+ version.attr('value',revision);
+ version.text(name);
// } else {
// var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"');
@@ -98,7 +103,7 @@ function createVersionsDropdown(filename, files) {
// user += '</li>';
// }
- $(version).appendTo('#found_versions');
+ version.appendTo('#found_versions');
}
$('#dropdown').show('blind');