mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 08:21:37 +08:00
Fix switching between global share and team shares [SCI-11182]
This commit is contained in:
parent
87f2851d9b
commit
d38ccea98f
2 changed files with 11 additions and 14 deletions
|
|
@ -8,26 +8,24 @@ class TeamSharedObjectsController < ApplicationController
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@activities_to_log = []
|
@activities_to_log = []
|
||||||
|
|
||||||
# Global share
|
global_permission_level =
|
||||||
if @model.globally_shareable?
|
|
||||||
permission_level =
|
|
||||||
if params[:select_all_teams]
|
if params[:select_all_teams]
|
||||||
params[:select_all_write_permission] ? :shared_write : :shared_read
|
params[:select_all_write_permission] ? :shared_write : :shared_read
|
||||||
else
|
else
|
||||||
:not_shared
|
:not_shared
|
||||||
end
|
end
|
||||||
|
|
||||||
@model.permission_level = permission_level
|
# Global share
|
||||||
|
if @model.globally_shareable?
|
||||||
|
@model.permission_level = global_permission_level
|
||||||
|
|
||||||
if @model.permission_level_changed?
|
if @model.permission_level_changed?
|
||||||
@model.save!
|
@model.save!
|
||||||
@model.team_shared_objects.each(&:destroy!) unless permission_level == :not_shared
|
@model.team_shared_objects.each(&:destroy!) unless global_permission_level == :not_shared
|
||||||
case @model
|
case @model
|
||||||
when Repository
|
when Repository
|
||||||
setup_repository_global_share_activity
|
setup_repository_global_share_activity
|
||||||
end
|
end
|
||||||
|
|
||||||
log_activities and next
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -35,11 +33,10 @@ class TeamSharedObjectsController < ApplicationController
|
||||||
params[:team_share_params].each do |t|
|
params[:team_share_params].each do |t|
|
||||||
next unless t['private_shared_with']
|
next unless t['private_shared_with']
|
||||||
|
|
||||||
@model.update!(permission_level: :not_shared) if @model.globally_shareable?
|
|
||||||
|
|
||||||
team_shared_object = @model.team_shared_objects.find_or_initialize_by(team_id: t['id'])
|
team_shared_object = @model.team_shared_objects.find_or_initialize_by(team_id: t['id'])
|
||||||
|
|
||||||
new_record = team_shared_object.new_record?
|
new_record = team_shared_object.new_record?
|
||||||
|
|
||||||
team_shared_object.update!(
|
team_shared_object.update!(
|
||||||
permission_level: t['private_shared_with_write'] ? :shared_write : :shared_read
|
permission_level: t['private_shared_with_write'] ? :shared_write : :shared_read
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ export default {
|
||||||
const data = {
|
const data = {
|
||||||
select_all_teams: this.sharedWithAllRead,
|
select_all_teams: this.sharedWithAllRead,
|
||||||
select_all_write_permission: this.sharedWithAllWrite,
|
select_all_write_permission: this.sharedWithAllWrite,
|
||||||
team_share_params: this.shareableTeams.map((team) => { return { id: team.id, ...team.attributes } })
|
team_share_params: this.sharedWithAllRead ? [] : this.shareableTeams.map((team) => { return { id: team.id, ...team.attributes } })
|
||||||
};
|
};
|
||||||
axios.post(this.object.urls.share, data).then(() => {
|
axios.post(this.object.urls.share, data).then(() => {
|
||||||
HelperModule.flashAlertMsg(this.i18n.t(
|
HelperModule.flashAlertMsg(this.i18n.t(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue