mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 21:21:50 +08:00
Add missed notifications to steps and fix notification for protocol repository [SCI-7531]
This commit is contained in:
parent
0788072df1
commit
98572d9a2c
5 changed files with 18 additions and 10 deletions
|
@ -276,12 +276,14 @@ class MyModulesController < ApplicationController
|
|||
|
||||
def update_protocol
|
||||
protocol = @my_module.protocol
|
||||
old_description = protocol.description
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
protocol.update!(protocol_params)
|
||||
log_activity(:protocol_name_in_task_edited) if protocol.saved_change_to_name?
|
||||
log_activity(:protocol_description_in_task_edited) if protocol.saved_change_to_description?
|
||||
TinyMceAsset.update_images(protocol, params[:tiny_mce_images], current_user)
|
||||
protocol_annotation_notification(old_description)
|
||||
end
|
||||
|
||||
render json: protocol, serializer: ProtocolSerializer, user: current_user
|
||||
|
|
|
@ -287,9 +287,6 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
# This is the "info" view
|
||||
current_team_switch(@project.team)
|
||||
|
||||
view_state = @project.current_view_state(current_user)
|
||||
@current_sort = view_state.state.dig('experiments', experiments_view_mode(@project), 'sort') || 'atoz'
|
||||
@current_view_type = view_state.state.dig('experiments', 'view_type')
|
||||
|
@ -386,6 +383,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def check_view_permissions
|
||||
current_team_switch(@project.team) if current_team != @project.team
|
||||
render_403 unless can_read_project?(@project)
|
||||
end
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ class ProtocolsController < ApplicationController
|
|||
before_action :check_clone_permissions, only: [:clone]
|
||||
before_action :check_view_permissions, only: %i(
|
||||
show
|
||||
edit
|
||||
protocol_status_bar
|
||||
updated_at_label
|
||||
preview
|
||||
|
@ -30,7 +31,6 @@ class ProtocolsController < ApplicationController
|
|||
# For update_from_parent and update_from_parent_modal we don't need to check
|
||||
# read permission for the parent protocol
|
||||
before_action :check_manage_permissions, only: %i(
|
||||
edit
|
||||
update_keywords
|
||||
update_description
|
||||
update_name
|
||||
|
@ -161,13 +161,10 @@ class ProtocolsController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
# Switch to correct team
|
||||
current_team_switch(@protocol.team)
|
||||
render :show
|
||||
end
|
||||
|
||||
def show
|
||||
# Switch to correct team
|
||||
current_team_switch(@protocol.team)
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: @protocol, serializer: ProtocolSerializer, user: current_user }
|
||||
|
@ -1102,6 +1099,7 @@ class ProtocolsController < ApplicationController
|
|||
|
||||
def check_view_permissions
|
||||
@protocol = Protocol.find_by_id(params[:id])
|
||||
current_team_switch(@protocol.team) if current_team != @protocol.team
|
||||
unless @protocol.present? &&
|
||||
(can_read_protocol_in_module?(@protocol) ||
|
||||
can_read_protocol_in_repository?(@protocol))
|
||||
|
@ -1245,7 +1243,7 @@ class ProtocolsController < ApplicationController
|
|||
user: current_user.full_name,
|
||||
protocol: @protocol.name),
|
||||
message: t('notifications.protocol_description_annotation_message_html',
|
||||
protocol: link_to(@protocol.name, edit_protocol_url(@protocol)))
|
||||
protocol: link_to(@protocol.name, protocol_url(@protocol)))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
module StepElements
|
||||
class ChecklistItemsController < ApplicationController
|
||||
include ApplicationHelper
|
||||
include StepsActions
|
||||
|
||||
before_action :load_vars
|
||||
before_action :load_checklist_item, only: %i(update toggle destroy)
|
||||
|
@ -21,6 +22,7 @@ module StepElements
|
|||
checklist_name: @checklist.name
|
||||
}
|
||||
)
|
||||
checklist_item_annotation(@step, checklist_item)
|
||||
end
|
||||
|
||||
render json: checklist_item, serializer: ChecklistItemSerializer, user: current_user
|
||||
|
@ -31,6 +33,7 @@ module StepElements
|
|||
end
|
||||
|
||||
def update
|
||||
old_text = @checklist_item.text
|
||||
@checklist_item.assign_attributes(
|
||||
checklist_item_params.merge(last_modified_by: current_user)
|
||||
)
|
||||
|
@ -41,6 +44,7 @@ module StepElements
|
|||
checklist_item: @checklist_item.text,
|
||||
checklist_name: @checklist.name
|
||||
)
|
||||
checklist_item_annotation(@step, @checklist_item, old_text)
|
||||
end
|
||||
|
||||
render json: @checklist_item, serializer: ChecklistItemSerializer, user: current_user
|
||||
|
@ -129,6 +133,8 @@ module StepElements
|
|||
@step = Step.find_by(id: params[:step_id])
|
||||
return render_404 unless @step
|
||||
|
||||
@protocol = @step.protocol
|
||||
|
||||
@checklist = @step.checklists.find_by(id: params[:checklist_id])
|
||||
return render_404 unless @checklist
|
||||
end
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
module StepElements
|
||||
class ChecklistsController < BaseController
|
||||
include ApplicationHelper
|
||||
include StepsActions
|
||||
before_action :load_checklist, only: %i(update destroy duplicate)
|
||||
|
||||
def create
|
||||
checklist = @step.checklists.build(
|
||||
name: t('protocols.steps.checklist.default_name', position: @step.checklists.length + 1)
|
||||
|
@ -11,6 +12,7 @@ module StepElements
|
|||
ActiveRecord::Base.transaction do
|
||||
create_in_step!(@step, checklist)
|
||||
log_step_activity(:checklist_added, { checklist_name: checklist.name })
|
||||
checklist_name_annotation(@step, checklist)
|
||||
end
|
||||
render_step_orderable_element(checklist)
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
|
@ -18,9 +20,11 @@ module StepElements
|
|||
end
|
||||
|
||||
def update
|
||||
old_name = @checklist.name
|
||||
ActiveRecord::Base.transaction do
|
||||
@checklist.update!(checklist_params)
|
||||
log_step_activity(:checklist_edited, { checklist_name: @checklist.name })
|
||||
checklist_name_annotation(@step, @checklist, old_name)
|
||||
end
|
||||
|
||||
render json: @checklist, serializer: ChecklistSerializer, user: current_user
|
||||
|
|
Loading…
Reference in a new issue