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

unset isContainerFluid if the specified value is the same to the system's one

Yuki Takei 3 лет назад
Родитель
Сommit
a3695a29ae
1 измененных файлов с 9 добавлено и 2 удалено
  1. 9 2
      packages/app/src/server/routes/apiv3/page.js

+ 9 - 2
packages/app/src/server/routes/apiv3/page.js

@@ -165,8 +165,9 @@ module.exports = (crowi) => {
   const certifySharedPage = require('../../middlewares/certify-shared-page')(crowi);
   const addActivity = generateAddActivityMiddleware(crowi);
 
+  const configManager = crowi.configManager;
+
   const globalNotificationService = crowi.getGlobalNotificationService();
-  const socketIoService = crowi.socketIoService;
   const { Page, GlobalNotificationSetting, Bookmark } = crowi.models;
   const { pageService, exportService } = crowi;
 
@@ -825,8 +826,14 @@ module.exports = (crowi) => {
       const { pageId } = req.params;
       const { isContainerFluid } = req.body;
 
+      const isContainerFluidBySystem = configManager.getConfig('crowi', 'customize:isContainerFluid');
+
       try {
-        const page = await Page.updateOne({ _id: pageId }, { $set: { isContainerFluid } });
+        const updateQuery = isContainerFluid === isContainerFluidBySystem
+          ? { $unset: { isContainerFluid } } // remove if the specified value is the same to the system's one
+          : { $set: { isContainerFluid } };
+
+        const page = await Page.updateOne({ _id: pageId }, updateQuery);
         return res.apiv3({ page });
       }
       catch (err) {