Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
IQB
PersonalDB
Commits
e0483408
Commit
e0483408
authored
Feb 21, 2022
by
mechtelm
Browse files
Add principals/subs in main data view
parent
8c98a8a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
apps/api/src/app/database/services/staff.service.ts
View file @
e0483408
...
...
@@ -3,12 +3,14 @@ import {InjectRepository} from "@nestjs/typeorm";
import
{
Repository
}
from
"
typeorm
"
;
import
Staff
from
"
../entities/staff-member.entity
"
;
import
{
StaffMemberCreateDto
,
StaffMemberInListDto
,
StaffMemberMainDto
}
from
"
@lib/dto
"
;
import
{
PrincipalService
}
from
"
./principal.service
"
;
@
Injectable
()
export
class
StaffService
{
constructor
(
@
InjectRepository
(
Staff
)
private
staffRepository
:
Repository
<
Staff
>
,
private
principalService
:
PrincipalService
,
)
{}
async
findAll
():
Promise
<
StaffMemberInListDto
[]
>
{
...
...
@@ -48,7 +50,9 @@ export class StaffService {
idmId
:
staffMember
.
idmId
,
idmRegistered
:
staffMember
.
idmRegistered
,
address
:
staffMember
.
address
,
dateOfBirth
:
staffMember
.
dateOfBirth
dateOfBirth
:
staffMember
.
dateOfBirth
,
principals
:
await
this
.
principalService
.
findAllPrincipals
(
staffMember
.
id
),
subs
:
await
this
.
principalService
.
findAllSubs
(
staffMember
.
id
)
}
}
else
{
throw
new
NotFoundException
();
...
...
apps/frontend/src/app/staff-list/main-data/main-data.component.html
View file @
e0483408
...
...
@@ -10,5 +10,7 @@
<tr><td>
Adresse
</td><td>
{{mainData.address ? mainData.address.replace('\n', '; ') : '-'}}
</td></tr>
<tr><td>
Tag der Geburt
</td><td>
{{mainData.dateOfBirthString}}
</td></tr>
<tr><td>
Vertrag
</td><td>
{{mainData.contractData}}
</td></tr>
<tr><td>
Vorgesetze/r
</td><td>
{{mainData.allPrincipals}}
</td></tr>
<tr><td>
Ist Vorgesetze/r von
</td><td>
{{mainData.allSubs}}
</td></tr>
</table>
</div>
apps/frontend/src/app/staff-list/staff-list.classes.ts
View file @
e0483408
import
{
StaffMemberInListDto
,
StaffMemberMainDto
}
from
"
@lib/dto
"
;
import
{
PrincipalRelationDto
,
StaffMemberInListDto
,
StaffMemberMainDto
}
from
"
@lib/dto
"
;
import
*
as
_moment
from
'
moment
'
;
export
class
StaffMemberView
{
...
...
@@ -49,6 +49,8 @@ export class StaffMember {
sex
?:
string
;
title
?:
string
;
dateOfBirth
?:
string
;
principals
?:
PrincipalRelationDto
[];
subs
?:
PrincipalRelationDto
[];
get
fullName
():
string
{
const
returnText
=
`
${
this
.
name
}${
this
.
firstName
?
'
,
'
+
this
.
firstName
:
''
}
`
;
...
...
@@ -113,6 +115,28 @@ export class StaffMember {
return
'
alle
'
}
get
allPrincipals
():
string
{
const
returnArray
:
string
[]
=
[];
if
(
this
.
principals
)
{
this
.
principals
.
forEach
(
p
=>
{
returnArray
.
push
(
`
${
p
.
name
}
,
${
p
.
firstName
}
`
);
})
return
returnArray
.
join
(
'
;
'
)
}
return
''
}
get
allSubs
():
string
{
const
returnArray
:
string
[]
=
[];
if
(
this
.
subs
)
{
this
.
subs
.
forEach
(
p
=>
{
returnArray
.
push
(
`
${
p
.
name
}
,
${
p
.
firstName
}
`
);
})
return
returnArray
.
join
(
'
;
'
)
}
return
''
}
constructor
(
staffData
:
StaffMemberMainDto
)
{
this
.
id
=
staffData
.
id
;
this
.
name
=
staffData
.
name
;
...
...
@@ -127,6 +151,8 @@ export class StaffMember {
this
.
address
=
staffData
.
address
;
this
.
payrollId
=
staffData
.
payrollId
;
this
.
dateOfBirth
=
staffData
.
dateOfBirth
;
this
.
principals
=
staffData
.
principals
;
this
.
subs
=
staffData
.
subs
}
static
dateToString
(
someDate
?:
_moment
.
Moment
):
string
{
...
...
libs/dto/src/lib/staff/staff-member-main-dto.ts
View file @
e0483408
...
...
@@ -42,6 +42,12 @@ export class StaffMemberMainDto {
@
ApiProperty
()
title
?:
string
;
@
ApiProperty
()
principals
?:
PrincipalRelationDto
[];
@
ApiProperty
()
subs
?:
PrincipalRelationDto
[];
}
export
class
PrincipalRelationDto
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment