diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-06-05 16:32:03 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-06-05 16:32:03 -0400 |
commit | 0a3fbdd128dd3b80868c93cb93901b501edf576c (patch) | |
tree | feff8120476bcc96f5c4c327ac66d0724fcfa2ac /view/tpl | |
parent | 4bc4fd5b7ebd7c5f25cfc9acfbda5b14a38dedb8 (diff) | |
download | volse-hubzilla-0a3fbdd128dd3b80868c93cb93901b501edf576c.tar.gz volse-hubzilla-0a3fbdd128dd3b80868c93cb93901b501edf576c.tar.bz2 volse-hubzilla-0a3fbdd128dd3b80868c93cb93901b501edf576c.zip |
Basic page reversion implemented. The revert button on the history view replaces the editor text but does not save the page.
Diffstat (limited to 'view/tpl')
-rw-r--r-- | view/tpl/wiki.tpl | 17 | ||||
-rw-r--r-- | view/tpl/wiki_page_history.tpl | 5 |
2 files changed, 20 insertions, 2 deletions
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index 6cdfabdb9..d9a490bf8 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -232,4 +232,21 @@ function wiki_delete_wiki(wikiHtmlName, resource_id) { }, 'json'); ev.preventDefault(); }); + + function wiki_revert_page(commitHash) { + if (window.wiki_resource_id === '' || window.wiki_page_name === '') { + window.console.log('You must have a wiki page open in order to revert pages.'); + return false; + } + $.post("wiki/{{$channel}}/revert/page", {commitHash: commitHash, name: window.wiki_page_name, resource_id: window.wiki_resource_id}, + function (data) { + if (data.success) { + window.console.log('Reverted content: ' + data.content); + // put contents in editor + editor.getSession().setValue(data.content); + } else { + window.console.log('Error reverting page.'); + } + }, 'json'); + } </script> diff --git a/view/tpl/wiki_page_history.tpl b/view/tpl/wiki_page_history.tpl index 7efc4aa96..b124d4cb5 100644 --- a/view/tpl/wiki_page_history.tpl +++ b/view/tpl/wiki_page_history.tpl @@ -1,8 +1,9 @@ <table class="table-striped table-responsive table-hover" style="width: 100%;"> {{foreach $pageHistory as $commit}} <tr><td> - <table> - <tr><td>Date</td><td>{{$commit.date}}</td></tr> + <table id="rev-{{$commit.hash}}" onclick="$('#details-{{$commit.hash}}').show()"> + <tr><td>Date</td><td>{{$commit.date}}</td><td rowspan="3""> + <button id="revert-{{$commit.hash}}" class="btn btn-warning btn-xs" onclick="wiki_revert_page('{{$commit.hash}}')">Revert</button></td></tr> <tr><td>Name</td><td>{{$commit.name}}</td></tr> <tr><td>Message</td><td>{{$commit.title}}</td></tr> </table> |