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 c7f1acf commit bfedcb5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/tylium/modules.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import 'tylium/modules/activities';
@import 'tylium/modules/alerts';
@import 'tylium/modules/attachments';
@import 'tylium/modules/buttons';
Expand Down
16 changes: 16 additions & 0 deletions app/assets/stylesheets/tylium/modules/activities.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.activity-filters {
input[type="date"] {
position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
padding: 0;
color: transparent;
background: transparent;
}
}
4 changes: 2 additions & 2 deletions app/views/activities/_filters.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<span class="form-label mb-2 d-block">Date range</span>
<div class="d-flex flex-column flex-sm-row gap-3 w-100">
<div class="input-group">
<%= f.date_field :period_start, max: Date.today, placeholder: 'From date', value: params[:period_start], class: 'form-control form-control-sm' %>
<%= f.date_field :period_start, max: params[:period_end], placeholder: 'From date', value: params[:period_start], class: 'form-control form-control-sm', onkeydown: "return false" %>
<%= 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', onkeydown: "return false" %>
</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 bfedcb5

Please sign in to comment.