Przeglądaj źródła

36 wip user_id needs to be passed

Mao 4 lat temu
rodzic
commit
33ae4f043c

+ 4 - 3
packages/app/src/components/Page/TagLabels.jsx

@@ -49,15 +49,16 @@ class TagLabels extends React.Component {
       appContainer, editorContainer, pageContainer, editorMode,
     } = this.props;
 
-    const { pageId } = pageContainer.state;
-
+    const { pageId, revisionId } = pageContainer.state;
     // It will not be reflected in the DB until the page is refreshed
     if (editorMode === 'edit') {
       return editorContainer.setState({ tags: newTags });
     }
 
     try {
-      const { tags } = await appContainer.apiPost('/tags.update', { pageId, tags: newTags });
+      const { tags } = await appContainer.apiPost('/tags.update', {
+        pageId, tags: newTags, revisionId,
+      });
 
       // update pageContainer.state
       pageContainer.setState({ tags });

+ 11 - 0
packages/app/src/server/routes/tag.js

@@ -135,16 +135,27 @@ module.exports = function(crowi, app) {
    * @apiParam {array} tags
    */
   api.update = async function(req, res) {
+    // GW36 tag update feature problem (when adding/removing tags, page's updatedAt does not get updated)
+    // Idea : call Page.updatePage to update 'updatedAt' when tag is added/removed
+    // ref: api.update in pages.js router
     const Page = crowi.model('Page');
     const PageTagRelation = crowi.model('PageTagRelation');
+    const Revision = crowi.model('Revision');
+    const User = crowi.model('User');
     const tagEvent = crowi.event('tag');
     const pageId = req.body.pageId;
     const tags = req.body.tags;
+    const revisionId = req.body.revisionId;
 
     const result = {};
     try {
       // TODO GC-1921 consider permission
+      // do Page.updatePage
       const page = await Page.findById(pageId);
+      const previousRevision = await Revision.findById(revisionId);
+      // no difference than before, just updating page to have pages 'updatedAt' updated
+      const user = await User.findById('613eda3717b2d80c4874dfb7');
+      await Page.updatePage(page, previousRevision.body, previousRevision.body, user, {});
       await PageTagRelation.updatePageTags(pageId, tags);
       result.tags = await PageTagRelation.listTagNamesByPage(pageId);