Просмотр исходного кода

Implv/125 Selective batch deletion in search result page
* Fix the problem of "page deletion execution API".

Tatsuya Ise 8 лет назад
Родитель
Сommit
23d4a57047

+ 2 - 1
lib/views/layout/layout.html

@@ -65,11 +65,12 @@
 {% endblock %}
 
 {% block html_body %}
-<body
+<body id="main-container"
   class="crowi main-container {% block html_base_css %}{% endblock %} {% if 'crowi-plus' === layoutType() %}crowi-plus{% endif %}"
   data-me="{{ user._id.toString() }}"
   data-plugin-enabled="{{ isEnabledPlugins() }}"
  {% block html_base_attr %}{% endblock %}
+  data-csrftoken="{{ csrf() }}"
  >
 
 {% block layout_head_nav %}

+ 2 - 2
resource/js/app.js

@@ -39,8 +39,8 @@ if (mainContent !== null) {
 
 // FIXME
 const crowi = new Crowi({
-  me: $('#content-main').data('current-username'),
-  csrfToken: $('#content-main').data('csrftoken'),
+  me: $('#main-container').data('current-username'),
+  csrfToken: $('#main-container').data('csrftoken'),
 }, window);
 window.crowi = crowi;
 crowi.setConfig(JSON.parse(document.getElementById('crowi-context-hydrate').textContent || '{}'));

+ 6 - 2
resource/js/components/SearchPage/SearchResult.js

@@ -68,19 +68,23 @@ export default class SearchResult extends React.Component {
     let isDeleteComplete = true;
     Array.from(this.state.selectedPages).map((page) => {
       const pageId = page._id;
-      const revisionId = page.revision_id;
+      const revisionId = page.revision._id;
       this.props.crowi.apiPost('/pages.remove',
-        {page_id: pageId, revision_id: page.revisionId})
+        {page_id: pageId, revision_id: revisionId})
       .then(res => {
         if (res.ok) {
           this.state.selectedPages.delete(page);
         }
+        else {
+          isDeleteComplete = false;
+        }
       }).catch(err => {
         console.log(err.message);
         isDeleteComplete = false;
         this.setState({errorMessageForDeleting: err.message});
       });
     });
+
     if ( isDeleteComplete ) {
       this.closeDeleteConfirmModal();
     }