diff --git a/.github/workflows/rspec-test-suite.yml b/.github/workflows/rspec-test-suite.yml
index ac772cdb..b967dd62 100644
--- a/.github/workflows/rspec-test-suite.yml
+++ b/.github/workflows/rspec-test-suite.yml
@@ -29,7 +29,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
- uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
+ uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Set up database schema
diff --git a/.ruby-version b/.ruby-version
index 944880fa..15a27998 100644
--- a/.ruby-version
+++ b/.ruby-version
@@ -1 +1 @@
-3.2.0
+3.3.0
diff --git a/Dockerfile b/Dockerfile
index a885e566..2c1e8b4c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,7 @@
# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
-ARG RUBY_VERSION=3.2.0
+ARG RUBY_VERSION=3.3.0
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
# Rails app lives here
diff --git a/Gemfile b/Gemfile
index 81ef3c3f..d9f069cf 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
source "https://rubygems.org"
-ruby "3.2.0"
+ruby "3.3.0"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "7.1.2"
diff --git a/Gemfile.lock b/Gemfile.lock
index 4077b046..c58bc7b2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -330,7 +330,7 @@ DEPENDENCIES
web-console
RUBY VERSION
- ruby 3.2.0p0
+ ruby 3.3.0p0
BUNDLED WITH
2.4.7
diff --git a/app/components/staff_plan/assignment_component.html.erb b/app/components/staff_plan/assignment_component.html.erb
deleted file mode 100644
index 4ba89ad3..00000000
--- a/app/components/staff_plan/assignment_component.html.erb
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- <%= @project.name %>
-
-
- <%= render(StaffPlan::WorkWeeksComponent.new(assignment: @assignment, beginning_of_week: @beginning_of_week)) %>
-
-
\ No newline at end of file
diff --git a/app/components/staff_plan/assignment_component.rb b/app/components/staff_plan/assignment_component.rb
deleted file mode 100644
index 73c5cadd..00000000
--- a/app/components/staff_plan/assignment_component.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# frozen_string_literal: true
-
-module StaffPlan
- class AssignmentComponent < ViewComponent::Base
- def initialize(assignment:, work_weeks:, beginning_of_week:)
- @assignment = assignment
- @project = @assignment.project
- @work_weeks = work_weeks
- @beginning_of_week = beginning_of_week
- end
-
- end
-
-end
diff --git a/app/components/staff_plan/client_component.html.erb b/app/components/staff_plan/client_component.html.erb
deleted file mode 100644
index d2d63955..00000000
--- a/app/components/staff_plan/client_component.html.erb
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- <%= @client.name %>
-
-
-
-
-
- <% @query.projects_for(client: @client).each do |project| %>
- <%= render(StaffPlan::AssignmentComponent.new(
- assignment: @query.assignment_for(project:),
- work_weeks: @query.work_weeks_for(project:),
- beginning_of_week: @query.beginning_of_week))
- %>
- <% end %>
-
\ No newline at end of file
diff --git a/app/components/staff_plan/client_component.rb b/app/components/staff_plan/client_component.rb
deleted file mode 100644
index 51ae5155..00000000
--- a/app/components/staff_plan/client_component.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-module StaffPlan
- class ClientComponent < ViewComponent::Base
- def initialize(client:, query:)
- @client = client
- @query = query
- end
- end
-end
\ No newline at end of file
diff --git a/app/components/staff_plan/header_component.html.erb b/app/components/staff_plan/header_component.html.erb
deleted file mode 100644
index 76681072..00000000
--- a/app/components/staff_plan/header_component.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-
\ No newline at end of file
diff --git a/app/components/staff_plan/header_component.rb b/app/components/staff_plan/header_component.rb
deleted file mode 100644
index 8ba4ba52..00000000
--- a/app/components/staff_plan/header_component.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-module StaffPlan
- class HeaderComponent < 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
-end
\ No newline at end of file
diff --git a/app/components/staff_plan/main_component.html.erb b/app/components/staff_plan/main_component.html.erb
deleted file mode 100644
index 465d53f3..00000000
--- a/app/components/staff_plan/main_component.html.erb
+++ /dev/null
@@ -1,79 +0,0 @@
-<%= tag.turbo_frame id: helpers.user_staff_plan_turbo_frame_id(@viewing_user) do %>
-
-
-
-
-
- <%= render(StaffPlan::HeaderComponent.new(beginning_of_week: @beginning_of_week)) %>
- <% @query.clients.each do |client| %>
- <%= render(StaffPlan::ClientComponent.new(client: client, query: @query)) %>
- <% end %>
-
-
-
-
-
-
-
-<% end %>
\ No newline at end of file
diff --git a/app/components/staff_plan/main_component.rb b/app/components/staff_plan/main_component.rb
deleted file mode 100644
index c909d51f..00000000
--- a/app/components/staff_plan/main_component.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-module StaffPlan
- class MainComponent < ViewComponent::Base
- def initialize(query:, viewing_user:, beginning_of_week:)
- @query = query
- @viewing_user = viewing_user
- @beginning_of_week = beginning_of_week
- end
- end
-end
diff --git a/app/components/staff_plan/work_week_component.html.erb b/app/components/staff_plan/work_week_component.html.erb
deleted file mode 100644
index 426a3d74..00000000
--- a/app/components/staff_plan/work_week_component.html.erb
+++ /dev/null
@@ -1,20 +0,0 @@
-
- <%= tag.turbo_frame id: turbo_frame_id do %>
- <%= form_for @work_week, url: form_path, data: { work_week_target: "form" } do |form| %>
- <%= hidden_field_tag :assignment_id, @assignment.id %>
- <%= hidden_field_tag :beginning_of_week, @beginning_of_week %>
- <%= hidden_field_tag :count, @count %>
- <%= form.hidden_field :cweek %>
- <%= form.hidden_field :year %>
- <%= form.hidden_field :beginning_of_week %>
- <%= form.text_field :estimated_hours,
- class: "block w-12 rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6 mb-1 text-center mx-auto",
- data: { action: "blur->work-week#submit", work_week_target: "proposedInput" } %>
-
- <%= form.text_field :actual_hours,
- class: "block w-12 rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6 text-center mx-auto",
- style: "#{render_actual_hours? ? '' : 'visibility: hidden;'}",
- data: { action: "blur->work-week#submit", work_week_target: "actualInput" } %>
- <% end %>
- <% end %>
-
\ No newline at end of file
diff --git a/app/components/staff_plan/work_week_component.rb b/app/components/staff_plan/work_week_component.rb
deleted file mode 100644
index a0d7ea45..00000000
--- a/app/components/staff_plan/work_week_component.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-# frozen_string_literal: true
-
-module StaffPlan
- class WorkWeekComponent < ViewComponent::Base
- def initialize(work_week: nil, assignment:, work_week_beginning_of_week:, beginning_of_week:, count:)
- @assignment = assignment
- @work_week_beginning_of_week = work_week_beginning_of_week
- @beginning_of_week = beginning_of_week
- @work_week = work_week || new_work_week
- @count = count
- end
-
- def actual_hours
- @work_week.actual_hours
- end
-
- def estimated_hours
- @work_week.estimated_hours
- end
-
- def work_week_form(&block)
- form_for @work_week, url: form_path, data: { work_week_target: "form" } do |form|
- yield(form)
- end
- end
-
- def render_actual_hours?
- # only allow input for work weeks that are the current week or in the past
- Time.zone.now.at_beginning_of_week.to_i >= @work_week_beginning_of_week
- end
-
- def turbo_frame_id
- helpers.work_week_turbo_frame_id(@work_week)
- end
-
- def form_path
- if @work_week.persisted?
- staff_plans_work_week_path(@work_week)
- else
- staff_plans_work_weeks_path
- end
- end
-
- private
-
-
-
- def new_work_week
- date = Time.at(@work_week_beginning_of_week.to_i).to_date
-
- @assignment.work_weeks.new(
- assignment: @assignment,
- beginning_of_week: @work_week_beginning_of_week,
- cweek: date.cweek,
- year: date.year
- )
- end
- end
-
-end
\ No newline at end of file
diff --git a/app/components/staff_plan/work_weeks_component.html.erb b/app/components/staff_plan/work_weeks_component.html.erb
deleted file mode 100644
index 726eb696..00000000
--- a/app/components/staff_plan/work_weeks_component.html.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-
- <% 16.times do |count| %>
- <% work_week_beginning_of_week = @beginning_of_week + count.weeks %>
- <%= render(StaffPlan::WorkWeekComponent.new(
- work_week: work_week_for(work_week_beginning_of_week),
- assignment: @assignment,
- work_week_beginning_of_week: work_week_beginning_of_week,
- beginning_of_week: @beginning_of_week,
- count: count
- )) %>
- <% end %>
-
\ No newline at end of file
diff --git a/app/components/staff_plan/work_weeks_component.rb b/app/components/staff_plan/work_weeks_component.rb
deleted file mode 100644
index ccf6ef01..00000000
--- a/app/components/staff_plan/work_weeks_component.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-module StaffPlan
- class WorkWeeksComponent < ViewComponent::Base
- def initialize(assignment:, beginning_of_week: nil)
- @assignment = assignment
- @beginning_of_week = beginning_of_week
- @work_weeks = assignment.work_weeks
- end
-
- def work_week_for(beginning_of_week)
- @work_weeks.detect { |work_week| work_week.beginning_of_week == beginning_of_week }
- end
- end
-
-end
\ No newline at end of file
diff --git a/app/controllers/staff_plans/users_controller.rb b/app/controllers/staff_plans/users_controller.rb
deleted file mode 100644
index 1812d307..00000000
--- a/app/controllers/staff_plans/users_controller.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-class StaffPlans::UsersController < ApplicationController
- before_action :require_user!
-
- before_action :redirect_to_user_id, only: [:show]
-
- def show
- @viewing_user = current_company.users.find(params[:id])
- @beginning_of_week = beginning_of_week.at_beginning_of_day.to_i
- @query = Queries::UserStaffPlan.new(
- user: @viewing_user,
- company: current_company,
- beginning_of_week: beginning_of_week
- )
- end
-
- private
-
- def beginning_of_week
- date = if params[:beginning_of_week].present?
- Time.at(params[:beginning_of_week].to_i).to_date
- else
- Date.today
- end
- date.beginning_of_week
- end
-
- def redirect_to_user_id
- redirect_to staff_plans_user_url(current_user) if params[:id].blank?
- end
-end
diff --git a/app/controllers/staff_plans/work_weeks_controller.rb b/app/controllers/staff_plans/work_weeks_controller.rb
deleted file mode 100644
index b37122b1..00000000
--- a/app/controllers/staff_plans/work_weeks_controller.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-class StaffPlans::WorkWeeksController < ApplicationController
- before_action :require_user!
-
- before_action :set_beginning_of_week
- before_action :set_count
- def create
- @work_week = assignment.work_weeks.create(create_work_week_params)
- end
-
- def update
- @work_week = assignment.work_weeks.find(params[:id])
- @work_week.update(create_work_week_params)
- end
-
- private
-
- def set_beginning_of_week
- @beginning_of_week = params[:beginning_of_week].to_i
- end
-
- def set_count
- @count = params[:count].to_i
- end
-
- def create_work_week_params
- params.require(:work_week).permit(:estimated_hours, :actual_hours, :cweek, :year)
- end
-
- def edit_work_week_params
- params.require(:work_week).permit(:estimated_hours, :actual_hours, :cweek, :year)
- end
-
- def assignment
- current_user.assignments.find(params[:assignment_id])
- end
-end
diff --git a/app/controllers/work_weeks_controller.rb b/app/controllers/work_weeks_controller.rb
index 32f61050..823b91c9 100644
--- a/app/controllers/work_weeks_controller.rb
+++ b/app/controllers/work_weeks_controller.rb
@@ -27,10 +27,8 @@ def create
respond_to do |format|
if @work_week.save
format.html { redirect_to work_week_url(@work_week), notice: "Work week was successfully created." }
- format.json { render :show, status: :created, location: @work_week }
else
format.html { render :new, status: :unprocessable_entity }
- format.json { render json: @work_week.errors, status: :unprocessable_entity }
end
end
end
@@ -40,10 +38,8 @@ def update
respond_to do |format|
if @work_week.update(work_week_params)
format.html { redirect_to work_week_url(@work_week), notice: "Work week was successfully updated." }
- format.json { render :show, status: :ok, location: @work_week }
else
format.html { render :edit, status: :unprocessable_entity }
- format.json { render json: @work_week.errors, status: :unprocessable_entity }
end
end
end
@@ -66,6 +62,6 @@ def set_work_week
# Only allow a list of trusted parameters through.
def work_week_params
- params.require(:work_week).permit(:estimated_hours, :actual_hours, :cweek, :year, :assignment_id, :beginning_of_week)
+ params.require(:work_week).permit(:estimated_hours, :actual_hours, :cweek, :year, :assignment_id)
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 7a8e9858..985307e5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -23,15 +23,4 @@ def user_gravatar(user:, css_classes: "h-8 w-8 rounded-full")
gravatar_url = "http://secure.gravatar.com/avatar/#{gravatar_id}"
image_tag(gravatar_url, alt: user.name, class: css_classes)
end
-
- def user_staff_plan_turbo_frame_id(viewing_user)
- "staff_plan:u:#{viewing_user.id}|c:#{current_user.current_company_id}"
- end
-
- def work_week_turbo_frame_id(work_week)
- frame_id = "work_week|a:#{work_week.assignment.id}"
- frame_id += "|u:#{work_week.assignment.user.id}|bow:#{work_week.beginning_of_week}"
- frame_id += "|cweek:#{work_week.cweek}|year:#{work_week.year}"
- frame_id
- end
end
diff --git a/app/javascript/controllers/work_week_controller.js b/app/javascript/controllers/work_week_controller.js
deleted file mode 100644
index e4bbb0a8..00000000
--- a/app/javascript/controllers/work_week_controller.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import { ApplicationController, useDebounce } from 'stimulus-use'
-
-// Connects to data-controller="work-week"
-export default class extends ApplicationController {
- static targets = ["proposedInput", "actualInput", "form"]
- static debounces = [{ name: "submit", wait: 200 }]
-
- connect() {
- useDebounce(this)
- }
-
- disconnect() {
- }
-
- submit() {
- this.formTarget.requestSubmit()
- }
-}
diff --git a/app/lib/queries/.keep b/app/lib/queries/.keep
new file mode 100644
index 00000000..e69de29b
diff --git a/app/lib/queries/user_staff_plan.rb b/app/lib/queries/user_staff_plan.rb
deleted file mode 100644
index 5a3ca916..00000000
--- a/app/lib/queries/user_staff_plan.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-module Queries
- class UserStaffPlan
- attr_reader :user, :company, :beginning_of_week
-
- def initialize(user:, company:, beginning_of_week:)
- raise ArgumentError, "user must be a User" unless user.is_a?(User)
- raise ArgumentError, "company must be a Company" unless company.is_a?(Company)
-
- @user = user
- @company = company
- @beginning_of_week = beginning_of_week.to_datetime.to_i
- @assignments = user.
- assignments.
- where(project: company.projects.active).
- includes(work_weeks: :assignment, project: :client).
- order('clients.name')
- end
-
- def assignment_for(project:)
- @assignments.find { |assignment| assignment.project == project }
- end
-
- def work_weeks
- @_work_weeks ||= @assignments.flat_map(&:work_weeks)
- end
-
- def work_weeks_for(project:)
- work_weeks.select { |work_week| work_week.assignment.project_id == project.id }
- end
-
- def clients
- @_clients ||= @assignments.flat_map(&:project).map(&:client).uniq
- end
-
- def projects_for(client:)
- @assignments.map { |assignment| assignment.project if assignment.project.client == client }.compact
- end
-
- def previous_week(diff)
- (beginning_of_week - diff.weeks).to_i
- end
-
- def next_week(diff)
- (beginning_of_week + diff.weeks).to_i
- end
- end
-end
\ No newline at end of file
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 2b9893d5..0858e6d1 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -23,7 +23,7 @@
- <%= header_link_to "My StaffPlan", staff_plans_path %>
+ <%= header_link_to "My StaffPlan", "#" %>
Clients
Projects
People
@@ -95,7 +95,7 @@