Beispiel #1
0
  @Restrict(UnitRole.DEFECTVIEW)
  public static void getComments(Long defectId) {
    List<DefectComment> defectComments = DefectComment.find("defect.id=?", defectId).fetch();
    TMUser tmUser = TMUser.find("id=?", getConnectedUserId()).first();
    JsonArray jsonArray = new JsonArray();
    JsonObject result = new JsonObject();
    for (DefectComment defectComment : defectComments) {
      JsonObject comment = new JsonObject();
      comment.addProperty("id", defectComment.id);
      comment.addProperty("comment", JavaExtensions.nl2br(defectComment.comment).toString());
      comment.addProperty("submittedBy", defectComment.submittedBy.getFullName());
      SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
      comment.addProperty("submittedOn", sdf.format(defectComment.created));

      comment.addProperty("commentText", defectComment.comment);
      comment.addProperty("mainCommentId", "mainCommentId" + defectComment.id);
      comment.addProperty("hiddenDivId", "hiddenDiv" + defectComment.id);
      comment.addProperty("visibleDivId", "visibleDiv" + defectComment.id);
      comment.addProperty("visibleActionsId", "visibleActions" + defectComment.id);
      comment.addProperty("hiddenActionsId", "hiddenActions" + defectComment.id);
      comment.addProperty("commentEditInputId", "commentEditInputId" + defectComment.id);
      comment.addProperty("canEdit", defectComment.submittedBy.equals(tmUser));

      jsonArray.add(comment);
    }
    result.add("comments", jsonArray);
    renderJSON(result.toString());
  }
Beispiel #2
0
 @Restrict(UnitRole.DEFECTEDIT)
 public static void addComment(DefectComment comment, Long defectId) {
   Defect defect = Defect.find("id=?", defectId).first();
   TMUser tmUser = TMUser.find("id=?", getConnectedUserId()).first();
   Project project = Project.find("id=?", getActiveProjectId()).first();
   comment.submittedBy = tmUser;
   comment.defect = defect;
   comment.project = project;
   comment.account = tmUser.account;
   comment.save();
   ok();
 }
Beispiel #3
0
 @Restrict(UnitRole.DEFECTVIEW)
 public static void index() {
   List<TMUser> users = TMUser.listByProject(getActiveProjectId());
   render(users);
 }