mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 05:34:55 +08:00
Fixes issue with new comments and date separator SCI-557
This commit is contained in:
parent
fa4f3fb0a0
commit
0c1ff06f21
5 changed files with 32 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -77,7 +77,8 @@ class MyModuleCommentsController < ApplicationController
|
|||
locals: {
|
||||
comment: @comment
|
||||
}
|
||||
})
|
||||
}),
|
||||
date: @comment.created_at.strftime('%d.%m.%Y')
|
||||
},
|
||||
status: :created
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ class ProjectCommentsController < ApplicationController
|
|||
locals: {
|
||||
comment: @comment
|
||||
}
|
||||
})
|
||||
}),
|
||||
date: @comment.created_at.strftime('%d.%m.%Y')
|
||||
}, status: :created
|
||||
}
|
||||
else
|
||||
|
|
|
@ -74,7 +74,8 @@ class ResultCommentsController < ApplicationController
|
|||
locals: {
|
||||
comment: @comment
|
||||
}
|
||||
})
|
||||
}),
|
||||
date: @comment.created_at.strftime('%d.%m.%Y')
|
||||
},
|
||||
status: :created
|
||||
}
|
||||
|
|
|
@ -78,7 +78,8 @@ class StepCommentsController < ApplicationController
|
|||
locals: {
|
||||
comment: @comment
|
||||
}
|
||||
})
|
||||
}),
|
||||
date: @comment.created_at.strftime('%d.%m.%Y')
|
||||
},
|
||||
status: :created
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue