Skip to content

Commit

Permalink
Merged in r2-2690-type-of-referral-role (pull request #6593)
Browse files Browse the repository at this point in the history
R2-2690 - New Role attribute: “Can this role be used for the ‘Type of Referral’ field?”
  • Loading branch information
dhernandez-quoin authored and pnabutovsky committed Nov 16, 2023
2 parents a8bcca8 + 9f3867e commit 063336b
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v2/roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def role_params
@role_params ||= params.require(:data).permit(
:id, :unique_id, :name, :description, :disabled,
:group_permission, :referral, :transfer, :is_manager, :reporting_location_level,
permissions: {}, form_section_read_write: {}, module_unique_ids: []
:referral_authorization, permissions: {}, form_section_read_write: {}, module_unique_ids: []
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const FIELD_NAMES = {
groupPermission: "group_permission",
isManager: "is_manager",
reportingLocationLevel: "reporting_location_level",
disabled: "disabled"
disabled: "disabled",
referralAuthorization: "referral_authorization"
};
export const ACTION_BUTTONS_NAME = "ActionButtons";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export default (groupPermissions, i18n, adminLevelMap) => {
type: TICK_FIELD,
tooltip: i18n.t("permissions.resource.referral.actions.refer.explanation")
}),
FieldRecord({
display_name: i18n.t("permissions.resource.referral_authorization.label"),
name: FIELD_NAMES.referralAuthorization,
type: TICK_FIELD,
tooltip: i18n.t("permissions.resource.referral_authorization.explanation")
}),
FieldRecord({
display_name: i18n.t("permissions.resource.module.label"),
tooltip: i18n.t("permissions.resource.module.explanation"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ describe("pages/admin/<RolesForm>/forms - RolesMainForm", () => {
const rolesMainForm = RolesMainForm(fromJS([]), i18n, fromJS({}));

expect(rolesMainForm.unique_id).to.be.equal("roles");
expect(rolesMainForm.fields).to.have.lengthOf(9);
expect(rolesMainForm.fields).to.have.lengthOf(10);
});
});
3 changes: 2 additions & 1 deletion app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class Role < ApplicationRecord
'is_manager' => { 'type' => 'boolean' }, 'transfer' => { 'type' => 'boolean' },
'disabled' => { 'type' => 'boolean' }, 'module_unique_ids' => { 'type' => 'array' },
'permissions' => { 'type' => 'object' }, 'form_section_read_write' => { 'type' => 'object' },
'reporting_location_level' => { 'type' => %w[integer null] }
'reporting_location_level' => { 'type' => %w[integer null] },
'referral_authorization' => { 'type' => 'boolean' }
}.freeze

has_many :form_permissions
Expand Down
1 change: 1 addition & 0 deletions app/views/api/v2/roles/_role.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ json.unique_id role.unique_id
json.name role.name
json.description role.description
json.group_permission role.group_permission
json.referral_authorization role.referral_authorization
json.referral role.referral
json.transfer role.transfer
json.disabled role.disabled
Expand Down
8 changes: 8 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3080,6 +3080,14 @@ en:
explanation: If you disable this Role, you will no longer be able to assign
it to User accounts.
label: Disabled
referral_authorization:
explanation: This means the role will appear as an option for the "Type of Referral"
dropdown when the user performs an internal referral. If the user chooses this role as the type of referral,
the referral recipient will only be able to access the forms which the selected role can access.
So, for instance, if the user chooses "Medical Service Provider" as the Type of Referral,
and the Medical Service Provider role only has access to the Basic Identity and Protection Concerns forms,
the recipient will only see these forms.
label: Can this role be used for the "Type of Referral" dropdown?
duplicate:
actions:
read:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

# Copyright (c) 2014 - 2023 UNICEF. All rights reserved.

class AddReferralAuthorizationToRole < ActiveRecord::Migration[5.2]
def change
add_column :roles, :referral_authorization, :boolean, null: false, default: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_09_21_124122) do
ActiveRecord::Schema.define(version: 2023_11_10_000000) do

# These are extensions that must be enabled in order to support this database
enable_extension "ltree"
Expand Down Expand Up @@ -501,6 +501,7 @@
t.boolean "disabled", default: false, null: false
t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.boolean "referral_authorization", default: false, null: false
t.index ["permissions"], name: "index_roles_on_permissions", using: :gin
t.index ["unique_id"], name: "index_roles_on_unique_id", unique: true
end
Expand Down
2 changes: 2 additions & 0 deletions spec/requests/api/v2/roles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
name: 'CP Administrator 00',
description: 'Administrator_description',
group_permission: 'all',
referral_authorization: true,
referral: false,
transfer: false,
disabled: false,
Expand Down Expand Up @@ -484,6 +485,7 @@
name: 'CP Administrator 00',
description: 'Administrator_description',
group_permission: 'all',
referral_authorization: false,
referral: false,
transfer: false,
disabled: false,
Expand Down

0 comments on commit 063336b

Please sign in to comment.