diff --git a/app/controllers/api/v2/roles_controller.rb b/app/controllers/api/v2/roles_controller.rb index 7517ca8b41..8e6a00461b 100644 --- a/app/controllers/api/v2/roles_controller.rb +++ b/app/controllers/api/v2/roles_controller.rb @@ -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, - :show_on_type_of_referral, permissions: {}, form_section_read_write: {}, module_unique_ids: [] + :referral_authorization, permissions: {}, form_section_read_write: {}, module_unique_ids: [] ) end diff --git a/app/javascript/components/pages/admin/roles-form/constants.js b/app/javascript/components/pages/admin/roles-form/constants.js index d2694d7268..44243b4483 100644 --- a/app/javascript/components/pages/admin/roles-form/constants.js +++ b/app/javascript/components/pages/admin/roles-form/constants.js @@ -12,7 +12,7 @@ export const FIELD_NAMES = { isManager: "is_manager", reportingLocationLevel: "reporting_location_level", disabled: "disabled", - showOnTypeOfReferral: "show_on_type_of_referral" + referralAuthorization: "referral_authorization" }; export const ACTION_BUTTONS_NAME = "ActionButtons"; diff --git a/app/javascript/components/pages/admin/roles-form/forms/roles-main.js b/app/javascript/components/pages/admin/roles-form/forms/roles-main.js index a59e3b3881..8e33b6680d 100644 --- a/app/javascript/components/pages/admin/roles-form/forms/roles-main.js +++ b/app/javascript/components/pages/admin/roles-form/forms/roles-main.js @@ -46,10 +46,10 @@ export default (groupPermissions, i18n, adminLevelMap) => { tooltip: i18n.t("permissions.resource.referral.actions.refer.explanation") }), FieldRecord({ - display_name: i18n.t("permissions.resource.show_on_type_of_referral.label"), - name: FIELD_NAMES.showOnTypeOfReferral, + display_name: i18n.t("permissions.resource.referral_authorization.label"), + name: FIELD_NAMES.referralAuthorization, type: TICK_FIELD, - tooltip: i18n.t("permissions.resource.show_on_type_of_referral.explanation") + tooltip: i18n.t("permissions.resource.referral_authorization.explanation") }), FieldRecord({ display_name: i18n.t("permissions.resource.module.label"), diff --git a/app/models/role.rb b/app/models/role.rb index c424fe38eb..69de66f185 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -36,7 +36,7 @@ class Role < ApplicationRecord 'disabled' => { 'type' => 'boolean' }, 'module_unique_ids' => { 'type' => 'array' }, 'permissions' => { 'type' => 'object' }, 'form_section_read_write' => { 'type' => 'object' }, 'reporting_location_level' => { 'type' => %w[integer null] }, - 'show_on_type_of_referral' => { 'type' => 'boolean' } + 'referral_authorization' => { 'type' => 'boolean' } }.freeze has_many :form_permissions diff --git a/app/views/api/v2/roles/_role.json.jbuilder b/app/views/api/v2/roles/_role.json.jbuilder index 4044148183..513a33a2c3 100644 --- a/app/views/api/v2/roles/_role.json.jbuilder +++ b/app/views/api/v2/roles/_role.json.jbuilder @@ -7,7 +7,7 @@ json.unique_id role.unique_id json.name role.name json.description role.description json.group_permission role.group_permission -json.show_on_type_of_referral role.show_on_type_of_referral +json.referral_authorization role.referral_authorization json.referral role.referral json.transfer role.transfer json.disabled role.disabled diff --git a/config/locales/en.yml b/config/locales/en.yml index 7ab9920390..7f8fd92b01 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3076,7 +3076,7 @@ en: explanation: If you disable this Role, you will no longer be able to assign it to User accounts. label: Disabled - show_on_type_of_referral: + 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. diff --git a/db/migrate/20231110000000_add_referral_authorization_to_role.rb b/db/migrate/20231110000000_add_referral_authorization_to_role.rb new file mode 100644 index 0000000000..c12f9d88a6 --- /dev/null +++ b/db/migrate/20231110000000_add_referral_authorization_to_role.rb @@ -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 diff --git a/db/migrate/20231110000000_add_show_on_type_of_referral_to_role.rb b/db/migrate/20231110000000_add_show_on_type_of_referral_to_role.rb deleted file mode 100644 index 72a2ac66ef..0000000000 --- a/db/migrate/20231110000000_add_show_on_type_of_referral_to_role.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) 2014 - 2023 UNICEF. All rights reserved. - -class AddShowOnTypeOfReferralToRole < ActiveRecord::Migration[5.2] - def change - add_column :roles, :show_on_type_of_referral, :boolean, null: false, default: false - end -end diff --git a/db/schema.rb b/db/schema.rb index 5fa1e2c863..f3e740d5c2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" @@ -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 diff --git a/spec/requests/api/v2/roles_controller_spec.rb b/spec/requests/api/v2/roles_controller_spec.rb index 1e2533bccd..64c516d329 100644 --- a/spec/requests/api/v2/roles_controller_spec.rb +++ b/spec/requests/api/v2/roles_controller_spec.rb @@ -436,7 +436,7 @@ name: 'CP Administrator 00', description: 'Administrator_description', group_permission: 'all', - show_on_type_of_referral: false, + referral_authorization: true, referral: false, transfer: false, disabled: false, @@ -485,7 +485,7 @@ name: 'CP Administrator 00', description: 'Administrator_description', group_permission: 'all', - show_on_type_of_referral: false, + referral_authorization: false, referral: false, transfer: false, disabled: false,