Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Fixing indentation and I18n call
Browse files Browse the repository at this point in the history
  • Loading branch information
samkevin1 committed Mar 22, 2023
1 parent 64208b8 commit fdd0eba
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 90 deletions.
4 changes: 1 addition & 3 deletions app/controllers/new_admin/allocation_chart_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ class AllocationChartController < ApplicationController
layout "new_admin"

def index
allocations = AllocationsAndUnalocatedUsersQuery.new(Allocation).call

@allocations = allocations.decorate
@allocations = AllocationsAndUnalocatedUsersQuery.new(Allocation).call.decorate
end
end
end
20 changes: 6 additions & 14 deletions app/decorators/allocation_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,29 @@ def user_name
model.user.first_and_last_name
end

def project_name
model.project ? model.project.name : nil
end

def user_level
decorated_user(model).level
model.user.decorate.level
end

def user_specialty
decorated_user(model).specialty
model.user.decorate.specialty
end

def user_english_level
decorated_user(model).english_level
model.user.decorate.english_level
end

def user_skills
decorated_user(model).skills
model.user.decorate.skills
end

def allocation_end_at
def end_at
build_date(model.end_at)
end

private

def decorated_user(allocation)
UserDecorator.decorate(allocation.user)
end

def build_date(date)
date ? date.to_time.strftime("%d/%m/%Y") : I18n.t('not_allocated')
date ? I18n.l(date) : I18n.t('not_allocated')
end
end
5 changes: 3 additions & 2 deletions app/models/allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class Allocation < ApplicationRecord
if: :ongoing?

delegate :office_name, to: :user
delegate :name, to: :project, prefix: true, allow_nil: true

scope :ongoing, -> {
scope :ongoing, -> {
where(ongoing: true, user_id: User.active).order(start_at: :desc)
}
scope :finished, -> {
Expand Down Expand Up @@ -59,7 +60,7 @@ def end_before_start?

def unique_period
return unless Allocation.in_period(start_at, end_at).where.not(id: id).exists?(user_id: user_id)

errors.add(:start_at, :overlapped_period)
end
end
2 changes: 1 addition & 1 deletion app/views/application/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<svg class="w-6 h-6" data-darkreader-inline-stroke="" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"></path>
</svg>
<span class="ml-4"><%= I18n.t('allocation_chart') %></span>
<span class="ml-4"><%= t 'allocation_chart' %></span>
<% end %>
</li>
</ul>
Expand Down
131 changes: 62 additions & 69 deletions app/views/new_admin/allocation_chart/_allocations.html.erb
Original file line number Diff line number Diff line change
@@ -1,75 +1,68 @@
<table class="w-full whitespace-no-wrap ">
<thead>
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
<th class="px-4 py-3"><%= I18n.t('name') %></th>
<th class="px-4 py-3"><%= I18n.t('client') %></th>
<th class="px-4 py-3"><%= I18n.t('allocated_until') %></th>
<th class="px-4 py-3"><%= I18n.t('level') %></th>
<th class="px-4 py-3"><%= I18n.t('specialty') %></th>
<th class="px-4 py-3"><%= I18n.t('english_evaluation') %></th>
<th class="px-4 py-3"><%= I18n.t('skills') %></th>
</tr>
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
<th class="px-4 py-3"><%= t 'name' %></th>
<th class="px-4 py-3"><%= t 'client' %></th>
<th class="px-4 py-3"><%= t 'allocated_until' %></th>
<th class="px-4 py-3"><%= t 'level' %></th>
<th class="px-4 py-3"><%= t 'specialty' %></th>
<th class="px-4 py-3"><%= t 'english_evaluation' %></th>
<th class="px-4 py-3"><%= t 'skills' %></th>
</tr>
</thead>
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
<% allocations.each do |allocation| %>
<tr class="text-gray-700 dark:text-gray-400">
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400 font-semibold">
<%= allocation.name %>
</p>
</div>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.project_name %>
</p>
</div>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.allocation_end_at %>
</p>
</div>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.level %>
</p>
</div>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.specialty %>
</p>
</div>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.english_level %>
</p>
</div>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.skills %>
</p>
</div>
</div>
</td>
</tr>
<% end %>
<% allocations.each do |allocation| %>
<tr class="text-gray-700 dark:text-gray-400">
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400 font-semibold">
<%= allocation.user_name %>
</p>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.project_name %>
</p>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.end_at %>
</p>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.user_level %>
</p>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.user_specialty %>
</p>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.user_english_level %>
</p>
</div>
</td>
<td class="px-4 py-3">
<div class="flex items-center text-sm">
<p class="text-sm text-gray-600 dark:text-gray-400">
<%= allocation.user_skills %>
</p>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
2 changes: 1 addition & 1 deletion app/views/new_admin/allocation_chart/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% content_for :page_title do %>
<%= I18n.t('allocation_chart') %>
<%= t 'allocation_chart' %>
<% end %>

<div data-tab-id="allocation_chart" class="w-full overflow-hidden rounded-lg ring-1 ring-black ring-opacity-5">
Expand Down

0 comments on commit fdd0eba

Please sign in to comment.