@@ -22,9 +22,18 @@ const ES_PROJECT_TYPE = config.get('elasticsearchConfig.docType');
22
22
// var permissions = require('tc-core-library-js').middleware.permissions
23
23
const permissions = tcMiddleware . permissions ;
24
24
const PROJECT_ATTRIBUTES = _ . without ( _ . keys ( models . Project . rawAttributes ) , 'utm' , 'deletedAt' ) ;
25
- const PROJECT_MEMBER_ATTRIBUTES = _ . without ( _ . keys ( models . ProjectMember . rawAttributes ) , 'deletedAt' ) ;
25
+ const PROJECT_MEMBER_ATTRIBUTES = _ . concat ( _ . without ( _ . keys ( models . ProjectMember . rawAttributes ) , 'deletedAt' ) ,
26
+ [ 'firstName' , 'lastName' , 'handle' , 'email' ] ) ;
26
27
const PROJECT_MEMBER_INVITE_ATTRIBUTES = _ . without ( _ . keys ( models . ProjectMemberInvite . rawAttributes ) , 'deletedAt' ) ;
27
28
const PROJECT_ATTACHMENT_ATTRIBUTES = _ . without ( _ . keys ( models . ProjectAttachment . rawAttributes ) , 'deletedAt' ) ;
29
+ const PROJECT_PHASE_ATTRIBUTES = _ . without (
30
+ _ . keys ( models . ProjectPhase . rawAttributes ) ,
31
+ 'deletedAt' ,
32
+ ) ;
33
+ const PROJECT_PHASE_PRODUCTS_ATTRIBUTES = _ . without (
34
+ _ . keys ( models . PhaseProduct . rawAttributes ) ,
35
+ 'deletedAt' ,
36
+ ) ;
28
37
29
38
/**
30
39
* Parse the ES search criteria and prepare search request body
@@ -52,13 +61,21 @@ const parseElasticSearchCriteria = (projectId, fields) => {
52
61
sourceInclude = sourceInclude . concat ( _ . map ( memberFields , single => `invites.${ single } ` ) ) ;
53
62
}
54
63
64
+ if ( _ . get ( fields , 'project_phases' , null ) ) {
65
+ const phaseFields = _ . get ( fields , 'project_phases' ) ;
66
+ sourceInclude = sourceInclude . concat ( _ . map ( phaseFields , single => `phases.${ single } ` ) ) ;
67
+ }
68
+ if ( _ . get ( fields , 'project_phases_products' , null ) ) {
69
+ const phaseFields = _ . get ( fields , 'project_phases_products' ) ;
70
+ sourceInclude = sourceInclude . concat ( _ . map ( phaseFields , single => `phases.products.${ single } ` ) ) ;
71
+ }
55
72
if ( _ . get ( fields , 'attachments' , null ) ) {
56
73
const attachmentFields = _ . get ( fields , 'attachments' ) ;
57
74
sourceInclude = sourceInclude . concat ( _ . map ( attachmentFields , single => `attachments.${ single } ` ) ) ;
58
75
}
59
76
60
77
if ( sourceInclude ) {
61
- searchCriteria . _sourceInclude = sourceInclude ; // eslint-disable-line no-underscore-dangle
78
+ searchCriteria . _sourceIncludes = sourceInclude ; // eslint-disable-line no-underscore-dangle
62
79
}
63
80
64
81
@@ -87,9 +104,14 @@ const retrieveProjectFromES = (projectId, req) => {
87
104
projects : PROJECT_ATTRIBUTES ,
88
105
project_members : PROJECT_MEMBER_ATTRIBUTES ,
89
106
project_member_invites : PROJECT_MEMBER_INVITE_ATTRIBUTES ,
107
+ project_phases : PROJECT_PHASE_ATTRIBUTES ,
108
+ project_phases_products : PROJECT_PHASE_PRODUCTS_ATTRIBUTES ,
90
109
attachments : PROJECT_ATTACHMENT_ATTRIBUTES ,
91
110
} ) ;
92
111
112
+ // if user is not admin, ignore email field for project_members
113
+ fields = util . ignoreEmailField ( req , fields ) ;
114
+
93
115
const searchCriteria = parseElasticSearchCriteria ( projectId , fields ) || { } ;
94
116
return new Promise ( ( accept , reject ) => {
95
117
const es = util . getElasticSearchClient ( ) ;
@@ -108,6 +130,7 @@ const retrieveProjectFromDB = (projectId, req) => {
108
130
projects : PROJECT_ATTRIBUTES ,
109
131
project_members : PROJECT_MEMBER_ATTRIBUTES ,
110
132
} ) ;
133
+
111
134
return models . Project
112
135
. findOne ( {
113
136
where : { id : projectId } ,
0 commit comments