@things-factory/organization 6.0.6 → 6.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/model/contact.ts +0 -2
- package/client/pages/employee/employee-list-page.ts +7 -11
- package/dist-client/model/contact.d.ts +0 -2
- package/dist-client/model/contact.js.map +1 -1
- package/dist-client/pages/employee/employee-list-page.d.ts +2 -2
- package/dist-client/pages/employee/employee-list-page.js +4 -8
- package/dist-client/pages/employee/employee-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/employee/employee-query.js +22 -24
- package/dist-server/service/employee/employee-query.js.map +1 -1
- package/dist-server/service/employee/employee-type.js +4 -0
- package/dist-server/service/employee/employee-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/service/employee/employee-query.ts +20 -21
- package/server/service/employee/employee-type.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/organization",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.8",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@operato/data-tree": "^1.0.0",
|
|
31
31
|
"@operato/graphql": "^1.0.0",
|
|
32
32
|
"@operato/shell": "^1.0.0",
|
|
33
|
-
"@things-factory/auth-base": "^6.0.
|
|
34
|
-
"@things-factory/contact": "^6.0.
|
|
35
|
-
"@things-factory/shell": "^6.0.
|
|
33
|
+
"@things-factory/auth-base": "^6.0.7",
|
|
34
|
+
"@things-factory/contact": "^6.0.8",
|
|
35
|
+
"@things-factory/shell": "^6.0.7"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "c883904927d790f21f9e821ddbb4b74be370040e"
|
|
38
38
|
}
|
|
@@ -7,6 +7,17 @@ import { Employee } from './employee'
|
|
|
7
7
|
import { EmployeeList } from './employee-type'
|
|
8
8
|
import { Department } from '../department/department'
|
|
9
9
|
|
|
10
|
+
async function getContactItem(contactId: String, type: String, label: String, context: ResolverContext) {
|
|
11
|
+
const { domain } = context.state
|
|
12
|
+
const contact: Contact = await getRepository(Contact).findOne({ where: { domain: { id: domain.id }, id: contactId } })
|
|
13
|
+
const { items } = contact
|
|
14
|
+
|
|
15
|
+
if (!items || !(items instanceof Array)) {
|
|
16
|
+
return ''
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return items?.find(item => item.type === type && item.label === label)?.value || ''
|
|
20
|
+
}
|
|
10
21
|
@Resolver(Employee)
|
|
11
22
|
export class EmployeeQuery {
|
|
12
23
|
@Query(returns => Employee!, { nullable: true, description: 'To fetch a Employee' })
|
|
@@ -48,42 +59,30 @@ export class EmployeeQuery {
|
|
|
48
59
|
}
|
|
49
60
|
|
|
50
61
|
@FieldResolver(type => String)
|
|
51
|
-
async phone(@Root() employee: Employee): Promise<string> {
|
|
62
|
+
async phone(@Root() employee: Employee, @Ctx() context: ResolverContext): Promise<string> {
|
|
52
63
|
if (!employee.contactId) {
|
|
53
64
|
return
|
|
54
65
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
type: ContactField.Phone,
|
|
58
|
-
label: 'work'
|
|
59
|
-
})) as any
|
|
60
|
-
return phone?.value
|
|
66
|
+
|
|
67
|
+
await getContactItem(employee.contactId, ContactField.Phone, 'work', context)
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
@FieldResolver(type => String)
|
|
64
|
-
async address(@Root() employee: Employee): Promise<string> {
|
|
71
|
+
async address(@Root() employee: Employee, @Ctx() context: ResolverContext): Promise<string> {
|
|
65
72
|
if (!employee.contactId) {
|
|
66
73
|
return
|
|
67
74
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
type: ContactField.Address,
|
|
71
|
-
label: 'work'
|
|
72
|
-
})) as any
|
|
73
|
-
return address?.value
|
|
75
|
+
|
|
76
|
+
await getContactItem(employee.contactId, ContactField.Address, 'work', context)
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
@FieldResolver(type => String)
|
|
77
|
-
async email(@Root() employee: Employee): Promise<string> {
|
|
80
|
+
async email(@Root() employee: Employee, @Ctx() context: ResolverContext): Promise<string> {
|
|
78
81
|
if (!employee.contactId) {
|
|
79
82
|
return
|
|
80
83
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
type: ContactField.Email,
|
|
84
|
-
label: 'work'
|
|
85
|
-
})) as any
|
|
86
|
-
return email?.value
|
|
84
|
+
|
|
85
|
+
await getContactItem(employee.contactId, ContactField.Email, 'work', context)
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
@FieldResolver(type => Profile)
|