1+ <template >
2+ <div class =" detailBox" >
3+ <div class =" titleBox" >
4+ <label >Comments: {{selectedTask.title}}</label >
5+ <button type =" button" class =" close" aria-hidden =" true" >× ; </button >
6+ </div >
7+ <div class =" commentBox" >
8+
9+ <p class =" taskDescription" >{{selectedTask.description}}</p >
10+ </div >
11+ <div class =" actionBox" >
12+ <ul class =" commentList" >
13+ <li v-for =" (comment,index) in taskComments" >
14+ <div class =" commenterImage" >
15+ <img src =" https://ssl.gstatic.com/accounts/ui/avatar_2x.png" />
16+ <!-- <i class='glyphicon glyphicon-user'></i> -->
17+ </div >
18+ <div class =" commentText" ><strong >{{comment.CommenterUserId}}</strong >
19+ <span class =" date sub-text" >on {{new Date(comment.createdDateTime).toDateString()}}</span >
20+ <p class =" " >{{comment.content}}.</p >
21+
22+ </div >
23+ </li >
24+
25+ </ul >
26+ <form class =" form-inline" role =" form" >
27+ <div class =" form-group" >
28+ <input class =" form-control" type =" text" placeholder =" Your comments" v-model =" newcomment" />
29+ </div >
30+ <div class =" form-group" >
31+ <!-- <button class="btn btn-default" v-on:click='submit($event)'>Add</button> -->
32+ <input type =" submit" class =" btn btn-default"
33+ value =" Add" v-on:click =' submit($event)' >
34+ </div >
35+ </form >
36+ </div >
37+ </div >
38+
39+ </template >
40+
41+ <script >
42+ import api from ' ../utils/api'
43+
44+ export default {
45+ name: ' Comments' ,
46+
47+ props: {
48+ selectedTask: {
49+ type: Object ,
50+ required: true
51+ },
52+ taskComments: {
53+ type: Array ,
54+ required: true
55+ },
56+ username: {
57+ type: String ,
58+ required: true
59+ }
60+ },
61+
62+ data (){
63+ return {
64+ newcomment: ' '
65+ }
66+ },
67+
68+ methods: {
69+ submit (e ){
70+ e .preventDefault ();
71+ var submitcommentreq = {
72+ content: this .newcomment ,
73+ TaskId: this .selectedTask ._id ,
74+ CommenterUserId: this .username
75+ };
76+
77+ api .createComment (submitcommentreq)
78+ .then ((resp )=> {
79+ console .log (' createComment resp:- ' + JSON .stringify (resp));
80+ this .taskComments .push (resp .data );
81+ this .newcomment = ' ' ;
82+ });
83+
84+ }
85+ },
86+
87+ beforeUpdate (){
88+
89+ },
90+ }
91+
92+ </script >
93+
94+
95+ <style >
96+ .thumbnail {
97+ padding :0px ;
98+ }
99+ .detailBox {
100+ position :relative ;
101+ border :1px solid #bbb ;
102+ }
103+
104+
105+
106+ .titleBox {
107+ background-color :#fdfdfd ;
108+ padding :10px ;
109+ }
110+ .titleBox label {
111+ color :#444 ;
112+ margin :0 ;
113+ display :inline-block ;
114+ }
115+
116+ .commentBox {
117+ padding :10px ;
118+ border-top :1px dotted #bbb ;
119+ }
120+ .commentBox .form-group :first-child , .actionBox .form-group :first-child {
121+ width :80% ;
122+ }
123+ .commentBox .form-group :nth-child (2 ), .actionBox .form-group :nth-child (2 ) {
124+ width :18% ;
125+ }
126+ .actionBox .form-group * {
127+ width :100% ;
128+ }
129+ .taskDescription {
130+ margin-top :10px 0 ;
131+ }
132+ .commentList {
133+ padding :0 ;
134+ list-style :none ;
135+ /* max-height:200px;*/
136+ overflow :auto ;
137+ }
138+ .commentList li {
139+ margin :0 ;
140+ margin-top :10px ;
141+ }
142+ .commentList li > div {
143+ display :table-cell ;
144+ }
145+ .commenterImage {
146+ width :30px ;
147+ margin-right :5px ;
148+ height :100% ;
149+ float :left ;
150+ }
151+ .commenterImage img {
152+ width :100% ;
153+ border-radius :50% ;
154+ }
155+ .commentText p {
156+ margin :0 ;
157+ }
158+ .sub-text {
159+ color :#aaa ;
160+ font-family :verdana ;
161+ font-size :11px ;
162+ }
163+ .actionBox {
164+ border-top :1px dotted #bbb ;
165+ padding :10px ;
166+ }
167+ </style >
0 commit comments