|
@@ -692,48 +692,37 @@ module.exports = function(crowi, app) {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// グループ詳細
|
|
// グループ詳細
|
|
|
- actions.userGroup.detail = function(req, res) {
|
|
|
|
|
|
|
+ actions.userGroup.detail = async function(req, res) {
|
|
|
const userGroupId = req.params.id;
|
|
const userGroupId = req.params.id;
|
|
|
const renderVar = {
|
|
const renderVar = {
|
|
|
userGroup: null,
|
|
userGroup: null,
|
|
|
userGroupRelations: [],
|
|
userGroupRelations: [],
|
|
|
- pageGroupRelations: [],
|
|
|
|
|
- notRelatedusers: []
|
|
|
|
|
|
|
+ notRelatedusers: [],
|
|
|
|
|
+ relatedPages: [],
|
|
|
};
|
|
};
|
|
|
- let targetUserGroup = null;
|
|
|
|
|
- UserGroup.findOne({ _id: userGroupId})
|
|
|
|
|
- .then(function(userGroup) {
|
|
|
|
|
- targetUserGroup = userGroup;
|
|
|
|
|
- if (targetUserGroup == null) {
|
|
|
|
|
- req.flash('errorMessage', 'グループがありません');
|
|
|
|
|
- throw new Error('no userGroup is exists. ', name);
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- renderVar.userGroup = targetUserGroup;
|
|
|
|
|
-
|
|
|
|
|
- return Promise.all([
|
|
|
|
|
- // get all user and group relations
|
|
|
|
|
- UserGroupRelation.findAllRelationForUserGroup(targetUserGroup),
|
|
|
|
|
- // get all page and group relations
|
|
|
|
|
- PageGroupRelation.findAllRelationForUserGroup(targetUserGroup),
|
|
|
|
|
- // get all not related users for group
|
|
|
|
|
- UserGroupRelation.findUserByNotRelatedGroup(targetUserGroup),
|
|
|
|
|
- ]);
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .then((resolves) => {
|
|
|
|
|
- renderVar.userGroupRelations = resolves[0];
|
|
|
|
|
- renderVar.pageGroupRelations = resolves[1];
|
|
|
|
|
- renderVar.notRelatedusers = resolves[2];
|
|
|
|
|
- debug('notRelatedusers', renderVar.notRelatedusers);
|
|
|
|
|
|
|
|
|
|
- return res.render('admin/user-group-detail', renderVar);
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {
|
|
|
|
|
- req.flash('errorMessage', 'ユーザグループの検索に失敗しました');
|
|
|
|
|
- debug('Error on get userGroupDetail', err);
|
|
|
|
|
- return res.redirect('/admin/user-groups');
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const userGroup = await UserGroup.findOne({ _id: userGroupId});
|
|
|
|
|
+
|
|
|
|
|
+ if (userGroup == null) {
|
|
|
|
|
+ logger.error('no userGroup is exists. ', userGroupId);
|
|
|
|
|
+ req.flash('errorMessage', 'グループがありません');
|
|
|
|
|
+ return res.redirect('/admin/user-groups');
|
|
|
|
|
+ }
|
|
|
|
|
+ renderVar.userGroup = userGroup;
|
|
|
|
|
+
|
|
|
|
|
+ const resolves = await Promise.all([
|
|
|
|
|
+ // get all user and group relations
|
|
|
|
|
+ UserGroupRelation.findAllRelationForUserGroup(userGroup),
|
|
|
|
|
+ // get all not related users for group
|
|
|
|
|
+ UserGroupRelation.findUserByNotRelatedGroup(userGroup),
|
|
|
|
|
+ // get all related pages
|
|
|
|
|
+ Page.find({grant: Page.GRANT_USER_GROUP, grantedGroup: { $in: [userGroup] }}),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ renderVar.userGroupRelations = resolves[0];
|
|
|
|
|
+ renderVar.notRelatedusers = resolves[1];
|
|
|
|
|
+ renderVar.relatedPages = resolves[2];
|
|
|
|
|
+
|
|
|
|
|
+ return res.render('admin/user-group-detail', renderVar);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
//グループの生成
|
|
//グループの生成
|