stuff and things.
This commit is contained in:
parent
dad6fbcbd9
commit
975491792f
|
@ -49,10 +49,11 @@ description = shorten(posts.currentPageResults.headOption.??(_.text).replace("\n
|
|||
</div>
|
||||
<p class="message">@autoLink(post.text)</p>
|
||||
@if(post.canBeEditedBy(ctx.userId)) {
|
||||
<a class="mod" id="edit-button-@post.number" data-icon="r" onclick="editForumPost(@post.number)">Edit</a>
|
||||
<a class="mod button-hidden" id="edit-submit-button-@post.number" data-icon="t" onclick="submitEdit(@post.number, '@post.id')">Submit</a>
|
||||
<a class="mod button-hidden" id="edit-cancel-button-@post.number" data-icon="s" onclick="cancelEdit(@post.number)">Cancel</a>
|
||||
|
||||
<div class="edit-buttons">
|
||||
<a class="mod" id="edit-button-@post.number" data-icon="r" onclick="editForumPost(@post.number)">Edit</a>
|
||||
<a class="mod button-hidden" id="edit-submit-button-@post.number" data-icon="t" onclick="submitEdit(@post.number, '@post.id')">Submit</a>
|
||||
<a class="mod button-hidden" id="edit-cancel-button-@post.number" data-icon="s" onclick="cancelEdit(@post.number)">Cancel</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -41,10 +41,7 @@ case class Post(
|
|||
}
|
||||
|
||||
def editedTooSoonAfterLastEdit(currentTime: DateTime) = {
|
||||
editHistory match {
|
||||
case Nil => true
|
||||
case lastEdit :: _ => lastEdit.createdAt.plus(coolOffBetweenEdits.toMillis).isAfter(currentTime)
|
||||
}
|
||||
editHistory.length > 3 && createdAt.plus(coolOffBetweenEdits.toMillis).isAfter(currentTime)
|
||||
}
|
||||
|
||||
def canBeEditedBy(editingId: Option[String]) : Boolean = editingId.isDefined && editingId == userId
|
||||
|
|
|
@ -82,7 +82,7 @@ final class PostApi(
|
|||
case Some((_, post)) if !post.canBeEditedBy(ctx.username) =>
|
||||
fufail("You are not authorized to modify this post.")
|
||||
case Some((_,post)) =>
|
||||
val newPost = post.editPost(DateTime.now, newText)
|
||||
val newPost = post.editPost(now, newText)
|
||||
env.postColl.update($id(post.id), newPost) >> fuccess(newPost)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ var editForumPost = function(postNumber) {
|
|||
|
||||
var postContents = oldContents.text();
|
||||
|
||||
var editableArea = $("<textarea id='post-edit-area-" + postNumber + "' style='width: 100%; height:300px'>");
|
||||
var editableArea = $("<textarea id='post-edit-area-" + postNumber + "' class='edit-post-box'>");
|
||||
|
||||
editableArea.text(postContents);
|
||||
|
||||
|
|
|
@ -183,10 +183,15 @@ div.post .message {
|
|||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
div.post .edit-button {
|
||||
div.post .edit-buttons {
|
||||
float: right;
|
||||
}
|
||||
|
||||
div.post .edit-post-box {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
div.post .button-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue