Fix sharing settings with invisible teams [SCI-11188]

This commit is contained in:
Martin Artnik 2024-10-14 15:52:47 +02:00
parent ca2c409bb0
commit f388594884
3 changed files with 14 additions and 5 deletions

View file

@ -57,7 +57,7 @@ class TeamSharedObjectsController < ApplicationController
end
def shareable_teams
teams = current_user.teams.order(:name) - [@model.team]
teams = Team.order(:name).all - [@model.team]
render json: teams, each_serializer: ShareableTeamSerializer, model: @model
end

View file

@ -37,14 +37,14 @@
<template v-for="team in shareableTeams">
<div class="col-span-2 flex items-center h-9 gap-1">
<span class="sci-checkbox-container" :class="{'opacity-0 pointer-events-none': sharedWithAllRead}">
<input type="checkbox" class="sci-checkbox" v-model="team.attributes.private_shared_with" />
<input :disabled="!team.attributes.readable" type="checkbox" class="sci-checkbox" v-model="team.attributes.private_shared_with" />
<span class="sci-checkbox-label"></span>
</span>
{{ team.attributes.name }}
{{ team.attributes.name || `(${i18n.t('teams.private_team')})` }}
</div>
<div class="flex justify-center items-center">
<span v-if="team.attributes.private_shared_with"
:class="{'opacity-0 pointer-events-none': sharedWithAllRead}"
:class="{'opacity-0 pointer-events-none': sharedWithAllRead || !team.attributes.readable}"
class="sci-toggle-checkbox-container">
<input type="checkbox"
class="sci-toggle-checkbox"

View file

@ -2,8 +2,17 @@
class ShareableTeamSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
include Canaid::Helpers::PermissionsHelper
attributes :id, :name, :private_shared_with, :private_shared_with_write
attributes :id, :name, :readable, :private_shared_with, :private_shared_with_write
def name
readable && object.name
end
def readable
can_read_team?(object)
end
def private_shared_with
model.private_shared_with?(object)