Fix redirects and badge

This commit is contained in:
Chris Veleris 2023-11-13 18:00:58 +02:00
parent aa408a85dc
commit 1cb45fcfa1
3 changed files with 10 additions and 10 deletions

View file

@ -17,7 +17,7 @@ class Sinatra::Application
area.name = params[:name]
if area.save
redirect '/'
redirect request.referrer || '/'
else
@errors = 'There was a problem updating the area.'
erb :some_template
@ -33,7 +33,7 @@ class Sinatra::Application
if area
area.destroy
redirect '/'
redirect request.referrer || '/'
else
status 404
@errors = 'Area not found or not owned by the current user.'

View file

@ -72,7 +72,7 @@ class Sinatra::Application
end
if task.update(task_attributes)
redirect '/'
redirect request.referrer || '/'
else
halt 400, 'There was a problem updating the task.'
end
@ -100,7 +100,7 @@ class Sinatra::Application
halt 404, 'Task not found.' unless task
if task.destroy
redirect '/'
redirect request.referrer || '/'
else
halt 400, 'There was a problem deleting the task.'
end

View file

@ -5,18 +5,18 @@
</span>
<%= task.name %>
</div>
<div class="ms-3 d-flex align-items-center">
<div class="">
<% if task.due_date %>
<% if task.due_date.to_date == Date.today %>
<span class="badge bg-success rounded-pill ms-2">
<i class="bi bi-calendar me-2"></i> TODAY
<span class="badge bg-primary rounded ms-2">
<i class="bi bi-clock me-2"></i> TODAY
</span>
<% elsif task.due_date && task.due_date.to_date < Date.today %>
<span class="badge bg-danger rounded-pill ms-2">
<i class="bi bi-calendar me-2"></i> <%= task.due_date.strftime("%Y-%m-%d") %>
<span class="badge bg-danger rounded ms-2">
<i class="bi bi-clock me-2"></i> <%= task.due_date.strftime("%Y-%m-%d") %>
</span>
<% else %>
<span class="badge bg-info rounded-pill ms-2">
<span class="badge bg-warning text-dark rounded ms-2">
<i class="bi bi-clock me-2"></i> <%= task.due_date.strftime("%Y-%m-%d") %>
</span>
<% end %>