mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-24 00:46:22 +08:00
commit
f3d78dd4c8
|
@ -70,7 +70,6 @@ module AccessPermissions
|
|||
@project.update!(visibility: :visible, default_public_user_role_id: user_assignment_params[:user_role_id])
|
||||
log_activity(:change_project_visibility, { visibility: t('projects.activity.visibility_visible') })
|
||||
else
|
||||
|
||||
user_assignment = UserAssignment.find_or_initialize_by(
|
||||
assignable: @project,
|
||||
user_id: user_assignment_params[:user_id],
|
||||
|
@ -137,18 +136,19 @@ module AccessPermissions
|
|||
|
||||
def update_default_public_user_role
|
||||
Project.transaction do
|
||||
@project.visibility = :hidden if permitted_default_public_user_role_params[:default_public_user_role_id].blank?
|
||||
@project.assign_attributes(permitted_default_public_user_role_params)
|
||||
@project.save!
|
||||
|
||||
UserAssignments::ProjectGroupAssignmentJob.perform_later(current_team, @project, current_user)
|
||||
|
||||
# revoke all team members access
|
||||
@project.visibility_will_change!
|
||||
@project.last_modified_by = current_user
|
||||
if permitted_default_public_user_role_params[:default_public_user_role_id].blank?
|
||||
# revoke all team members access
|
||||
@project.visibility = :hidden
|
||||
@project.save!
|
||||
log_activity(:change_project_visibility, { visibility: t('projects.activity.visibility_hidden') })
|
||||
render json: { flash: t('access_permissions.update.revoke_all_team_members') }, status: :ok
|
||||
render json: { flash: t('access_permissions.update.revoke_all_team_members') }
|
||||
else
|
||||
# update all team members access
|
||||
@project.visibility = :visible
|
||||
@project.assign_attributes(permitted_default_public_user_role_params)
|
||||
@project.save!
|
||||
log_activity(:project_access_changed_all_team_members,
|
||||
{ team: @project.team.id, role: @project.default_public_user_role&.name })
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</div>
|
||||
<div v-if="teams" class="sci--navigation--top-menu-teams">
|
||||
<DropdownSelector
|
||||
:selectedValue="current_team"
|
||||
:selectedValue="currentTeam"
|
||||
:options="teams"
|
||||
:disableSearch="true"
|
||||
:selectorId="`sciNavigationTeamSelector`"
|
||||
|
@ -25,7 +25,7 @@
|
|||
<i class="fas fa-question-circle"></i>
|
||||
</button>
|
||||
<ul v-if="user" class="dropdown-menu dropdown-menu-right">
|
||||
<li v-for="(item, i) in helpMenu">
|
||||
<li v-for="(item, i) in helpMenu" :key="item.name">
|
||||
<a :key="i" :href="item.url">
|
||||
{{ item.name }}
|
||||
</a>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<i class="fas fa-cog"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li v-for="(item, i) in settingsMenu">
|
||||
<li v-for="(item, i) in settingsMenu" :key="item.name">
|
||||
<a :key="i" :href="item.url">
|
||||
{{ item.name }}
|
||||
</a>
|
||||
|
@ -71,7 +71,7 @@
|
|||
<img class="avatar" :src="user.avatar_url">
|
||||
</div>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<li v-for="(item, i) in userMenu">
|
||||
<li v-for="(item, i) in userMenu" :key="item.name">
|
||||
<a :key="i" :href="item.url">
|
||||
{{ item.name }}
|
||||
</a>
|
||||
|
@ -105,7 +105,7 @@
|
|||
return {
|
||||
rootUrl: null,
|
||||
logo: null,
|
||||
current_team: null,
|
||||
currentTeam: null,
|
||||
teams: null,
|
||||
searchUrl: null,
|
||||
user: null,
|
||||
|
@ -121,7 +121,7 @@
|
|||
$.get(this.url, (result) => {
|
||||
this.rootUrl = result.root_url;
|
||||
this.logo = result.logo;
|
||||
this.current_team = result.current_team;
|
||||
this.currentTeam = result.current_team;
|
||||
this.teams = result.teams;
|
||||
this.searchUrl = result.search_url;
|
||||
this.helpMenu = result.help_menu;
|
||||
|
@ -135,15 +135,21 @@
|
|||
$(document).on('turbolinks:load', () => {
|
||||
this.notificationsOpened = false;
|
||||
this.checkUnseenNotifications();
|
||||
this.refreshCurrentTeam();
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
switchTeam(team) {
|
||||
if (this.current_team == team) return;
|
||||
if (this.currentTeam == team) return;
|
||||
|
||||
$.post(this.teams.find(e => e.value == team).params.switch_url, (result) => {
|
||||
this.current_team = result.current_team
|
||||
dropdownSelector.selectValues('#sciNavigationTeamSelector', this.current_team);
|
||||
let newTeam = this.teams.find(e => e.value == team);
|
||||
|
||||
if (!newTeam) return;
|
||||
|
||||
$.post(newTeam.params.switch_url, (result) => {
|
||||
this.currentTeam = result.currentTeam
|
||||
dropdownSelector.selectValues('#sciNavigationTeamSelector', this.currentTeam);
|
||||
$('body').attr('data-current-team-id', this.currentTeam);
|
||||
window.open(this.rootUrl, '_self')
|
||||
}).error((msg) => {
|
||||
HelperModule.flashAlertMsg(msg.responseJSON.message, 'danger');
|
||||
|
@ -156,6 +162,13 @@
|
|||
$.get(this.unseenNotificationsUrl, (result) => {
|
||||
this.unseenNotificationsCount = result.unseen;
|
||||
})
|
||||
},
|
||||
refreshCurrentTeam() {
|
||||
let newTeam = parseInt($('body').attr('data-current-team-id'));
|
||||
if (newTeam !== this.currentTeam) {
|
||||
this.currentTeam = newTeam;
|
||||
dropdownSelector.selectValues('#sciNavigationTeamSelector', this.currentTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@ module UserAssignments
|
|||
@team = team
|
||||
@assigned_by = assigned_by
|
||||
|
||||
return unless project.visible?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
team.users.where.not(id: assigned_by).find_each do |user|
|
||||
team.users.find_each do |user|
|
||||
user_assignment = UserAssignment.find_or_initialize_by(
|
||||
user: user,
|
||||
assignable: project
|
||||
|
|
|
@ -330,7 +330,7 @@ class Project < ApplicationRecord
|
|||
def auto_assign_project_members
|
||||
return if skip_user_assignments
|
||||
|
||||
UserAssignments::ProjectGroupAssignmentJob.perform_now(
|
||||
UserAssignments::ProjectGroupAssignmentJob.perform_later(
|
||||
team,
|
||||
self,
|
||||
last_modified_by || created_by
|
||||
|
|
|
@ -7,8 +7,8 @@ module Reports::Docx::DrawStepTable
|
|||
obj = self
|
||||
@docx.p
|
||||
@docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE do
|
||||
if table.metadata
|
||||
table.metadata['cells'].each do |cell|
|
||||
if table.metadata.present?
|
||||
table.metadata['cells']&.each do |cell|
|
||||
data = cell[1]
|
||||
next unless data.present? && data['row'].present? && data['col'].present? && data['className'].present?
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
<body
|
||||
class="<%= yield :body_class %>"
|
||||
<% if user_signed_in? && current_team.present? %>
|
||||
data-current-team-id="<%= current_team.id %>"
|
||||
data-atwho-users-url="<%= atwho_users_team_path(current_team) %>"
|
||||
data-atwho-task-url="<%= atwho_my_modules_team_path(current_team) %>"
|
||||
data-atwho-project-url="<%= atwho_projects_team_path(current_team) %>"
|
||||
|
|
Loading…
Reference in a new issue