Răsfoiți Sursa

Merge pull request #2070 from weseek/feat/add-empty-trash-btn

Feat/add empty trash btn
itizawa 6 ani în urmă
părinte
comite
ac9aef1b0f

+ 3 - 0
resource/locales/en-US/translation.json

@@ -275,6 +275,9 @@
     "recursively": "Delete children of under <code>%s</code> recursively.",
     "completely": "Delete completely instead of putting it into trash."
   },
+  "modal_empty":{
+    "empty_the_trash": "Empty The Trash"
+  },
   "modal_duplicate": {
     "label": {
       "Duplicate page": "Duplicate page",

+ 3 - 0
resource/locales/ja/translation.json

@@ -273,6 +273,9 @@
     "recursively": "<code>%s</code> 配下のページも削除します",
     "completely": "ゴミ箱を経由せず、完全に削除します"
   },
+  "modal_empty":{
+    "empty_the_trash": "ゴミ箱を空にする"
+  },
   "modal_duplicate": {
     "label": {
       "Duplicate page": "ページを複製する",

+ 5 - 1
src/client/js/legacy/crowi.js

@@ -135,7 +135,7 @@ Crowi.initAffix = () => {
       $elm.removeData('affix').removeClass('affix affix-top affix-bottom');
       return false;
     });
-    $affixContentContainer.css({ 'min-height': containerHeight });
+    $affixContentContainer.css({ minHeight: containerHeight });
   }
 };
 
@@ -359,6 +359,10 @@ $(() => {
     return false;
   });
 
+  // empty trash
+  $('#empty-trash-form').submit((e) => {
+    // TODO GW-2060 create api
+  });
   // delete
   $('#deletePage').on('shown.bs.modal', (e) => {
     $('#deletePage .msg').hide();

+ 46 - 0
src/server/views/modal/empty_trash.html

@@ -0,0 +1,46 @@
+<div class="modal" id="emptyTrash">
+  <div class="modal-dialog">
+    <div class="modal-content">
+
+    <form role="form" id="empty-trash-form" onsubmit="return false;">
+
+      <div class="modal-header bg-danger">
+        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+        <div class="modal-title">
+          <i class="icon-fw icon-trash"></i>  {{ t('modal_empty.empty_the_trash') }}
+        </div>
+      </div>
+      <div class="modal-body">
+        <ul>
+          {% for data in pages %}
+            {% if pagePropertyName %}
+              {% set page = data[pagePropertyName] %}
+            {% else %}
+              {% set page = data %}
+            {% endif %}
+            <li>
+              <img src="{{ page.lastUpdateUser|picture }}" class="picture img-circle">
+              <a href="{{ page.path }}"
+                class="page-list-link"
+                data-path="{{ page.path }}">{{ decodeURIComponent(page.path) }}
+              </a>
+            </li>
+          {% endfor %}
+        </ul>
+      </div>
+      <div class="modal-footer">
+        <div class="d-flex justify-content-end">
+          <div>
+            <input type="hidden" name="_csrf" value="{{ csrf() }}">
+            <button type="submit" class="m-l-10 btn btn-danger delete-button">
+              <i class="icon-trash" aria-hidden="true"></i>
+              Empty
+            </button>
+          </div>
+        </div>
+      </div><!-- /.modal-footer -->
+
+    </form>
+    </div><!-- /.modal-content -->
+  </div><!-- /.modal-dialog -->
+</div><!-- /.modal -->

+ 7 - 2
src/server/views/widget/page_alerts.html

@@ -88,16 +88,21 @@
         <br>Deleted by <img src="{{ page.lastUpdateUser|picture }}" class="picture picture-sm img-circle"> {{ page.lastUpdateUser.name }} at {{ page.updatedAt|datetz('Y-m-d H:i:s') }}
         {% endif %}
       </div>
-      {% if page.isDeleted() and user %}
       <ul class="list-inline">
+        {% if user and user.admin and req.path == '/trash' %}
+        <li>
+          <button href="#" class="btn btn-danger btn-rounded btn-sm" data-target="#emptyTrash" data-toggle="modal"><i class="icon-trash" aria-hidden="true"></i>{{ t('modal_empty.empty_the_trash') }}</button>
+        </li>
+        {% endif %}
+        {% if page.isDeleted() and user %}
         <li>
           <button href="#" class="btn btn-default btn-rounded btn-sm" data-target="#putBackPage" data-toggle="modal"><i class="icon-action-undo" aria-hidden="true"></i> {{ t('Put Back') }}</button>
         </li>
         <li>
             <button href="#" class="btn btn-danger btn-rounded btn-sm" {% if !user.canDeleteCompletely(page.creator._id) %} disabled="disabled" {% endif %} data-target="#deletePage" data-toggle="modal"><i class="icon-fire" aria-hidden="true"></i> {{ t('Delete Completely') }}</button>
         </li>
+        {% endif %}
       </ul>{# /.pull-right #}
-      {% endif %}
     </div>
     {% endif %}
   </div>

+ 1 - 0
src/server/views/widget/page_modals.html

@@ -1,4 +1,5 @@
 {% include '../modal/rename.html' %}
+{% include '../modal/empty_trash.html' %}
 {% include '../modal/delete.html' %}
 {% include '../modal/create_template.html' %}
 {% include '../modal/duplicate.html' %}