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

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

Tatsuya Ise 8 лет назад
Родитель
Сommit
23d4a57047
3 измененных файлов с 10 добавлено и 5 удалено
  1. 2 1
      lib/views/layout/layout.html
  2. 2 2
      resource/js/app.js
  3. 6 2
      resource/js/components/SearchPage/SearchResult.js

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

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

+ 2 - 2
resource/js/app.js

@@ -39,8 +39,8 @@ if (mainContent !== null) {
 
 
 // FIXME
 // FIXME
 const crowi = new Crowi({
 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);
 window.crowi = crowi;
 window.crowi = crowi;
 crowi.setConfig(JSON.parse(document.getElementById('crowi-context-hydrate').textContent || '{}'));
 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;
     let isDeleteComplete = true;
     Array.from(this.state.selectedPages).map((page) => {
     Array.from(this.state.selectedPages).map((page) => {
       const pageId = page._id;
       const pageId = page._id;
-      const revisionId = page.revision_id;
+      const revisionId = page.revision._id;
       this.props.crowi.apiPost('/pages.remove',
       this.props.crowi.apiPost('/pages.remove',
-        {page_id: pageId, revision_id: page.revisionId})
+        {page_id: pageId, revision_id: revisionId})
       .then(res => {
       .then(res => {
         if (res.ok) {
         if (res.ok) {
           this.state.selectedPages.delete(page);
           this.state.selectedPages.delete(page);
         }
         }
+        else {
+          isDeleteComplete = false;
+        }
       }).catch(err => {
       }).catch(err => {
         console.log(err.message);
         console.log(err.message);
         isDeleteComplete = false;
         isDeleteComplete = false;
         this.setState({errorMessageForDeleting: err.message});
         this.setState({errorMessageForDeleting: err.message});
       });
       });
     });
     });
+
     if ( isDeleteComplete ) {
     if ( isDeleteComplete ) {
       this.closeDeleteConfirmModal();
       this.closeDeleteConfirmModal();
     }
     }