Fixed icons in table

This commit is contained in:
2024-08-10 19:56:32 +02:00
parent d0c653d61a
commit 083ec5253a
4 changed files with 20 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ module ApplicationHelper
options[:nocomment] = true
options[:variant] ||= :outline
#options[:class] = options.fetch(:class, nil)
options[:class] = "size-5" unless options[:class]
path = options.fetch(:path, "icons/#{options[:variant]}/#{name}.svg")
icon = path
inline_svg_tag(icon, options)

View File

@@ -1,6 +1,6 @@
class Job < ApplicationRecord
belongs_to :operator, class_name: 'User', optional: true
belongs_to :costumer, class_name: 'User', optional: true
belongs_to :operator, class_name: "User", optional: true
belongs_to :costumer, class_name: "User", optional: true
has_one_attached :pdf, dependent: :purge
@@ -29,11 +29,11 @@ class Job < ApplicationRecord
scope :created_today, -> { created_on_day(Time.now) }
scope :created_on_day, lambda { |date|
where('created_at >= ? AND created_at <= ?', date.beginning_of_day, date.end_of_day)
where("created_at >= ? AND created_at <= ?", date.beginning_of_day, date.end_of_day)
}
scope :upgraded_today, -> { upgraded_on_day(Time.now) }
scope :upgraded_on_day, lambda { |date|
where('upgraded_at >= ? AND upgraded_at <= ?', date.beginning_of_day, date.end_of_day)
where("upgraded_at >= ? AND upgraded_at <= ?", date.beginning_of_day, date.end_of_day)
}
# Returns all jobs with status: open print ready_for_pickup and jobs from today with status: paid canceled
# paid: only updated_at today
@@ -42,7 +42,7 @@ class Job < ApplicationRecord
# NOTE: use Time.now instead of Date.today to take the timezone into account
where(status: %i[open printing ready_for_pickup])
.or(Job.where(status: %i[paid canceled])
.where('status_changed_at >= ?', Time.now.beginning_of_day))
.where("status_changed_at >= ?", Time.now.beginning_of_day))
# .in_status_order
.order(created_at: :desc)
.order(:costumer_firstname, :costumer_lastname)
@@ -50,17 +50,17 @@ class Job < ApplicationRecord
# .references(:pdf_attachment, :blob) # creates big join table
end
def fullname
[costumer_firstname, ' ', costumer_lastname].join
def costumer_fullname
[ costumer_firstname, " ", costumer_lastname ].join
end
def acceptable_pdf
return unless pdf.attached?
acceptable_types = ['application/pdf']
acceptable_types = [ "application/pdf" ]
errors.add(:pdf, 'is too big') unless pdf.blob.byte_size <= 100.megabyte
errors.add(:pdf, 'must be a PDF') unless acceptable_types.include?(pdf.content_type)
errors.add(:pdf, "is too big") unless pdf.blob.byte_size <= 100.megabyte
errors.add(:pdf, "must be a PDF") unless acceptable_types.include?(pdf.content_type)
end
def able_to_cancel?

View File

@@ -2,10 +2,10 @@
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap">
<span class="p-1.5 text-xs font-medium uppercase tracking-wider bg-opacity-50 text-status-<%= job.status %> bg-status-<%= job.status %>-light rounded-lg"><%= job.id %></span>
</td>
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap"> <%= job.fullname %> </td>
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap">
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap"> <%= job.costumer_fullname %> </td>
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap w-6">
<% if job.pdf.attached? %>
<%= image_tag url_for(job.pdf.preview(resize_to_limit: [100, 100])) %>
<%= image_tag url_for(job.pdf.preview(resize_to_limit: [100, 100])) %>
<% end %>
</td>
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap">
@@ -22,12 +22,14 @@
<td class="p-3 text-sm text-left text-hsrm-gray whitespace-nowrap"><span class="p-1.5 bg-gray-300 bg-opacity-50 font-medium rounded-lg"><%= job.costum_qm_plan.round(2) %> m²</span></td>
<td class="p-3 text-sm text-left text-hsrm-gray whitespace-nowrap"><span class="p-1.5 bg-gray-300 bg-opacity-50 font-medium rounded-lg"><%= job.cost.round(2) %> €</span></td>
<td class="p-3 text-sm text-left text-hsrm-gray whitespace-nowrap">
<span class="p-1.5 block text-xs font-medium uppercase tracking-wider bg-opacity-50 w-20 text-center text-status-<%= job.status.to_sym %> bg-status-<%= job.status %>-light rounded-lg"><%= job.status %></span>
<span class="p-1.5 block text-xs font-medium uppercase tracking-wider bg-opacity-50 w-20 text-center text-status-<%= job.status.to_sym %> bg-status-<%= job.status %>-light rounded-lg"><%= job.status %></span>
</td>
<td class="p-3 text-sm text-left text-hsrm-gray whitespace-nowrap">
<%= link_to icon("pencil", class: "size-5 inline"), edit_job_path(job), classe: "p-1.5 ml-2 rounded-lg bg-gray-300 bg-opacity-50 font-medium" %>
<%= link_to icon("pencil-square", class: "size-5 inline"), edit_job_path(job), classe: "p-1.5 ml-2 rounded-lg bg-gray-300 bg-opacity-50 font-medium" %>
<% if job.able_to_cancel? %>
<%= button_to "Abbrechen", cancel_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, class: "p-1.5 inline ml-2 rounded-lg bg-gray-100 font-medium" %>
<%= button_to icon("x-circle", class: "text-hsrm-red size-5 inline"), cancel_job_path(job), method: :patch, form: {data: {turbo_confirm: 'Den Plottauftrag wirklich abbrechen?'}}, form_class: "inline" %>
<% else %>
<%= icon("x-circle", class: "text-hsrm-gray text-opacity-50 size-5 inline") %>
<% end %>
</td>
</tr>