Fix role reset for team assignments on PET [SCI-12222]

This commit is contained in:
Martin Artnik 2025-08-12 16:25:19 +02:00
parent c4f523c18c
commit 08bfa91820
4 changed files with 8 additions and 4 deletions

View file

@ -75,6 +75,8 @@ module AccessPermissions
end
propagate_job
render json: { user_role_id: @assignment.user_role_id }, status: :ok
rescue ActiveRecord::RecordInvalid
render json: { flash: t('access_permissions.update.failure') }, status: :unprocessable_entity
end

View file

@ -7,7 +7,7 @@ module AccessPermissions
def update
if permitted_params[:user_role_id] == 'reset'
parent_assignment = @project.public_send(:"#{assignment_type}_assignments").find_or_initialize_by(
"#{assignment_type}_id": permitted_params[:"#{assignment_type}_id"],
"#{assignment_type}_id": permitted_params[:"#{assignment_type}_id"] || current_team.id,
team: current_team
)
@ -35,7 +35,7 @@ module AccessPermissions
log_activity(:change_user_role_on_experiment, user_target: @assignment.user.id, role: @assignment.user_role.name)
end
render json: {}, status: :ok
render json: { user_role_id: @assignment.user_role_id }, status: :ok
end
private

View file

@ -8,7 +8,7 @@ module AccessPermissions
def update
if permitted_params[:user_role_id] == 'reset'
parent_assignment = @experiment.public_send(:"#{assignment_type}_assignments").find_or_initialize_by(
"#{assignment_type}_id": permitted_params[:"#{assignment_type}_id"],
"#{assignment_type}_id": permitted_params[:"#{assignment_type}_id"] || current_team.id,
team: current_team
)
@ -33,6 +33,8 @@ module AccessPermissions
when :user
log_activity(:change_user_role_on_my_module, user_target: @assignment.user.id, role: @assignment.user_role.name)
end
render json: { user_role_id: @assignment.user_role_id }, status: :ok
end
private

View file

@ -329,7 +329,7 @@ export default {
if (!roleId) {
this.$emit('changeVisibility', false, null);
} else {
this.$emit('changeVisibility', true, roleId);
this.$emit('changeVisibility', true, response.data.user_role_id);
}
if (response.data.message) {
HelperModule.flashAlertMsg(response.data.message, 'success');