Browse Source

Allow support user to create log on behalf of other users

pull/657/head
baarkerlounger 3 years ago
parent
commit
4e920ecd15
  1. 4
      app/controllers/case_logs_controller.rb
  2. 2
      app/models/case_log.rb
  3. 4
      app/views/case_logs/_log_list.html.erb
  4. 32
      config/forms/2021_2022.json
  5. 32
      config/forms/2022_2023.json

4
app/controllers/case_logs_controller.rb

@ -105,9 +105,7 @@ private
end
def case_log_params
if current_user && current_user.role == "support"
{ "created_by_id": current_user.id }.merge(api_case_log_params)
elsif current_user
if current_user && current_user.role != "support"
org_params.merge(api_case_log_params)
else
api_case_log_params

2
app/models/case_log.rb

@ -33,7 +33,7 @@ class CaseLog < ApplicationRecord
belongs_to :owning_organisation, class_name: "Organisation", optional: true
belongs_to :managing_organisation, class_name: "Organisation", optional: true
belongs_to :created_by, class_name: "User"
belongs_to :created_by, class_name: "User", optional: true
scope :filter_by_organisation, ->(org, _user = nil) { where(owning_organisation: org).or(where(managing_organisation: org)) }
scope :filter_by_status, ->(status, _user = nil) { where status: }

4
app/views/case_logs/_log_list.html.erb

@ -64,8 +64,8 @@
<%= status_tag(log.status) %>
<% end %>
<% if current_user.support? %>
<% row.cell(text: log.owning_organisation.name) %>
<% row.cell(text: log.managing_organisation.name) %>
<% row.cell(text: log.owning_organisation&.name) %>
<% row.cell(text: log.managing_organisation&.name) %>
<% end %>
<% end %>
<% end %>

32
config/forms/2021_2022.json

@ -36,6 +36,38 @@
]
]
},
"user": {
"header": "",
"description": "",
"questions": {
"created_by_id": {
"header": "Which user are you creating this log for?",
"hint_text": "",
"type": "select",
"answer_options_lookup": {
"class": "User",
"scope": "all",
"id": "id",
"label": "name"
}
}
},
"derived": true,
"depends_on": [
[
{
"object": "user",
"method": "role",
"value": "support"
},
{
"object": "case_log",
"method": "owning_organisation_id.nil?",
"value": false
}
]
]
},
"needs_type": {
"header": "",
"description": "",

32
config/forms/2022_2023.json

@ -36,6 +36,38 @@
]
]
},
"user": {
"header": "",
"description": "",
"questions": {
"created_by_id": {
"header": "Which user are you creating this log for?",
"hint_text": "",
"type": "select",
"answer_options_lookup": {
"class": "User",
"scope": "all",
"id": "id",
"label": "name"
}
}
},
"derived": true,
"depends_on": [
[
{
"object": "user",
"method": "role",
"value": "support"
},
{
"object": "case_log",
"method": "owning_organisation_id.nil?",
"value": false
}
]
]
},
"needs_type": {
"header": "",
"description": "",

Loading…
Cancel
Save