Skip to content

Commit

Permalink
Prevents date fields to be submitted manually
Browse files Browse the repository at this point in the history
  • Loading branch information
Kostas Sklias committed Dec 14, 2023
1 parent caf8a78 commit 1edc807
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/assets/javascripts/tylium/pages/activities.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ document.addEventListener('turbolinks:load', function() {
}

$(function() {

$('[data-behavior~=activity-filters]').change(function() {
$(this).submit();
});

$('[data-behavior~=activity-filters]').keydown(function() {
return false
});
});
});


2 changes: 1 addition & 1 deletion app/views/activities/_filters.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<%= f.label :period_start, class: 'visually-hidden' %>
<span class="input-group-text input-group-sm">to</span>
<%= f.label :period_end, class: 'visually-hidden' %>
<%= f.date_field :period_end, max: Date.today, placeholder: 'To date', value: params[:period_end] || Date.today, class: 'form-control form-control-sm' %>
<%= f.date_field :period_end, max: Date.today, min: params[:period_start] placeholder: 'To date', value: params[:period_end] || Date.today, class: 'form-control form-control-sm' %>
</div>

<%= link_to project_activities_path(current_project.id), class: 'text-error-hover text-nowrap d-flex align-items-center' do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/activities/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</nav>
<% end %>

<div class="content-container mt-3 py-3">
<div class="content-container mt-3 py-3 activity-filters">
<%= render 'activities/filters' %>
</div>

Expand Down

0 comments on commit 1edc807

Please sign in to comment.