File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 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";
1212 <tags-input ng-model="$ctrl.tagFilter">
1313 <auto-complete source="$ctrl.tags"></auto-complete>
1414 </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>
1616 <comment comment="$ctrl.emptyComment" on-add="$ctrl.addComment()" tags="$ctrl.tags"></comment>
1717 </div>
1818 </div>`
@@ -46,4 +46,9 @@ class CommentsController {
4646 this . comments . push ( this . emptyComment ) ;
4747 this . emptyComment = { } ;
4848 }
49+
50+ deleteComment ( comment : IComment ) {
51+ let index = this . comments . indexOf ( comment ) ;
52+ this . comments . splice ( index , 1 ) ;
53+ }
4954}
Original file line number Diff line number Diff line change 11/**
22 * Created by voland on 4/2/16.
33 */
4+
45import Component from '../../decorators' ;
56import './comment.scss' ;
67import { IComment } from "../../interfaces" ;
@@ -9,7 +10,8 @@ import {IComment} from "../../interfaces";
910 bindings : {
1011 comment : '=' ,
1112 tags : '=' ,
12- onAdd : '&'
13+ onAdd : '&' ,
14+ onDelete : '&'
1315 } ,
1416 template : `
1517 <div class="comment-wrapper">
@@ -19,6 +21,9 @@ import {IComment} from "../../interfaces";
1921 <button type="button" class="comment-edit-button" title="Edit comment" ng-click="$ctrl.edit()">
2022 <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>
2123 </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>
2227 </div>
2328 <div class="comment-tag" ng-repeat="tag in $ctrl.comment.tags">{{tag}}</div>
2429 <div class="comment-header-text">{{$ctrl.comment.title}}</div>
@@ -53,7 +58,8 @@ class CommentController {
5358 editMode : boolean ;
5459 comment : IComment ;
5560 commentCopy : IComment ;
56- onAdd : any ;
61+ onAdd : ( ) => void ;
62+ onDelete : ( ) => void ;
5763
5864 constructor ( ) {
5965 this . editMode = ! this . comment . id ;
@@ -73,6 +79,10 @@ class CommentController {
7379 ( this . onAdd || angular . noop ) ( ) ;
7480 }
7581
82+ remove ( ) {
83+ ( this . onDelete || angular . noop ) ( ) ;
84+ }
85+
7686 discard ( ) {
7787 this . editMode = false ;
7888 this . comment = this . commentCopy ;
You can’t perform that action at this time.
0 commit comments