Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
frag.jetzt SWTP 2022
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Marc Tröll
frag.jetzt SWTP 2022
Commits
4328cc70
Commit
4328cc70
authored
6 years ago
by
Lukas Mauß
Browse files
Options
Downloads
Patches
Plain Diff
Add voting functions to components
parent
453cfffe
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/components/shared/comment-list/comment-list.component.ts
+26
-18
26 additions, 18 deletions
.../components/shared/comment-list/comment-list.component.ts
src/app/components/shared/comment/comment.component.ts
+8
-0
8 additions, 0 deletions
src/app/components/shared/comment/comment.component.ts
with
34 additions
and
18 deletions
src/app/components/shared/comment-list/comment-list.component.ts
+
26
−
18
View file @
4328cc70
...
@@ -19,9 +19,9 @@ export class CommentListComponent implements OnInit {
...
@@ -19,9 +19,9 @@ export class CommentListComponent implements OnInit {
filteredComments
:
Comment
[];
filteredComments
:
Comment
[];
constructor
(
private
commentService
:
CommentService
,
constructor
(
private
commentService
:
CommentService
,
private
translateService
:
TranslateService
,
private
translateService
:
TranslateService
,
protected
langService
:
LanguageService
,
protected
langService
:
LanguageService
,
private
rxStompService
:
RxStompService
)
{
private
rxStompService
:
RxStompService
)
{
langService
.
langEmitter
.
subscribe
(
lang
=>
translateService
.
use
(
lang
));
langService
.
langEmitter
.
subscribe
(
lang
=>
translateService
.
use
(
lang
));
}
}
...
@@ -51,28 +51,36 @@ export class CommentListComponent implements OnInit {
...
@@ -51,28 +51,36 @@ export class CommentListComponent implements OnInit {
parseIncomingMessage
(
message
:
Message
)
{
parseIncomingMessage
(
message
:
Message
)
{
const
msg
=
JSON
.
parse
(
message
.
body
);
const
msg
=
JSON
.
parse
(
message
.
body
);
const
payload
=
msg
.
payload
;
const
payload
=
msg
.
payload
;
if
(
msg
.
type
===
'
CommentCreated
'
)
{
switch
(
msg
.
type
)
{
const
c
=
new
Comment
();
case
'
CommentCreated
'
:
c
.
roomId
=
this
.
roomId
;
const
c
=
new
Comment
();
c
.
body
=
payload
.
body
;
c
.
roomId
=
this
.
roomId
;
c
.
id
=
payload
.
id
;
c
.
body
=
payload
.
body
;
c
.
creationTimestamp
=
payload
.
timestamp
;
c
.
id
=
payload
.
id
;
this
.
comments
=
this
.
comments
.
concat
(
c
);
c
.
creationTimestamp
=
payload
.
timestamp
;
}
else
if
(
msg
.
type
===
'
CommentPatched
'
)
{
this
.
comments
=
this
.
comments
.
concat
(
c
);
break
;
case
'
CommentPatched
'
:
for
(
let
i
=
0
;
i
<
this
.
comments
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
comments
.
length
;
i
++
)
{
if
(
payload
.
id
===
this
.
comments
[
i
].
id
)
{
if
(
payload
.
id
===
this
.
comments
[
i
].
id
)
{
for
(
const
[
key
,
value
]
of
Object
.
entries
(
payload
.
changes
))
{
for
(
const
[
key
,
value
]
of
Object
.
entries
(
payload
.
changes
))
{
switch
(
key
)
{
switch
(
key
)
{
case
'
read
'
:
this
.
comments
[
i
].
read
=
<
boolean
>
value
;
case
'
read
'
:
break
;
this
.
comments
[
i
].
read
=
<
boolean
>
value
;
case
'
correct
'
:
this
.
comments
[
i
].
correct
=
<
boolean
>
value
;
break
;
break
;
case
'
correct
'
:
case
'
favorite
'
:
this
.
comments
[
i
].
favorite
=
<
boolean
>
value
;
this
.
comments
[
i
].
correct
=
<
boolean
>
value
;
break
;
break
;
case
'
favorite
'
:
this
.
comments
[
i
].
favorite
=
<
boolean
>
value
;
break
;
case
'
score
'
:
this
.
comments
[
i
].
score
=
<
number
>
value
;
break
;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/app/components/shared/comment/comment.component.ts
+
8
−
0
View file @
4328cc70
...
@@ -51,6 +51,14 @@ export class CommentComponent implements OnInit {
...
@@ -51,6 +51,14 @@ export class CommentComponent implements OnInit {
this
.
comment
=
this
.
wsCommentService
.
toggleFavorite
(
comment
);
this
.
comment
=
this
.
wsCommentService
.
toggleFavorite
(
comment
);
}
}
voteUp
(
comment
:
Comment
):
void
{
this
.
wsCommentService
.
voteUp
(
comment
);
}
voteDown
(
comment
:
Comment
):
void
{
this
.
wsCommentService
.
voteDown
(
comment
);
}
delete
(
comment
:
Comment
):
void
{
delete
(
comment
:
Comment
):
void
{
this
.
commentService
.
deleteComment
(
comment
.
id
).
subscribe
(
room
=>
{
this
.
commentService
.
deleteComment
(
comment
.
id
).
subscribe
(
room
=>
{
this
.
notification
.
show
(
`Comment '
${
comment
.
body
}
' successfully deleted.`
);
this
.
notification
.
show
(
`Comment '
${
comment
.
body
}
' successfully deleted.`
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment