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[:nocomment] = true
options[:variant] ||= :outline options[:variant] ||= :outline
#options[:class] = options.fetch(:class, nil) #options[:class] = options.fetch(:class, nil)
options[:class] = "size-5" unless options[:class]
path = options.fetch(:path, "icons/#{options[:variant]}/#{name}.svg") path = options.fetch(:path, "icons/#{options[:variant]}/#{name}.svg")
icon = path icon = path
inline_svg_tag(icon, options) inline_svg_tag(icon, options)

View File

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

View File

@@ -2,8 +2,8 @@
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap"> <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> <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>
<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"> <%= job.costumer_fullname %> </td>
<td class="p-3 text-sm text-hsrm-gray whitespace-nowrap"> <td class="p-3 text-sm text-hsrm-gray whitespace-nowrap w-6">
<% if job.pdf.attached? %> <% 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 %> <% end %>
@@ -25,9 +25,11 @@
<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>
<td class="p-3 text-sm text-left text-hsrm-gray whitespace-nowrap"> <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? %> <% 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 %> <% end %>
</td> </td>
</tr> </tr>

View File

@@ -12,14 +12,13 @@ module.exports = {
fontFamily: { fontFamily: {
sans: ["Inter var", ...defaultTheme.fontFamily.sans], sans: ["Inter var", ...defaultTheme.fontFamily.sans],
}, },
},
extend: {
colors: { colors: {
"hsrm-red": "#c20008", "hsrm-red": "#c20008",
"hsrm-red-dark": "#af0007", "hsrm-red-dark": "#af0007",
"hsrm-red-light": "#e20009", "hsrm-red-light": "#e20009",
"hsrm-gray": "#3a3a3a", "hsrm-gray": "#3a3a3a",
"hsrm-gray-dark": "#212121", "hsrm-gray-dark": "#212121",
"hsrm-gray-light": "#4e4e4e",
"status-open": "#111827", // gray-900 "status-open": "#111827", // gray-900
"status-open-light": "#d1d5db", // gray-300 "status-open-light": "#d1d5db", // gray-300
"status-printing": "#713f12", // yellow-900 "status-printing": "#713f12", // yellow-900