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

* Fix bug of group selector ReactComponent renderer.(WIP)

Tatsuya Ise 7 лет назад
Родитель
Сommit
81bf3fd1c6
1 измененных файлов с 10 добавлено и 9 удалено
  1. 10 9
      resource/js/app.js

+ 10 - 9
resource/js/app.js

@@ -181,14 +181,7 @@ if (pageEditorOptionsSelectorElem) {
   );
 }
 // render GrantSelector
-/*
- * Commented out temporary -- 2018.05.21 Yuki Takei
- *
- *  err: Uncaught TypeError: Cannot read property 'textContent' of null
- *
-const userRelatedGroups = JSON.parse(document.getElementById('user-related-group-data').textContent || '{}', (value) => {
-  return new UserGroup(value);
-});
+const userRelatedGroupsElem = document.getElementById('user-related-group-data');
 const pageEditorGrantSelectorElem = document.getElementById('page-grant-selector');
 const pageGrantElem = document.getElementById('page-grant');
 const pageGrantGroupElem = document.getElementById('grant-group');
@@ -197,6 +190,15 @@ function updatePageGrantElems(newPageGrant) {
   pageGrantGroupElem.value = newPageGrant.grantGroup.userGroupId || '';
 }
 if (pageEditorGrantSelectorElem) {
+  let userRelatedGroups = [];
+  if (userRelatedGroupsElem != null) {
+    let userRelatedGroupsJSON = JSON.parse(userRelatedGroupsElem.textContent || '{}')
+    if (userRelatedGroupsJSON != null && userRelatedGroupsJSON.length > 0) {
+      userRelatedGroups = userRelatedGroupsJSON.map((value) => {
+        return new UserGroup(value);
+      });
+    }
+  }
   pageGrant = new PageGrant();
   pageGrant.grant = document.getElementById('page-grant').value;
   const grantGroupData = JSON.parse(document.getElementById('grant-group').textContent || '{}');
@@ -213,7 +215,6 @@ if (pageEditorGrantSelectorElem) {
     pageEditorGrantSelectorElem
   );
 }
-*/
 
 // render for admin
 const customCssEditorElem = document.getElementById('custom-css-editor');