Procházet zdrojové kódy

# Feature/196, 198, 199 Grouping users
* Fix get user related group logic.

Tatsuya Ise před 8 roky
rodič
revize
681cc5b860
2 změnil soubory, kde provedl 7 přidání a 6 odebrání
  1. 3 2
      lib/routes/page.js
  2. 4 4
      lib/views/_form.html

+ 3 - 2
lib/routes/page.js

@@ -231,7 +231,7 @@ module.exports = function(crowi, app) {
       author: false,
       author: false,
       pages: [],
       pages: [],
       tree: [],
       tree: [],
-      relatedUserGroups: [],
+      userRelatedGroups: [],
     };
     };
 
 
     var pageTeamplate = 'customlayout-selector/page';
     var pageTeamplate = 'customlayout-selector/page';
@@ -337,7 +337,8 @@ module.exports = function(crowi, app) {
       return UserGroupRelation.findAllRelationForUser(req.user);
       return UserGroupRelation.findAllRelationForUser(req.user);
     }).then(function (groupRelations) {
     }).then(function (groupRelations) {
       debug('findPage : relatedGroups ', groupRelations);
       debug('findPage : relatedGroups ', groupRelations);
-      renderVars.relatedUserGroups = groupRelations;
+      renderVars.userRelatedGroups = groupRelations.map(relation => relation.relatedGroup);
+      debug('findPage : groups ', renderVars.userRelatedGroups);
 
 
       return Promise.resolve();
       return Promise.resolve();
     });
     });

+ 4 - 4
lib/views/_form.html

@@ -50,14 +50,14 @@
         {% else %}
         {% else %}
         <select name="pageForm[grant]" class="form-control">
         <select name="pageForm[grant]" class="form-control">
           {% for grantId, grantLabel in consts.pageGrants %}
           {% for grantId, grantLabel in consts.pageGrants %}
-          <option value="{{ grantId }}" {% if pageForm.grant|default(page.grant) == grantId %}selected{% endif %} {% if grantId == 5 && relatedUserGroups.length == 0 %}disabled{% endif %}>{{ t(grantLabel) }}</option>
+          <option value="{{ grantId }}" {% if pageForm.grant|default(page.grant) == grantId %}selected{% endif %} {% if grantId == 5 && userRelatedGroups.length == 0 %}disabled{% endif %}>{{ t(grantLabel) }}</option>
           {% endfor %}
           {% endfor %}
         </select>
         </select>
         {% endif %}
         {% endif %}
-        {% if relatedUserGroups.length != 0 %}
+        {% if userRelatedGroups.length != 0 %}
         <select name="pageForm[grantUserGroupId]" class="form-control">
         <select name="pageForm[grantUserGroupId]" class="form-control">
-          {% for userGroupRelation in relatedUserGroups %}
-          <option value="{{ userGroupRelation.relatedGroup.id }}">{{ userGroupRelation.relatedGroup.name }}</option>
+          {% for userGroup in userRelatedGroups %}
+          <option value="{{ userGroup.id }}">{{ userGroup.name }}</option>
           {% endfor %}
           {% endfor %}
         </select>
         </select>
         {% endif %}
         {% endif %}