diff --git a/app/assets/stylesheets/_bootstrap_overrides.scss b/app/assets/stylesheets/_bootstrap_overrides.scss index d71920a..1948109 100644 --- a/app/assets/stylesheets/_bootstrap_overrides.scss +++ b/app/assets/stylesheets/_bootstrap_overrides.scss @@ -14,6 +14,7 @@ $red: #F9002B; $green: #51B61B; $teal: #32C498; $purple: #5139EE; +$yellow: #F9BE1B; $dark: $gray-900; $success: $teal; $link-color: $body-color; diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d7242bb..ffbf3b1 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -32,14 +32,14 @@ &.release-me { span:last-child { background-color: $teal; - color: $body-color; + color: $white; } } &.direct-me { span:last-child { background-color: $green; - color: $body-color; + color: $white; } } @@ -53,7 +53,14 @@ &.deliver-me { span:last-child { background-color: $purple; - color: white; + color: $white; + } + } + + &.task-me { + span:last-child { + background-color: $yellow; + color: $white; } } diff --git a/app/controllers/admin/task_requests_controller.rb b/app/controllers/admin/task_requests_controller.rb index 89c8ba3..ed94957 100644 --- a/app/controllers/admin/task_requests_controller.rb +++ b/app/controllers/admin/task_requests_controller.rb @@ -1,5 +1,5 @@ class Admin::TaskRequestsController < Admin::ApplicationController - before_action :set_task_request, only: [:edit, :update] + before_action :set_task_request, only: [:edit, :update, :show] def index @task_requests = task_requests.order_by_recent.paginate(page: params[:page]) diff --git a/app/controllers/task_requests_controller.rb b/app/controllers/task_requests_controller.rb index f50389e..c34964a 100644 --- a/app/controllers/task_requests_controller.rb +++ b/app/controllers/task_requests_controller.rb @@ -6,11 +6,7 @@ class TaskRequestsController < ApplicationController before_action :set_task_request, only: [:show, :edit, :update, :cancel] def index - if params[:completed_only] - @task_requests = task_requests.completed.order_by_recent.paginate(page: params[:page]) - else - @task_requests = task_requests.order_by_recent.paginate(page: params[:page]) - end + @task_requests = task_requests.order_by_recent.paginate(page: params[:page]) end def new diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb new file mode 100644 index 0000000..18c52dd --- /dev/null +++ b/app/controllers/tasks_controller.rb @@ -0,0 +1,19 @@ +class TasksController < ApplicationController + before_action :set_project + + include ProjectLayout + + def index + @tasks = task_requests.completed.order_by_recent.paginate(page: params[:page]) + end + + private + + def set_project + @project = policy_scope(Project).find(params[:project_id]) + end + + def task_requests + authorize policy_scope(@project.task_requests) + end +end diff --git a/app/javascript/packs/datepickers.js b/app/javascript/packs/datepickers.js index f0e1029..2451d1d 100644 --- a/app/javascript/packs/datepickers.js +++ b/app/javascript/packs/datepickers.js @@ -1,5 +1,6 @@ $(document).on("turbolinks:load", () => { $('.datepicker-control').datepicker({ - format: "yyyy-mm-dd" + format: "yyyy-mm-dd", + todayHighlight: true }); }); diff --git a/app/models/account.rb b/app/models/account.rb index bd7e51b..d9bd775 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -79,8 +79,8 @@ class Account < ApplicationRecord plan_uid.to_s == "me_suite" || plan_uid.to_s == "releaseme" end - def assistme_enabled? - plan_uid.to_s == "me_suite" || plan_uid.to_s == "assistme" + def taskme_enabled? + plan_uid.to_s == "me_suite" || plan_uid.to_s == "taskme" end def plan_name @@ -91,8 +91,8 @@ class Account < ApplicationRecord "DirectME" when "releaseme" "ReleaseME" - when "assistme" - "AssistME" + when "taskme" + "TaskME" when "me_suite" "ME Suite" end diff --git a/app/policies/task_request_policy.rb b/app/policies/task_request_policy.rb index 4845b5d..3775941 100644 --- a/app/policies/task_request_policy.rb +++ b/app/policies/task_request_policy.rb @@ -22,4 +22,8 @@ class TaskRequestPolicy < ApplicationPolicy def cancel? true end + + def open_deliverable? + true + end end diff --git a/app/views/admin/task_requests/_task_request.html.erb b/app/views/admin/task_requests/_task_request.html.erb index cdc777e..05763c6 100644 --- a/app/views/admin/task_requests/_task_request.html.erb +++ b/app/views/admin/task_requests/_task_request.html.erb @@ -2,6 +2,12 @@ <%= task_request.id %> + + <%= task_request.project.account.name %> + + + <%= task_request.project.name %> + <%= task_request.created_at.strftime("%D") %> @@ -18,6 +24,7 @@
<%= button_tag "Manage", class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
diff --git a/app/views/admin/task_requests/index.html.erb b/app/views/admin/task_requests/index.html.erb index bc445da..8afe67f 100644 --- a/app/views/admin/task_requests/index.html.erb +++ b/app/views/admin/task_requests/index.html.erb @@ -3,6 +3,8 @@ Task ID + Account Name + Project Name Created On Deadline Time Allowed @@ -15,7 +17,7 @@ <%= render @task_requests %> <% else %> - <%= t(".empty") %> + <%= t(".empty") %> <% end %> diff --git a/app/views/admin/task_requests/show.html.erb b/app/views/admin/task_requests/show.html.erb new file mode 100644 index 0000000..147cb1c --- /dev/null +++ b/app/views/admin/task_requests/show.html.erb @@ -0,0 +1,18 @@ +
+ <%= description_list_pair_for @task_request, :description, append: ":" %> + <%= description_list_pair_for @task_request, :created_at, append: ":" %> + <%= description_list_pair_for @task_request, :deadline, append: ":" %> + <%= description_list_pair_for @task_request, :time_allowed, append: ":" %> + <%= description_list_pair_for @task_request, :additional_notes, append: ":" %> + <%= description_list_pair_for @task_request, :status, append: ":" %> +
Files:
+
+ <% if @task_request.files.present? %> + <% @task_request.files.each do |file| %> + <%= link_to file.filename, rails_blob_path(file, disposition: 'attachment'), class: "btn btn-link" %>
+ <% end %> + <% else %> + No files attached + <% end %> +
+
diff --git a/app/views/application/_sidebar.html.erb b/app/views/application/_sidebar.html.erb index 5e0d200..ad6e63e 100644 --- a/app/views/application/_sidebar.html.erb +++ b/app/views/application/_sidebar.html.erb @@ -37,8 +37,8 @@ diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 1a95b20..86ac532 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -18,7 +18,7 @@ <% end %> <% if policy(Project).show_task_results? %> <%= render "folder_card" do %> - <%= link_to t("projects.show.task_requests"), [@project, :task_requests, completed_only: true], class: "text-decoration-none text-reset stretched-link" %> + <%= link_to t("projects.show.tasks"), [@project, :tasks], class: "text-decoration-none text-reset stretched-link" %> <% end %> <% end %> diff --git a/app/views/task_requests/_form.html.erb b/app/views/task_requests/_form.html.erb index 64b7645..22d0464 100644 --- a/app/views/task_requests/_form.html.erb +++ b/app/views/task_requests/_form.html.erb @@ -24,6 +24,11 @@ data-placeholder="<%= dropzone_placeholder_message_for(task_request) %>" data-submit-button="#submit_folder"> <% end %> + +
+ <%= fa_icon "info-circle" %> + After you submit this information you will immediately be connected with a BIG representative who will be able to collect any additional information needed, answer your questions, etc. +
<%= link_to t("shared.cancel"), [project, :task_requests], class: "col-3 text-reset" %> diff --git a/app/views/task_requests/_task_request.html.erb b/app/views/task_requests/_task_request.html.erb index 9d626ab..c3f970c 100644 --- a/app/views/task_requests/_task_request.html.erb +++ b/app/views/task_requests/_task_request.html.erb @@ -11,11 +11,6 @@ <%= task_request.status.titleize %> - <% if params[:completed_only] %> - - <%= task_request.deliverable_url %> - - <% end %>
<%= button_tag t(".actions.manage"), class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %> @@ -26,6 +21,9 @@ <% if policy(task_request).edit? %> <%= link_to fa_icon("pencil fw", text: "Edit"), [:edit, task_request.project, task_request], class: "dropdown-item" %> <% end %> + <% if policy(task_request).open_deliverable? && task_request.status == "completed" %> + <%= link_to fa_icon("external-link fw", text: t(".actions.open_deliverable")), task_request.deliverable_url, class: "dropdown-item", target: '_blank' %> + <% end %> <% if policy(task_request).cancel? && !task_request.cancelled? %> <%= link_to fa_icon("ban fw", text: "Cancel"), [:cancel, task_request.project, task_request], class: "dropdown-item", method: :post %> <% end %> diff --git a/app/views/task_requests/index.html.erb b/app/views/task_requests/index.html.erb index 18804b1..4c6c61d 100644 --- a/app/views/task_requests/index.html.erb +++ b/app/views/task_requests/index.html.erb @@ -1,4 +1,4 @@ -<%= product_wordmark :assist_me, class: "small mb-3" %> +<%= product_wordmark :task_me, class: "small mb-3" %>
@@ -18,9 +18,6 @@ <%= t(".table_headers.task_request_deadline") %> <%= t(".table_headers.task_request_time_allowed") %> <%= t(".table_headers.task_request_status") %> - <% if params[:completed_only] %> - <%= t(".table_headers.task_request_results") %> - <% end %> diff --git a/app/views/tasks/_task.html.erb b/app/views/tasks/_task.html.erb new file mode 100644 index 0000000..35a1efe --- /dev/null +++ b/app/views/tasks/_task.html.erb @@ -0,0 +1,17 @@ + + + <%= task.created_at.strftime('%D') %> + + + <%= task.deadline.try(:strftime, '%D') %> + + + <%= task.time_allowed %> + + + <%= task.status.titleize %> + + + <%= task.deliverable_url %> + + diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb new file mode 100644 index 0000000..103d1bf --- /dev/null +++ b/app/views/tasks/index.html.erb @@ -0,0 +1,26 @@ +
+ + + + + + + + + + + + <% if @tasks.any? %> + <%= render partial: "task", collection: @tasks %> + <% else %> + + + + <% end %> + +
<%= t(".table_headers.task_request_created_on") %><%= t(".table_headers.task_request_deadline") %><%= t(".table_headers.task_request_time_allowed") %><%= t(".table_headers.task_request_status") %><%= t(".table_headers.task_request_results") %>
<%= t(".empty") %>
+
+ +
+ <%= will_paginate @tasks %> +
diff --git a/config/locales/en.yml b/config/locales/en.yml index e6890be..2d4f792 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -734,7 +734,7 @@ en: music_release: Music Releases (%{count}) report: Reports talent_release: Talent Releases (%{count}) - task_requests: Tasks + tasks: Tasks public: acquired_media_releases: new: @@ -875,7 +875,6 @@ en: title: Sign In shared: ago: ago - assist_me: Assist back: Back cancel: Cancel clear: Clear @@ -901,6 +900,7 @@ en: tag_multiple_releases: Add Tag tag_multiple_releases_form: submit: Add + task_me: Task tags: form: submit: Add @@ -959,8 +959,18 @@ en: task_request: actions: manage: Manage + open_deliverable: Open Deliverable update: notice: Task request updated successfully. + tasks: + index: + empty: Tasks will appear here. + table_headers: + task_request_created_on: Created On + task_request_deadline: Deadline + task_request_results: Task Results + task_request_status: Status + task_request_time_allowed: Time Allowed user_mailer: existing_account: subject: You've been added as a ME Suite Account Manager diff --git a/config/locales/es.yml b/config/locales/es.yml index 13abd12..80514a6 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -182,3 +182,8 @@ es: photos: guardian_photo: heading: Guardian Photo (ES) + task_requests: + task_request: + actions: + manage: Manage (ES) + open_deliverable: Open Deliverable (ES) diff --git a/config/routes.rb b/config/routes.rb index 15c008f..665311d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,7 +31,7 @@ Rails.application.routes.draw do resources :users, only: [:index, :new, :create, :edit, :update, :destroy] do resource :masquerade, only: :create end - resources :task_requests, only: [:index, :edit, :update] + resources :task_requests, only: [:index, :edit, :update, :show] root to: "accounts#index", as: :signed_in_root end @@ -103,6 +103,7 @@ Rails.application.routes.draw do post :cancel end end + resources :tasks, only: :index end resource :profile, only: [:show, :update] resources :videos, only: [] do diff --git a/spec/controllers/tasks_controller_spec.rb b/spec/controllers/tasks_controller_spec.rb new file mode 100644 index 0000000..9860156 --- /dev/null +++ b/spec/controllers/tasks_controller_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +RSpec.describe TasksController, type: :controller do + render_views + + let(:user) { create(:user) } + let(:account) { user.primary_account } + let(:project) { create(:project, account: user.primary_account) } + + before do + sign_in user + end + + describe "#index" do + it "responds successfully" do + get :index, params: { project_id: project } + + expect(response).to be_successful + end + + it "renders content" do + create(:task_request, :completed, project: project, description: "Another Request") + + get :index, params: { project_id: project } + + expect(response.body).to have_content "Completed" + expect(response.body).to have_content "example.com/deliverables" + end + + context "when there are many records" do + it "paginates the table" do + create_list(:task_request, 20, :completed, project: project) + + get :index, params: { project_id: project } + + expect(response.body).to have_link("2", href: project_tasks_path(project, page: 2)) + end + end + end +end diff --git a/spec/factories/task_requests.rb b/spec/factories/task_requests.rb index 2b206d8..c417fa8 100644 --- a/spec/factories/task_requests.rb +++ b/spec/factories/task_requests.rb @@ -6,6 +6,11 @@ FactoryBot.define do description "Task request" additional_notes "Additional notes" status 0 + + trait :completed do + deliverable_url "example.com/deliverables" + status 1 + end trait :with_files do files { [Rack::Test::UploadedFile.new('spec/fixtures/files/contract.pdf', 'application/pdf')] } diff --git a/spec/features/admin_managing_task_requests_spec.rb b/spec/features/admin_managing_task_requests_spec.rb new file mode 100644 index 0000000..83a7efd --- /dev/null +++ b/spec/features/admin_managing_task_requests_spec.rb @@ -0,0 +1,99 @@ +require "rails_helper" + +feature "Admin managing task requests" do + let(:current_user) { create(:user, admin: true, email: "user@test.com") } + let(:project) { create(:project, account: current_user.primary_account, name: "Test Project") } + + before do + sign_in current_user + end + + scenario "admin should see View action for task request in Manage dropdown", js: true do + create(:task_request) + visit admin_task_requests_path + + click_on 'Manage' + expect(page).to have_content 'View' + end + + scenario "admin can open detail view of task request", js: true do + task_request = create(:task_request, :with_files) + visit admin_task_requests_path + + click_on 'Manage' + click_link 'View' + switch_to_window(windows.last) + + expect(page).to have_content 'Description' + expect(page).to have_content task_request.description + + expect(page).to have_content 'Created At' + expect(page).to have_content task_request.created_at + + expect(page).to have_content 'Deadline' + expect(page).to have_content task_request.deadline + + expect(page).to have_content 'Time Allowed' + expect(page).to have_content task_request.time_allowed + + expect(page).to have_content 'Additional Notes' + expect(page).to have_content task_request.additional_notes + + expect(page).to have_content 'Status' + expect(page).to have_content task_request.status + + expect(page).to have_content 'Files' + task_request.files.each do |file| + expect(page).to have_link file.blob.filename + end + end + + scenario "no files attached label is shown if there are no files attached to the task request", js:true do + create(:task_request) + visit admin_task_requests_path + + click_on 'Manage' + click_link 'View' + switch_to_window(windows.last) + + expect(page).to have_content 'No files attached' + end + + scenario "task requests table is visible" do + visit admin_task_requests_path + + expect(page).to have_content "Task ID" + expect(page).to have_content "Account Name" + expect(page).to have_content "Project Name" + expect(page).to have_content "Created On" + expect(page).to have_content "Deadline" + expect(page).to have_content "Time Allowed" + expect(page).to have_content "Status" + end + + scenario "sees list of task requests" do + visit admin_task_requests_path + + expect(page).to have_content no_task_requests_label + + task_request = create(:task_request) + + visit admin_task_requests_path + + expect(page).not_to have_content no_task_requests_label + + expect(page).to have_content task_request.id + expect(page).to have_content task_request.project.account.name + expect(page).to have_content task_request.project.name + expect(page).to have_content task_request.created_at.try(:strftime, '%D') + expect(page).to have_content task_request.deadline.try(:strftime, '%D') + expect(page).to have_content task_request.time_allowed + expect(page).to have_content task_request.status.capitalize + end + + private + + def no_task_requests_label + "Task requests will appear here" + end +end diff --git a/spec/features/user_managing_task_requests_spec.rb b/spec/features/user_managing_task_requests_spec.rb new file mode 100644 index 0000000..00f5956 --- /dev/null +++ b/spec/features/user_managing_task_requests_spec.rb @@ -0,0 +1,73 @@ +require "rails_helper" + +feature "User managing task requests" do + let(:current_user) { create(:user) } + let(:project) { create(:project, account: current_user.primary_account) } + + before :each do + sign_in current_user + end + + scenario "task requests table is visible" do + visit project_task_requests_path(project) + + expect(page).to have_content "Created On" + expect(page).to have_content "Deadline" + expect(page).to have_content "Time Allowed" + expect(page).to have_content "Status" + end + + scenario "sees list of task requests" do + visit project_task_requests_path(project) + + expect(page).to have_content no_task_requests_label + + task_request = create(:task_request, project: project) + + visit project_task_requests_path(project) + + expect(page).not_to have_content no_task_requests_label + + expect(page).to have_content task_request.created_at.try(:strftime, '%D') + expect(page).to have_content task_request.deadline.try(:strftime, '%D') + expect(page).to have_content task_request.time_allowed + expect(page).to have_content task_request.status.capitalize + end + + scenario "user does not see open deliverable action in manage dropdown if task status is not completed" do + task_request = create(:task_request, project: project) + visit project_task_requests_path(project) + + click_on manage_button + expect(page).not_to have_content open_deliverable_action_label + end + + scenario "user can click deliverable action in manage dropdown if task status is completed", js: true do + create(:task_request, project: project, status: "completed", deliverable_url: "/") + visit project_task_requests_path(project) + + click_on manage_button + expect(page).to have_content open_deliverable_action_label + click_link open_deliverable_action_label + switch_to_window(windows.last) + expect(page).to have_content add_new_project_label + end + + private + + def no_task_requests_label + "Task requests will appear here" + end + + def manage_button + t "task_requests.task_request.actions.manage" + end + + def open_deliverable_action_label + t "task_requests.task_request.actions.open_deliverable" + end + + def add_new_project_label + t "projects.index.actions.new" + end +end