diff --git a/app/controllers/new_admin/allocation_chart_controller.rb b/app/controllers/new_admin/allocation_chart_controller.rb index 3a1039f39..8ccbfbc58 100644 --- a/app/controllers/new_admin/allocation_chart_controller.rb +++ b/app/controllers/new_admin/allocation_chart_controller.rb @@ -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 diff --git a/app/decorators/allocation_decorator.rb b/app/decorators/allocation_decorator.rb index b7b5b40ac..6e20be26c 100644 --- a/app/decorators/allocation_decorator.rb +++ b/app/decorators/allocation_decorator.rb @@ -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 diff --git a/app/models/allocation.rb b/app/models/allocation.rb index 47d0bb73e..4574d891a 100644 --- a/app/models/allocation.rb +++ b/app/models/allocation.rb @@ -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, -> { @@ -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 diff --git a/app/views/application/_sidebar.html.erb b/app/views/application/_sidebar.html.erb index 0a1eddd88..9f6079016 100644 --- a/app/views/application/_sidebar.html.erb +++ b/app/views/application/_sidebar.html.erb @@ -19,7 +19,7 @@ - <%= I18n.t('allocation_chart') %> + <%= t 'allocation_chart' %> <% end %> diff --git a/app/views/new_admin/allocation_chart/_allocations.html.erb b/app/views/new_admin/allocation_chart/_allocations.html.erb index 4ff0b81e4..a5dee8a47 100644 --- a/app/views/new_admin/allocation_chart/_allocations.html.erb +++ b/app/views/new_admin/allocation_chart/_allocations.html.erb @@ -1,75 +1,68 @@
<%= I18n.t('name') %> | -<%= I18n.t('client') %> | -<%= I18n.t('allocated_until') %> | -<%= I18n.t('level') %> | -<%= I18n.t('specialty') %> | -<%= I18n.t('english_evaluation') %> | -<%= I18n.t('skills') %> | -
---|---|---|---|---|---|---|
<%= t 'name' %> | +<%= t 'client' %> | +<%= t 'allocated_until' %> | +<%= t 'level' %> | +<%= t 'specialty' %> | +<%= t 'english_evaluation' %> | +<%= t 'skills' %> | +
-
-
-
- - <%= allocation.name %> - - |
-
-
-
-
- - <%= allocation.project_name %> - - |
-
-
-
-
- - <%= allocation.allocation_end_at %> - - |
-
-
-
-
- - <%= allocation.level %> - - |
-
-
-
-
- - <%= allocation.specialty %> - - |
-
-
-
-
- - <%= allocation.english_level %> - - |
-
-
-
-
- - <%= allocation.skills %> - - |
-
+
+
+ + <%= allocation.user_name %> + + |
+
+
+
+ + <%= allocation.project_name %> + + |
+
+
+
+ + <%= allocation.end_at %> + + |
+
+
+
+ + <%= allocation.user_level %> + + |
+
+
+
+ + <%= allocation.user_specialty %> + + |
+
+
+
+ + <%= allocation.user_english_level %> + + |
+
+
+
+ + <%= allocation.user_skills %> + + |
+