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

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

Tatsuya Ise 8 лет назад
Родитель
Сommit
681cc5b860
2 измененных файлов с 7 добавлено и 6 удалено
  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,
       pages: [],
       tree: [],
-      relatedUserGroups: [],
+      userRelatedGroups: [],
     };
 
     var pageTeamplate = 'customlayout-selector/page';
@@ -337,7 +337,8 @@ module.exports = function(crowi, app) {
       return UserGroupRelation.findAllRelationForUser(req.user);
     }).then(function (groupRelations) {
       debug('findPage : relatedGroups ', groupRelations);
-      renderVars.relatedUserGroups = groupRelations;
+      renderVars.userRelatedGroups = groupRelations.map(relation => relation.relatedGroup);
+      debug('findPage : groups ', renderVars.userRelatedGroups);
 
       return Promise.resolve();
     });

+ 4 - 4
lib/views/_form.html

@@ -50,14 +50,14 @@
         {% else %}
         <select name="pageForm[grant]" class="form-control">
           {% 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 %}
         </select>
         {% endif %}
-        {% if relatedUserGroups.length != 0 %}
+        {% if userRelatedGroups.length != 0 %}
         <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 %}
         </select>
         {% endif %}