Procházet zdrojové kódy

move boolean to pageContainer and use it in crowi.js file

kaori před 5 roky
rodič
revize
9f7b98bd62

+ 2 - 5
src/client/js/legacy/crowi.js

@@ -201,16 +201,13 @@ $(() => {
 
 
 window.addEventListener('load', (e) => {
 window.addEventListener('load', (e) => {
   const { appContainer, pageContainer } = window;
   const { appContainer, pageContainer } = window;
-  const { currentUser } = appContainer;
-  const {
-    isPageExist, isPageForbidden, isNotCreatable, isTrashPage,
-  } = pageContainer.state;
+  const isEditableMode = pageContainer;
 
 
   // hash on page
   // hash on page
   if (window.location.hash) {
   if (window.location.hash) {
     const navigationContainer = appContainer.getContainer('NavigationContainer');
     const navigationContainer = appContainer.getContainer('NavigationContainer');
 
 
-    if (window.location.hash === '#edit' && isPageExist && (currentUser != null) && !isPageForbidden && !isNotCreatable && !isTrashPage) {
+    if (window.location.hash === '#edit' && isEditableMode) {
       navigationContainer.setEditorMode('edit');
       navigationContainer.setEditorMode('edit');
 
 
       // focus
       // focus

+ 12 - 0
src/client/js/services/PageContainer.js

@@ -133,6 +133,18 @@ export default class PageContainer extends Container {
     return 'PageContainer';
     return 'PageContainer';
   }
   }
 
 
+  isEditableMode() {
+    const { appContainer } = window;
+    const { currentUser } = appContainer;
+    const {
+      isPageExist, isPageForbidden, isNotCreatable, isTrashPage,
+    } = this.state;
+
+    if (isPageExist && (currentUser != null) && !isPageForbidden && !isNotCreatable && !isTrashPage) {
+      return true;
+    }
+  }
+
   /**
   /**
    * initialize state for markdown data
    * initialize state for markdown data
    */
    */