Yuki Takei 9 лет назад
Родитель
Сommit
7262e9b32e
2 измененных файлов с 33 добавлено и 2 удалено
  1. 15 2
      lib/views/page.html
  2. 18 0
      resource/js/legacy/crowi.js

+ 15 - 2
lib/views/page.html

@@ -151,8 +151,21 @@
 
 
   <div class="tab-content wiki-content">
   <div class="tab-content wiki-content">
   {% if req.query.renamed and not page.isDeleted() %}
   {% if req.query.renamed and not page.isDeleted() %}
-  <div class="alert alert-info">
-    <strong>{{ t('Moved') }}: </strong> {{ t('page_page.notice.moved', req.query.renamed) }}
+  <div class="alert alert-info alert-moved">
+    <div>
+      <form role="form" id="unlink-page-form" onsubmit="return false;">
+        <input type="hidden" name="_csrf" value="{{ csrf() }}">
+        <input type="hidden" name="path" value="{{ page.path }}">
+        <input type="hidden" name="page_id" value="{{ page._id.toString() }}">
+        <button type="submit" class="btn btn-default btn-sm pull-right">
+          <i class="fa fa-unlink" aria-hidden="true"></i>
+          Unlink
+        </button>
+      </form>
+      <span>
+        <strong>{{ t('Moved') }}: </strong> {{ t('page_page.notice.moved', req.query.renamed) }}
+      </span>
+    </div>
   </div>
   </div>
   {% endif %}
   {% endif %}
   {% if not page.isLatestRevision() %}
   {% if not page.isLatestRevision() %}

+ 18 - 0
resource/js/legacy/crowi.js

@@ -294,6 +294,24 @@ $(function() {
 
 
     return false;
     return false;
   });
   });
+  $('#unlink-page-form').submit(function(e) {
+    $.ajax({
+      type: 'POST',
+      url: '/_api/pages.unlink',
+      data: $('#unlink-page-form').serialize(),
+      dataType: 'json'
+    }).done(function(res) {
+      if (!res.ok) {
+        $('#delete-errors').html('<i class="fa fa-times-circle"></i> ' + res.error);
+        $('#delete-errors').addClass('alert-danger');
+      } else {
+        var page = res.page;
+        top.location.href = page.path;
+      }
+    });
+
+    return false;
+  });
 
 
   $('#create-portal-button').on('click', function(e) {
   $('#create-portal-button').on('click', function(e) {
     $('.portal').removeClass('hide');
     $('.portal').removeClass('hide');