-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds the start of a staffplan, componentized a bit
- Loading branch information
Showing
16 changed files
with
114 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<tr> | ||
<td class="whitespace-nowrap py-2 pl-4 pr-3 text-sm text-gray-500 sm:pl-0 truncate" style="width: 200px;"> | ||
<%= @project.name %> | ||
</td> | ||
<%= render(AssignmentWorkWeeksComponent.new(assignment: @assignment, work_weeks: [])) %> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class AssignmentRowComponent < ViewComponent::Base | ||
def initialize(assignment:, work_weeks:) | ||
@assignment = assignment | ||
@project = @assignment.project | ||
@work_weeks = work_weeks | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<% 12.times do |count| %> | ||
<%= render(WorkWeekComponent.new(work_week: nil)) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class AssignmentWorkWeeksComponent < ViewComponent::Base | ||
def initialize(assignment:, work_weeks:) | ||
@assignment = assignment | ||
@work_weeks = work_weeks | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<tr class="border-t border-gray-200"> | ||
<th colspan="8" scope="colgroup" class="bg-gray-50 py-2 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-3"> | ||
<%= @client.name %> | ||
</th> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class ClientRowComponent < ViewComponent::Base | ||
def initialize(client:) | ||
@client = client | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
app/components/staff_plan_column_header_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<thead> | ||
<tr> | ||
<th> </th> | ||
<% 12.times do |count| %> | ||
<th scope="col" class="whitespace-nowrap px-2 py-3.5 text-left text-sm font-semibold text-gray-900"> | ||
<%= Time.at(date_plus_count(count)).to_date.strftime("%m/%d") %> | ||
</th> | ||
<% end %> | ||
</tr> | ||
</thead> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class StaffPlanColumnHeaderComponent < ViewComponent::Base | ||
def initialize(beginning_of_week:) | ||
@beginning_of_week = beginning_of_week | ||
end | ||
|
||
def date_plus_count(count) | ||
(@beginning_of_week + count.weeks).to_i | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<td class="whitespace-nowrap px-2 py-2 text-sm text-gray-500">work week</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class WorkWeekComponent < ViewComponent::Base | ||
def initialize(work_week:) | ||
@work_week = work_week | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
<% content_for(:header) do %> | ||
<%= current_user == @viewing_user ? "My StaffPlan" : "#{@viewing_user.name}'s StaffPlan" %> | ||
<% end %> | ||
<% end %> | ||
|
||
<div class="px-4 sm:px-6 lg:px-8"> | ||
<div class="mt-8 flow-root"> | ||
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | ||
<div class="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8"> | ||
<table class="min-w-full divide-y divide-gray-300"> | ||
<%= render(StaffPlanColumnHeaderComponent.new(beginning_of_week: @query.beginning_of_week)) %> | ||
<tbody class="divide-y divide-gray-200 bg-white"> | ||
<% @query.clients.each do |client| %> | ||
<%= render(ClientRowComponent.new(client:)) %> | ||
<% @query.projects_for(client: client).each do |project| %> | ||
<%= render(AssignmentRowComponent.new(assignment: @query.assignment_for(project:), work_weeks: @query.work_weeks_for(project:))) %> | ||
<% end %> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |