File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import {IComment} from "../../interfaces";
12
12
<tags-input ng-model="$ctrl.tagFilter">
13
13
<auto-complete source="$ctrl.tags"></auto-complete>
14
14
</tags-input>
15
- <comment ng-repeat="comment in $ctrl.comments | filterByTags:$ctrl.tagFilter" comment="comment" tags="$ctrl.tags"></comment>
15
+ <comment ng-repeat="comment in $ctrl.comments | filterByTags:$ctrl.tagFilter" comment="comment" tags="$ctrl.tags" on-delete="$ctrl.deleteComment(comment)" ></comment>
16
16
<comment comment="$ctrl.emptyComment" on-add="$ctrl.addComment()" tags="$ctrl.tags"></comment>
17
17
</div>
18
18
</div>`
@@ -46,4 +46,9 @@ class CommentsController {
46
46
this . comments . push ( this . emptyComment ) ;
47
47
this . emptyComment = { } ;
48
48
}
49
+
50
+ deleteComment ( comment : IComment ) {
51
+ let index = this . comments . indexOf ( comment ) ;
52
+ this . comments . splice ( index , 1 ) ;
53
+ }
49
54
}
Original file line number Diff line number Diff line change 1
1
/**
2
2
* Created by voland on 4/2/16.
3
3
*/
4
+
4
5
import Component from '../../decorators' ;
5
6
import './comment.scss' ;
6
7
import { IComment } from "../../interfaces" ;
@@ -9,7 +10,8 @@ import {IComment} from "../../interfaces";
9
10
bindings : {
10
11
comment : '=' ,
11
12
tags : '=' ,
12
- onAdd : '&'
13
+ onAdd : '&' ,
14
+ onDelete : '&'
13
15
} ,
14
16
template : `
15
17
<div class="comment-wrapper">
@@ -19,6 +21,9 @@ import {IComment} from "../../interfaces";
19
21
<button type="button" class="comment-edit-button" title="Edit comment" ng-click="$ctrl.edit()">
20
22
<svg aria-hidden="true" class="octicon octicon-pencil" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M0 12v3h3l8-8-3-3L0 12z m3 2H1V12h1v1h1v1z m10.3-9.3l-1.3 1.3-3-3 1.3-1.3c0.39-0.39 1.02-0.39 1.41 0l1.59 1.59c0.39 0.39 0.39 1.02 0 1.41z"></path></svg>
21
23
</button>
24
+ <button type="button" class="comment-edit-button" title="Delete comment" ng-click="$ctrl.remove()">
25
+ <svg aria-hidden="true" class="octicon octicon-trashcan" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M10 2H8c0-0.55-0.45-1-1-1H4c-0.55 0-1 0.45-1 1H1c-0.55 0-1 0.45-1 1v1c0 0.55 0.45 1 1 1v9c0 0.55 0.45 1 1 1h7c0.55 0 1-0.45 1-1V5c0.55 0 1-0.45 1-1v-1c0-0.55-0.45-1-1-1z m-1 12H2V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9z m1-10H1v-1h9v1z"></path></svg>
26
+ </button>
22
27
</div>
23
28
<div class="comment-tag" ng-repeat="tag in $ctrl.comment.tags">{{tag}}</div>
24
29
<div class="comment-header-text">{{$ctrl.comment.title}}</div>
@@ -53,7 +58,8 @@ class CommentController {
53
58
editMode : boolean ;
54
59
comment : IComment ;
55
60
commentCopy : IComment ;
56
- onAdd : any ;
61
+ onAdd : ( ) => void ;
62
+ onDelete : ( ) => void ;
57
63
58
64
constructor ( ) {
59
65
this . editMode = ! this . comment . id ;
@@ -73,6 +79,10 @@ class CommentController {
73
79
( this . onAdd || angular . noop ) ( ) ;
74
80
}
75
81
82
+ remove ( ) {
83
+ ( this . onDelete || angular . noop ) ( ) ;
84
+ }
85
+
76
86
discard ( ) {
77
87
this . editMode = false ;
78
88
this . comment = this . commentCopy ;
You can’t perform that action at this time.
0 commit comments