Parcourir la source

36 wip updateStateAfterTagAdded ready

Mao il y a 4 ans
Parent
commit
2fa5da518d

+ 6 - 0
packages/app/src/client/services/PageContainer.js

@@ -343,6 +343,12 @@ export default class PageContainer extends Container {
     }
   }
 
+  // TODO  : params
+  updateStateAfterTagAdded() {
+    console.log('params to get for updateStateTadAdded is...');
+    // this.setState();
+  }
+
   /**
    * save success handler
    * @param {object} page Page instance

+ 6 - 2
packages/app/src/components/Page/TagLabels.jsx

@@ -12,6 +12,7 @@ import EditorContainer from '~/client/services/EditorContainer';
 import RenderTagLabels from './RenderTagLabels';
 import TagEditModal from './TagEditModal';
 
+
 class TagLabels extends React.Component {
 
   constructor(props) {
@@ -57,8 +58,8 @@ class TagLabels extends React.Component {
     }
 
     try {
-      const { tags } = await appContainer.apiPost('/tags.update', { pageId, tags: newTags });
-
+      const { tags, updatedBy } = await appContainer.apiPost('/tags.update', { pageId, tags: newTags });
+      console.log(`tags object is :${tags} and ${updatedBy}`);
       // update pageContainer.state
       pageContainer.setState({ tags });
       // update editorContainer.state
@@ -69,6 +70,9 @@ class TagLabels extends React.Component {
     catch (err) {
       toastError(err, 'fail to update tags');
     }
+    pageContainer.updateStateAfterTagAdded();
+    // TODO あとで消す
+    console.log('Tag is added');
   }
 
 

+ 1 - 1
packages/app/src/server/routes/tag.js

@@ -147,7 +147,7 @@ module.exports = function(crowi, app) {
       const page = await Page.findById(pageId);
       await PageTagRelation.updatePageTags(pageId, tags);
       result.tags = await PageTagRelation.listTagNamesByPage(pageId);
-
+      result.updatedBy = 'this is string passed from api.update';
       tagEvent.emit('update', page, tags);
     }
     catch (err) {