Fixes issue with new comments and date separator SCI-557

This commit is contained in:
Oleksii Kriuchykhin 2016-10-20 22:33:15 +02:00
parent fa4f3fb0a0
commit 0c1ff06f21
5 changed files with 32 additions and 4 deletions

View file

@ -100,6 +100,30 @@ var Comments = (function() {
list.parent().find('.content-comments')
.find('li.no-comments').remove();
// Find previous date separator
var dateSeparator = list.parent().find('.comment-date-separator:last');
if (dateSeparator.length > 0) {
// Parse string with creation date
var pr = dateSeparator.text().split('.');
var comm = data.date.split('.');
// Build Date objects and compare
var sepDate = new Date(pr[2], pr[1] - 1, pr[0]);
var commDate = new Date(comm[2], comm[1] - 1, comm[0]);
if (commDate > sepDate) {
// Add date separator
list.parent().find('.content-comments')
.append('<li class="comment-date-separator">\
<p class="text-center">' + data.date + '</p>\
</li>');
}
} else {
// Comment is the first one so add date separator
list.parent().find('.content-comments')
.append('<li class="comment-date-separator">\
<p class="text-center">' + data.date + '</p>\
</li>');
}
list.parent().find('.content-comments')
.append('<li class="comment">' + data.html + '</li>')
.scrollTop(0);

View file

@ -77,7 +77,8 @@ class MyModuleCommentsController < ApplicationController
locals: {
comment: @comment
}
})
}),
date: @comment.created_at.strftime('%d.%m.%Y')
},
status: :created
}

View file

@ -76,7 +76,8 @@ class ProjectCommentsController < ApplicationController
locals: {
comment: @comment
}
})
}),
date: @comment.created_at.strftime('%d.%m.%Y')
}, status: :created
}
else

View file

@ -74,7 +74,8 @@ class ResultCommentsController < ApplicationController
locals: {
comment: @comment
}
})
}),
date: @comment.created_at.strftime('%d.%m.%Y')
},
status: :created
}

View file

@ -78,7 +78,8 @@ class StepCommentsController < ApplicationController
locals: {
comment: @comment
}
})
}),
date: @comment.created_at.strftime('%d.%m.%Y')
},
status: :created
}