Преглед изворни кода

Merge branch 'master' of Hepper/comment into master

AdamFu пре 4 година
родитељ
комит
faedcc8a99

+ 11
- 4
lib/App.js Прегледај датотеку

356
         if (_this5.props.showAlertComment) {
356
         if (_this5.props.showAlertComment) {
357
           _message3.default.success(_reactIntlUniversal2.default.get("message.success"));
357
           _message3.default.success(_reactIntlUniversal2.default.get("message.success"));
358
         }
358
         }
359
-        if ((0, _helper.isFunction)(cb)) cb();
359
+        if ((0, _helper.isFunction)(cb)) cb(response.data);
360
         // 将数据写入到 list 中
360
         // 将数据写入到 list 中
361
         // 临时插入
361
         // 临时插入
362
         // 等到获取数据之后,删除临时数据
362
         // 等到获取数据之后,删除临时数据
397
         var res = list.filter(function (item) {
397
         var res = list.filter(function (item) {
398
           return item.id !== commentId;
398
           return item.id !== commentId;
399
         });
399
         });
400
+        var deletedItem = list.find(function (item) {
401
+          return item.id === commentId;
402
+        });
400
         _this6.setState({ list: res, total: total - 1 });
403
         _this6.setState({ list: res, total: total - 1 });
401
-        _this6.props.onDelete(_constant.COMMENT_TYPE.COMMENT);
404
+        _this6.props.onDelete(_constant.COMMENT_TYPE.COMMENT, deletedItem);
402
         _this6.props.onCountChange(total - 1);
405
         _this6.props.onCountChange(total - 1);
403
       }).catch(this.errorHandler).finally(function () {
406
       }).catch(this.errorHandler).finally(function () {
404
         _this6.handleChangeLoading("sDeleteComment", false);
407
         _this6.handleChangeLoading("sDeleteComment", false);
428
         if (_this7.props.showAlertReply) {
431
         if (_this7.props.showAlertReply) {
429
           _message3.default.success(_reactIntlUniversal2.default.get("message.replySuccess"));
432
           _message3.default.success(_reactIntlUniversal2.default.get("message.replySuccess"));
430
         }
433
         }
431
-        if ((0, _helper.isFunction)(cb)) cb();
434
+        if ((0, _helper.isFunction)(cb)) cb(response.data);
432
         // 将数据写入到 list 中
435
         // 将数据写入到 list 中
433
         // 临时插入
436
         // 临时插入
434
         // 等到获取数据之后,删除临时数据
437
         // 等到获取数据之后,删除临时数据
466
         method: "delete",
469
         method: "delete",
467
         withCredentials: true
470
         withCredentials: true
468
       }).then(function () {
471
       }).then(function () {
472
+        var deletedItem = null;
469
         var list = _this8.state.list.map(function (item) {
473
         var list = _this8.state.list.map(function (item) {
470
           if (item.id === commentId) {
474
           if (item.id === commentId) {
471
             var replies = item.replies.filter(function (item) {
475
             var replies = item.replies.filter(function (item) {
472
               return item.id !== replyId;
476
               return item.id !== replyId;
473
             });
477
             });
478
+            deletedItem = item.replies.find(function (item) {
479
+              return item.id === replyId;
480
+            });
474
             item.replies = replies;
481
             item.replies = replies;
475
             item.reply_count -= 1;
482
             item.reply_count -= 1;
476
           }
483
           }
477
           return item;
484
           return item;
478
         });
485
         });
479
         _this8.setState({ list: list });
486
         _this8.setState({ list: list });
480
-        _this8.props.onDelete(_constant.COMMENT_TYPE.REPLY);
487
+        _this8.props.onDelete(_constant.COMMENT_TYPE.REPLY, deletedItem);
481
       }).catch(this.errorHandler).finally(function () {
488
       }).catch(this.errorHandler).finally(function () {
482
         _this8.handleChangeLoading("sDeleteReply", false);
489
         _this8.handleChangeLoading("sDeleteReply", false);
483
       });
490
       });

+ 1
- 1
lib/App.js.map
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 4
- 4
lib/components/CommentInput/index.js Прегледај датотеку

83
           comment_id: commentId,
83
           comment_id: commentId,
84
           content: value,
84
           content: value,
85
           business_user_id: userId
85
           business_user_id: userId
86
-        }, function () {
87
-          return callback && callback();
86
+        }, function (data) {
87
+          return callback && callback(data);
88
         });
88
         });
89
       } else if (action === "replyToReply") {
89
       } else if (action === "replyToReply") {
90
         this.props.app.sCreateReply({
90
         this.props.app.sCreateReply({
92
           content: value,
92
           content: value,
93
           reply_id: replyId,
93
           reply_id: replyId,
94
           business_user_id: userId
94
           business_user_id: userId
95
-        }, function () {
96
-          return callback && callback();
95
+        }, function (data) {
96
+          return callback && callback(data);
97
         });
97
         });
98
       }
98
       }
99
     }
99
     }

+ 1
- 1
lib/components/CommentInput/index.js.map
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 14
- 10
lib/components/ContentItem/index.js Прегледај датотеку

118
     _this.showPreviewer = _this.showPreviewer.bind(_this);
118
     _this.showPreviewer = _this.showPreviewer.bind(_this);
119
     _this.hidePreviewer = _this.hidePreviewer.bind(_this);
119
     _this.hidePreviewer = _this.hidePreviewer.bind(_this);
120
     _this.handleVisibleChange = _this.handleVisibleChange.bind(_this);
120
     _this.handleVisibleChange = _this.handleVisibleChange.bind(_this);
121
+    _this.handleUserAvaClick = _this.handleUserAvaClick.bind(_this);
121
     return _this;
122
     return _this;
122
   }
123
   }
123
 
124
 
148
         popoverVisible: visible
149
         popoverVisible: visible
149
       });
150
       });
150
     }
151
     }
152
+  }, {
153
+    key: "handleUserAvaClick",
154
+    value: function handleUserAvaClick() {
155
+      var user_id = this.props.user_id;
156
+      var userAvaClick = this.props.app.userAvaClick;
157
+
158
+      if (userAvaClick) {
159
+        userAvaClick(user_id);
160
+      }
161
+    }
151
   }, {
162
   }, {
152
     key: "renderTextWithReply",
163
     key: "renderTextWithReply",
153
     value: function renderTextWithReply(text, content) {
164
     value: function renderTextWithReply(text, content) {
187
           user_id = _props.user_id;
198
           user_id = _props.user_id;
188
       var _props$app = this.props.app,
199
       var _props$app = this.props.app,
189
           locale = _props$app.locale,
200
           locale = _props$app.locale,
190
-          userAvaClick = _props$app.userAvaClick,
191
           showHoverCard = _props$app.showHoverCard;
201
           showHoverCard = _props$app.showHoverCard;
192
       var showInput = this.state.showInput;
202
       var showInput = this.state.showInput;
193
 
203
 
240
               style: {
250
               style: {
241
                 backgroundImage: "url(" + (content.user_avatar || _avatar2.default) + ")"
251
                 backgroundImage: "url(" + (content.user_avatar || _avatar2.default) + ")"
242
               },
252
               },
243
-              onClick: function onClick() {
244
-                return userAvaClick(user_id);
245
-              }
253
+              onClick: this.handleUserAvaClick
246
             })
254
             })
247
           ) : _react2.default.createElement("div", {
255
           ) : _react2.default.createElement("div", {
248
             className: "comment-item-avatar",
256
             className: "comment-item-avatar",
249
             style: {
257
             style: {
250
               backgroundImage: "url(" + (content.user_avatar || _avatar2.default) + ")"
258
               backgroundImage: "url(" + (content.user_avatar || _avatar2.default) + ")"
251
             },
259
             },
252
-            onClick: function onClick() {
253
-              userAvaClick(user_id);
254
-            }
260
+            onClick: this.handleUserAvaClick
255
           })
261
           })
256
         ),
262
         ),
257
         _react2.default.createElement(
263
         _react2.default.createElement(
263
             _react2.default.createElement(
269
             _react2.default.createElement(
264
               "strong",
270
               "strong",
265
               {
271
               {
266
-                onClick: function onClick() {
267
-                  return userAvaClick(user_id);
268
-                },
272
+                onClick: this.handleUserAvaClick,
269
                 style: { cursor: "pointer" }
273
                 style: { cursor: "pointer" }
270
               },
274
               },
271
               content.user_name || _reactIntlUniversal2.default.get("comment.tourist")
275
               content.user_name || _reactIntlUniversal2.default.get("comment.tourist")

+ 1
- 1
lib/components/ContentItem/index.js.map
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 5
- 0
lib/components/Editor/Upload.css Прегледај датотеку

7
   margin-top: 8px;
7
   margin-top: 8px;
8
   color: #666;
8
   color: #666;
9
 }
9
 }
10
+
11
+.upload-img-preview .ant-modal-close {
12
+  top: -10px;
13
+  right: -15px;
14
+}

+ 1
- 0
lib/components/Editor/Upload.js Прегледај датотеку

200
         _react2.default.createElement(
200
         _react2.default.createElement(
201
           _modal2.default,
201
           _modal2.default,
202
           {
202
           {
203
+            className: "upload-img-preview",
203
             visible: previewVisible,
204
             visible: previewVisible,
204
             footer: null,
205
             footer: null,
205
             onCancel: this.handleCancel
206
             onCancel: this.handleCancel

+ 1
- 1
lib/components/Editor/Upload.js.map
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 4
- 4
lib/components/Editor/index.js Прегледај датотеку

247
       if (this.props.beforeSubmit) {
247
       if (this.props.beforeSubmit) {
248
         Promise.resolve(this.props.beforeSubmit({ text: value, files: files })).then(function (res) {
248
         Promise.resolve(this.props.beforeSubmit({ text: value, files: files })).then(function (res) {
249
           if (!(res === false)) {
249
           if (!(res === false)) {
250
-            _this2.props.onSubmit({ text: value, files: files }, function () {
250
+            _this2.props.onSubmit({ text: value, files: files }, function (res) {
251
               _this2.resetState();
251
               _this2.resetState();
252
               if (_this2.props.onCommentSuccess) {
252
               if (_this2.props.onCommentSuccess) {
253
-                _this2.props.onCommentSuccess();
253
+                _this2.props.onCommentSuccess(res);
254
               }
254
               }
255
             });
255
             });
256
           }
256
           }
257
         });
257
         });
258
       } else {
258
       } else {
259
-        this.props.onSubmit({ text: value, files: files }, function () {
259
+        this.props.onSubmit({ text: value, files: files }, function (res) {
260
           _this2.resetState();
260
           _this2.resetState();
261
           if (_this2.props.onCommentSuccess) {
261
           if (_this2.props.onCommentSuccess) {
262
-            _this2.props.onCommentSuccess();
262
+            _this2.props.onCommentSuccess(res);
263
           }
263
           }
264
         });
264
         });
265
       }
265
       }

+ 1
- 1
lib/components/Editor/index.js.map
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 9
- 2
lib/index.js Прегледај датотеку

111
     type: 1,
111
     type: 1,
112
     businessId: "test",
112
     businessId: "test",
113
     businessUserId: 4,
113
     businessUserId: 4,
114
-    userId: 71299,
114
+    userId: 71748,
115
     currentUser: {
115
     currentUser: {
116
       user_id: 71748
116
       user_id: 71748
117
     },
117
     },
158
     onCountChange: function onCountChange(c) {
158
     onCountChange: function onCountChange(c) {
159
       console.log(c);
159
       console.log(c);
160
     },
160
     },
161
-    editorProps: {}
161
+    onDelete: function onDelete(type, data) {
162
+      console.log(type, data);
163
+    },
164
+    editorProps: {
165
+      onCommentSuccess: function onCommentSuccess(data) {
166
+        console.log(data);
167
+      }
168
+    }
162
   });
169
   });
163
 }
170
 }
164
 
171
 

+ 1
- 1
lib/index.js.map
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 3
- 3
lib/version.json Прегледај датотеку

1
 {
1
 {
2
     "name":       "comment",
2
     "name":       "comment",
3
-    "buildDate":  1562073871881,
3
+    "buildDate":  1562985105668,
4
     "version":    "1.0.4",
4
     "version":    "1.0.4",
5
-    "numCommits": 158,
6
-    "hash":       "1b15efb",
5
+    "numCommits": 161,
6
+    "hash":       "a7dfeba",
7
     "dirty":      true
7
     "dirty":      true
8
 }
8
 }

+ 5
- 2
src/App.js Прегледај датотеку

277
       .then(() => {
277
       .then(() => {
278
         const { list, total } = this.state;
278
         const { list, total } = this.state;
279
         const res = list.filter(item => item.id !== commentId);
279
         const res = list.filter(item => item.id !== commentId);
280
+        const deletedItem = list.find(item => item.id === commentId);
280
         this.setState({ list: res, total: total - 1 });
281
         this.setState({ list: res, total: total - 1 });
281
-        this.props.onDelete(COMMENT_TYPE.COMMENT);
282
+        this.props.onDelete(COMMENT_TYPE.COMMENT, deletedItem);
282
         this.props.onCountChange(total - 1);
283
         this.props.onCountChange(total - 1);
283
       })
284
       })
284
       .catch(this.errorHandler)
285
       .catch(this.errorHandler)
341
       withCredentials: true
342
       withCredentials: true
342
     })
343
     })
343
       .then(() => {
344
       .then(() => {
345
+        let deletedItem = null;
344
         const list = this.state.list.map(item => {
346
         const list = this.state.list.map(item => {
345
           if (item.id === commentId) {
347
           if (item.id === commentId) {
346
             const replies = item.replies.filter(item => item.id !== replyId);
348
             const replies = item.replies.filter(item => item.id !== replyId);
349
+            deletedItem = item.replies.find(item => item.id === replyId);
347
             item.replies = replies;
350
             item.replies = replies;
348
             item.reply_count -= 1;
351
             item.reply_count -= 1;
349
           }
352
           }
350
           return item;
353
           return item;
351
         });
354
         });
352
         this.setState({ list });
355
         this.setState({ list });
353
-        this.props.onDelete(COMMENT_TYPE.REPLY);
356
+        this.props.onDelete(COMMENT_TYPE.REPLY, deletedItem);
354
       })
357
       })
355
       .catch(this.errorHandler)
358
       .catch(this.errorHandler)
356
       .finally(() => {
359
       .finally(() => {

+ 8
- 9
src/components/CommentInput/index.js Прегледај датотеку

36
         cb
36
         cb
37
       );
37
       );
38
     } else if (action === "reply") {
38
     } else if (action === "reply") {
39
-      console.log("[[[", callback);
40
-      // this.props.app.sCreateReply(
41
-      //   {
42
-      //     comment_id: commentId,
43
-      //     content: value,
44
-      //     business_user_id: userId
45
-      //   },
46
-      //   (data) => callback && callback(data)
47
-      // );
39
+      this.props.app.sCreateReply(
40
+        {
41
+          comment_id: commentId,
42
+          content: value,
43
+          business_user_id: userId
44
+        },
45
+        data => callback && callback(data)
46
+      );
48
     } else if (action === "replyToReply") {
47
     } else if (action === "replyToReply") {
49
       this.props.app.sCreateReply(
48
       this.props.app.sCreateReply(
50
         {
49
         {

+ 3
- 2
src/components/ContentItem/index.js Прегледај датотеку

36
     this.showPreviewer = this.showPreviewer.bind(this);
36
     this.showPreviewer = this.showPreviewer.bind(this);
37
     this.hidePreviewer = this.hidePreviewer.bind(this);
37
     this.hidePreviewer = this.hidePreviewer.bind(this);
38
     this.handleVisibleChange = this.handleVisibleChange.bind(this);
38
     this.handleVisibleChange = this.handleVisibleChange.bind(this);
39
+    this.handleUserAvaClick = this.handleUserAvaClick.bind(this);
39
   }
40
   }
40
 
41
 
41
   showPreviewer(index) {
42
   showPreviewer(index) {
61
     });
62
     });
62
   }
63
   }
63
 
64
 
64
-  handleUserAvaClick = () => {
65
+  handleUserAvaClick() {
65
     const { user_id } = this.props;
66
     const { user_id } = this.props;
66
     const { userAvaClick } = this.props.app;
67
     const { userAvaClick } = this.props.app;
67
     if (userAvaClick) {
68
     if (userAvaClick) {
68
       userAvaClick(user_id);
69
       userAvaClick(user_id);
69
     }
70
     }
70
-  };
71
+  }
71
 
72
 
72
   renderTextWithReply(text, content) {
73
   renderTextWithReply(text, content) {
73
     let newText = text;
74
     let newText = text;

+ 4
- 1
src/index.js Прегледај датотеку

76
     type: 1,
76
     type: 1,
77
     businessId: "test",
77
     businessId: "test",
78
     businessUserId: 4,
78
     businessUserId: 4,
79
-    userId: 71299,
79
+    userId: 71748,
80
     currentUser: {
80
     currentUser: {
81
       user_id: 71748
81
       user_id: 71748
82
     },
82
     },
123
     onCountChange: c => {
123
     onCountChange: c => {
124
       console.log(c);
124
       console.log(c);
125
     },
125
     },
126
+    onDelete: (type, data) => {
127
+      console.log(type, data);
128
+    },
126
     editorProps: {
129
     editorProps: {
127
       onCommentSuccess: data => {
130
       onCommentSuccess: data => {
128
         console.log(data);
131
         console.log(data);