aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl/wiki_page_list.tpl
diff options
context:
space:
mode:
Diffstat (limited to 'view/tpl/wiki_page_list.tpl')
-rw-r--r--view/tpl/wiki_page_list.tpl53
1 files changed, 43 insertions, 10 deletions
diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl
index 723cd0904..ef2b41490 100644
--- a/view/tpl/wiki_page_list.tpl
+++ b/view/tpl/wiki_page_list.tpl
@@ -4,7 +4,12 @@
<ul class="nav nav-pills nav-stacked">
{{if $pages}}
{{foreach $pages as $page}}
- <li><a href="/wiki/{{$channel}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a></li>
+ <li id="{{$page.link_id}}">
+ {{if $page.resource_id && $canadd}}
+ <i class="widget-nav-pills-icons fa fa-trash-o drop-icons" onclick="wiki_delete_page('{{$page.title}}', '{{$page.url}}', '{{$page.resource_id}}', '{{$page.link_id}}')"></i>
+ {{/if}}
+ <a href="/wiki/{{$channel}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a>
+ </li>
{{/foreach}}
{{/if}}
{{if $canadd}}
@@ -24,19 +29,47 @@
<script>
$('#new-page-submit').click(function (ev) {
- if (window.wiki_resource_id === '') {
- window.console.log('You must have a wiki open in order to create pages.');
- ev.preventDefault();
- return false;
- }
$.post("wiki/{{$channel}}/create/page", {name: $('#id_pageName').val(), resource_id: window.wiki_resource_id},
- function (data) {
- if (data.success) {
- window.location = data.url;
+ function(data) {
+ if(data.success) {
+ window.location = data.url;
} else {
- window.console.log('Error creating page.');
+ window.console.log('Error creating page.');
}
}, 'json');
ev.preventDefault();
});
+
+ function wiki_delete_page(wiki_page_name, wiki_page_url, wiki_resource_id, wiki_link_id) {
+ if(!confirm('Are you sure you want to delete the page: ' + wiki_page_name)) {
+ return;
+ }
+ $.post("wiki/{{$channel}}/delete/page", {name: wiki_page_url, resource_id: wiki_resource_id},
+ function (data) {
+ if (data.success) {
+ window.console.log('Page deleted successfully.');
+ if(wiki_page_url == window.wiki_page_name) {
+ var url = window.location.href;
+ if(url.substr(-1) == '/')
+ url = url.substr(0, url.length - 2);
+ url = url.split('/');
+ url.pop();
+ window.location = url.join('/');
+ }
+ else {
+ $('#' + wiki_link_id).remove();
+ }
+ } else {
+ alert('Error deleting page.'); // TODO: Replace alerts with auto-timeout popups
+ window.console.log('Error deleting page.');
+ }
+ }, 'json');
+ return false;
+ }
+
+ function wiki_show_new_page_form() {
+ $('#new-page-form-wrapper').toggle();
+ $('#id_pageName').focus();
+ return false;
+ }
</script>