Skip to content

Commit

Permalink
Added Datepicker for events
Browse files Browse the repository at this point in the history
  • Loading branch information
imajit committed Mar 2, 2021
1 parent 452a75b commit 26515d3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
19 changes: 19 additions & 0 deletions app/assets/javascripts/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,23 @@ jQuery(document).ready(function($) {
$('.activity-comment#i-did-this').find('button.btn-primary').click(function(e) {
$('.activity-comment#i-did-this').hide();
});
$(".datepicker").datepicker({format: 'mm-dd-yyyy'});
$("#collapse-button").click(function(){
$(this).remove();
});
$(function() {
$("img").lazyload();
});
$("#event-datepicker").hide();
$("#date-toggle").click(function(){
$("#event-datepicker").toggle();
});
$("#save-event-date").click(function(){
eventDate= $(".datepicker").datepicker();
if(eventDate!== null)
{
addTag("date:"+eventDate.val());
alert("Event date has been added");
}
});
});
17 changes: 9 additions & 8 deletions app/views/notes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@
</table>
<% end %>

<% if current_user && (current_user.role == "admin" || current_user.role == "moderator" || current_user.id == @node.id || current_user.is_coauthor?(@node)) && @node.has_tag('event') %>
<hr/>
<p>This looks like an event. <span><button id="date-toggle" class="btn-outline-secondary btn-sm" data-toggle="tooltip" data-placement="right" title="Add Date"><i class="fa fa-calendar" aria-hidden="true"></i></button></span></p>
<div id="event-datepicker">
<input type="text" class="datepicker"/>
<span><button id="save-event-date" class="btn-outline-secondary btn-sm">Save Date</button></span>
</div>
<% end %>

<div class="d-print-none">
<hr />

Expand Down Expand Up @@ -142,11 +151,3 @@
border-radius: 3px;
}
</style>
<script>
$("#collapse-button").click(function(){
$(this).remove();
});
$(function() {
$("img").lazyload();
});
</script>

0 comments on commit 26515d3

Please sign in to comment.