mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-13 18:04:55 +00:00
fix the issue that can not delete and edit the comments
This commit is contained in:
parent
d04abe78c8
commit
cd942e852c
@ -344,6 +344,11 @@ public class Dataset extends Controller
|
|||||||
public static Result getPagedDatasetComments(int id)
|
public static Result getPagedDatasetComments(int id)
|
||||||
{
|
{
|
||||||
ObjectNode result = Json.newObject();
|
ObjectNode result = Json.newObject();
|
||||||
|
String username = session("user");
|
||||||
|
if (username == null)
|
||||||
|
{
|
||||||
|
username = "";
|
||||||
|
}
|
||||||
|
|
||||||
int page = 1;
|
int page = 1;
|
||||||
String pageStr = request().getQueryString("page");
|
String pageStr = request().getQueryString("page");
|
||||||
@ -386,7 +391,7 @@ public class Dataset extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.put("status", "ok");
|
result.put("status", "ok");
|
||||||
result.set("data", DatasetsDAO.getPagedDatasetComments(id, page, size));
|
result.set("data", DatasetsDAO.getPagedDatasetComments(username, id, page, size));
|
||||||
return ok(result);
|
return ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,6 +582,12 @@ public class Dataset extends Controller
|
|||||||
{
|
{
|
||||||
ObjectNode result = Json.newObject();
|
ObjectNode result = Json.newObject();
|
||||||
|
|
||||||
|
String username = session("user");
|
||||||
|
if (username == null)
|
||||||
|
{
|
||||||
|
username = "";
|
||||||
|
}
|
||||||
|
|
||||||
int page = 1;
|
int page = 1;
|
||||||
String pageStr = request().getQueryString("page");
|
String pageStr = request().getQueryString("page");
|
||||||
if (StringUtils.isBlank(pageStr))
|
if (StringUtils.isBlank(pageStr))
|
||||||
@ -618,7 +629,7 @@ public class Dataset extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.put("status", "ok");
|
result.put("status", "ok");
|
||||||
result.set("data", DatasetsDAO.getPagedDatasetColumnComments(datasetId, columnId, page, size));
|
result.set("data", DatasetsDAO.getPagedDatasetColumnComments(username, datasetId, columnId, page, size));
|
||||||
return ok(result);
|
return ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,7 +943,7 @@ public class DatasetsDAO extends AbstractMySQLOpenSourceDAO
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObjectNode getPagedDatasetComments(int id, int page, int size)
|
public static ObjectNode getPagedDatasetComments(String userName, int id, int page, int size)
|
||||||
{
|
{
|
||||||
ObjectNode result = Json.newObject();
|
ObjectNode result = Json.newObject();
|
||||||
|
|
||||||
@ -969,6 +969,17 @@ public class DatasetsDAO extends AbstractMySQLOpenSourceDAO
|
|||||||
Logger.error("Exception = " + e.getMessage());
|
Logger.error("Exception = " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pagedComments != null)
|
||||||
|
{
|
||||||
|
for(DatasetComment dc : pagedComments)
|
||||||
|
{
|
||||||
|
if(StringUtils.isNotBlank(userName) && userName.equalsIgnoreCase(dc.authorUserName))
|
||||||
|
{
|
||||||
|
dc.isAuthor = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ObjectNode resultNode = Json.newObject();
|
ObjectNode resultNode = Json.newObject();
|
||||||
resultNode.set("comments", Json.toJson(pagedComments));
|
resultNode.set("comments", Json.toJson(pagedComments));
|
||||||
resultNode.put("count", count);
|
resultNode.put("count", count);
|
||||||
@ -1256,7 +1267,7 @@ public class DatasetsDAO extends AbstractMySQLOpenSourceDAO
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObjectNode getPagedDatasetColumnComments(int datasetId, int columnId, int page, int size)
|
public static ObjectNode getPagedDatasetColumnComments(String userName, int datasetId, int columnId, int page, int size)
|
||||||
{
|
{
|
||||||
ObjectNode result = Json.newObject();
|
ObjectNode result = Json.newObject();
|
||||||
|
|
||||||
@ -1312,6 +1323,17 @@ public class DatasetsDAO extends AbstractMySQLOpenSourceDAO
|
|||||||
Logger.error("Exception = " + e.getMessage());
|
Logger.error("Exception = " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pagedComments != null)
|
||||||
|
{
|
||||||
|
for(DatasetColumnComment dc : pagedComments)
|
||||||
|
{
|
||||||
|
if(StringUtils.isNotBlank(userName) && userName.equalsIgnoreCase(dc.authorUsername))
|
||||||
|
{
|
||||||
|
dc.isAuthor = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resultNode.set("comments", Json.toJson(pagedComments));
|
resultNode.set("comments", Json.toJson(pagedComments));
|
||||||
resultNode.put("count", count);
|
resultNode.put("count", count);
|
||||||
resultNode.put("page", page);
|
resultNode.put("page", page);
|
||||||
|
@ -23,4 +23,5 @@ public class DatasetColumnComment {
|
|||||||
public String created;
|
public String created;
|
||||||
public String modified;
|
public String modified;
|
||||||
public boolean isDefault;
|
public boolean isDefault;
|
||||||
|
public Boolean isAuthor;
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,5 @@ public class DatasetComment {
|
|||||||
public String created;
|
public String created;
|
||||||
public String modified;
|
public String modified;
|
||||||
public String type;
|
public String type;
|
||||||
|
public Boolean isAuthor;
|
||||||
}
|
}
|
@ -673,12 +673,12 @@
|
|||||||
class="pull-right actions"
|
class="pull-right actions"
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
class="fa fa-pencil"
|
class="fa fa-pencil wh-clickable-icon"
|
||||||
{{action "showModal" comment}}
|
{{action "showModal" comment}}
|
||||||
>
|
>
|
||||||
</i>
|
</i>
|
||||||
<i
|
<i
|
||||||
class="fa fa-trash"
|
class="fa fa-trash wh-clickable-icon"
|
||||||
{{action "remove" comment}}
|
{{action "remove" comment}}
|
||||||
>
|
>
|
||||||
</i>
|
</i>
|
||||||
@ -863,13 +863,13 @@
|
|||||||
</i>
|
</i>
|
||||||
{{#if comment.isAuthor}}
|
{{#if comment.isAuthor}}
|
||||||
<i
|
<i
|
||||||
class="fa fa-pencil"
|
class="fa fa-pencil wh-clickable-icon"
|
||||||
title="Edit"
|
title="Edit"
|
||||||
{{action "editMode" comment}}
|
{{action "editMode" comment}}
|
||||||
>
|
>
|
||||||
</i>
|
</i>
|
||||||
<i
|
<i
|
||||||
class="fa fa-trash"
|
class="fa fa-trash wh-clickable-icon"
|
||||||
title="Remove"
|
title="Remove"
|
||||||
{{action "remove" comment}}
|
{{action "remove" comment}}
|
||||||
>
|
>
|
||||||
|
@ -539,11 +539,7 @@ App.DatasetCommentsComponent = Ember.Component.extend({
|
|||||||
_this.set('commentsLoading', false)
|
_this.set('commentsLoading', false)
|
||||||
var comments = data.data.comments
|
var comments = data.data.comments
|
||||||
comments.forEach(function(cmnt){
|
comments.forEach(function(cmnt){
|
||||||
cmnt.isAuthor = false
|
cmnt.html = marked(cmnt.text).htmlSafe();
|
||||||
cmnt.html = marked(cmnt.text).htmlSafe()
|
|
||||||
if(cmnt.authorUserName === $("#username").text().trim()) {
|
|
||||||
cmnt.isAuthor = true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
_this.set('comments', comments);
|
_this.set('comments', comments);
|
||||||
}
|
}
|
||||||
|
@ -276,11 +276,7 @@ App.SchemaCommentComponent = Ember.Component.extend({
|
|||||||
, function(data){
|
, function(data){
|
||||||
var comments = data.data.comments
|
var comments = data.data.comments
|
||||||
comments.forEach(function(cmnt){
|
comments.forEach(function(cmnt){
|
||||||
cmnt.isAuthor = false
|
cmnt.html = marked(cmnt.text).htmlSafe();
|
||||||
cmnt.html = marked(cmnt.text).htmlSafe()
|
|
||||||
if(cmnt.authorUsername === $("#username").text().trim()) {
|
|
||||||
cmnt.isAuthor = true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
_this.set('comments', comments)
|
_this.set('comments', comments)
|
||||||
_this.set('page', data.data.page)
|
_this.set('page', data.data.page)
|
||||||
|
@ -331,7 +331,6 @@ a.list-group-item {
|
|||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
padding-top: 12px;
|
padding-top: 12px;
|
||||||
padding-bottom: 12px;
|
padding-bottom: 12px;
|
||||||
text-transform: capitalize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-group-item.active {
|
.list-group-item.active {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user