mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 11:57:16 +08:00
Fix markup and naming
This commit is contained in:
parent
f480c0eb8d
commit
a843a016a0
5 changed files with 60 additions and 57 deletions
|
@ -449,7 +449,7 @@ var FilePreviewModal = (function() {
|
||||||
if (!readOnly && data.editable) {
|
if (!readOnly && data.editable) {
|
||||||
modal.find('.file-edit-link').css('display', '');
|
modal.find('.file-edit-link').css('display', '');
|
||||||
modal.find('.file-edit-link').off().click(function(ev) {
|
modal.find('.file-edit-link').off().click(function(ev) {
|
||||||
$.post('/files/' + data.id + '/start_edit');
|
$.post('/files/' + data.id + '/start_edit_image');
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
modal.modal('hide');
|
modal.modal('hide');
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
class AssetsController < ApplicationController
|
class AssetsController < ApplicationController
|
||||||
include WopiUtil
|
include WopiUtil
|
||||||
|
include AssetsActions
|
||||||
# include ActionView::Helpers
|
# include ActionView::Helpers
|
||||||
include ActionView::Helpers::AssetTagHelper
|
include ActionView::Helpers::AssetTagHelper
|
||||||
include ActionView::Helpers::TextHelper
|
include ActionView::Helpers::TextHelper
|
||||||
|
@ -155,11 +156,8 @@ class AssetsController < ApplicationController
|
||||||
render layout: false
|
render layout: false
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_edit
|
def create_start_edit_image_activity
|
||||||
asset = Asset.find_by_id(params[:id])
|
create_edit_image_activity(@asset, current_user, :start_editing)
|
||||||
return render_403 unless asset
|
|
||||||
|
|
||||||
create_edit_image_activity(asset, current_user, true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_image
|
def update_image
|
||||||
|
@ -171,7 +169,7 @@ class AssetsController < ApplicationController
|
||||||
@asset.file = params[:image]
|
@asset.file = params[:image]
|
||||||
@asset.file_file_name = orig_file_name
|
@asset.file_file_name = orig_file_name
|
||||||
@asset.save!
|
@asset.save!
|
||||||
create_edit_image_activity(@asset, current_user, false)
|
create_edit_image_activity(@asset, current_user, :finish_editing)
|
||||||
# release previous image space
|
# release previous image space
|
||||||
@asset.team.release_space(orig_file_size)
|
@asset.team.release_space(orig_file_size)
|
||||||
# Post process file here
|
# Post process file here
|
||||||
|
@ -315,52 +313,4 @@ class AssetsController < ApplicationController
|
||||||
|
|
||||||
'file'
|
'file'
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_edit_image_activity(asset, current_user, started_editing)
|
|
||||||
action = if started_editing
|
|
||||||
t('activities.file_editing.started')
|
|
||||||
else
|
|
||||||
t('activities.file_editing.finished')
|
|
||||||
end
|
|
||||||
if asset.step.class == Step
|
|
||||||
protocol = asset.step.protocol
|
|
||||||
default_step_items =
|
|
||||||
{ step: asset.step.id,
|
|
||||||
step_position: { id: asset.step.id, value_for: 'position_plus_one' },
|
|
||||||
asset_name: { id: asset.id, value_for: 'file_file_name' },
|
|
||||||
action: action }
|
|
||||||
if protocol.in_module?
|
|
||||||
project = protocol.my_module.experiment.project
|
|
||||||
team = project.team
|
|
||||||
type_of = :edit_image_on_step
|
|
||||||
message_items = { my_module: protocol.my_module.id }
|
|
||||||
else
|
|
||||||
type_of = :edit_image_on_step_in_repository
|
|
||||||
project = nil
|
|
||||||
team = protocol.team
|
|
||||||
message_items = { protocol: protocol.id }
|
|
||||||
end
|
|
||||||
message_items = default_step_items.merge(message_items)
|
|
||||||
Activities::CreateActivityService
|
|
||||||
.call(activity_type: type_of,
|
|
||||||
owner: current_user,
|
|
||||||
subject: protocol,
|
|
||||||
team: team,
|
|
||||||
project: project,
|
|
||||||
message_items: message_items)
|
|
||||||
elsif asset.result.class == Result
|
|
||||||
my_module = asset.result.my_module
|
|
||||||
Activities::CreateActivityService
|
|
||||||
.call(activity_type: :edit_image_on_result,
|
|
||||||
owner: current_user,
|
|
||||||
subject: asset.result,
|
|
||||||
team: my_module.experiment.project.team,
|
|
||||||
project: my_module.experiment.project,
|
|
||||||
message_items: {
|
|
||||||
result: asset.result.id,
|
|
||||||
asset_name: { id: asset.id, value_for: 'file_file_name' },
|
|
||||||
action: action
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
53
app/controllers/concerns/assets_actions.rb
Normal file
53
app/controllers/concerns/assets_actions.rb
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module AssetsActions
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
def create_edit_image_activity(asset, current_user, started_editing)
|
||||||
|
action = if started_editing == :start_editing
|
||||||
|
t('activities.file_editing.started')
|
||||||
|
elsif started_editing == :finish_editing
|
||||||
|
t('activities.file_editing.finished')
|
||||||
|
end
|
||||||
|
if asset.step.class == Step
|
||||||
|
protocol = asset.step.protocol
|
||||||
|
default_step_items =
|
||||||
|
{ step: asset.step.id,
|
||||||
|
step_position: { id: asset.step.id, value_for: 'position_plus_one' },
|
||||||
|
asset_name: { id: asset.id, value_for: 'file_file_name' },
|
||||||
|
action: action }
|
||||||
|
if protocol.in_module?
|
||||||
|
project = protocol.my_module.experiment.project
|
||||||
|
team = project.team
|
||||||
|
type_of = :edit_image_on_step
|
||||||
|
message_items = { my_module: protocol.my_module.id }
|
||||||
|
else
|
||||||
|
type_of = :edit_image_on_step_in_repository
|
||||||
|
project = nil
|
||||||
|
team = protocol.team
|
||||||
|
message_items = { protocol: protocol.id }
|
||||||
|
end
|
||||||
|
message_items = default_step_items.merge(message_items)
|
||||||
|
Activities::CreateActivityService
|
||||||
|
.call(activity_type: type_of,
|
||||||
|
owner: current_user,
|
||||||
|
subject: protocol,
|
||||||
|
team: team,
|
||||||
|
project: project,
|
||||||
|
message_items: message_items)
|
||||||
|
elsif asset.result.class == Result
|
||||||
|
my_module = asset.result.my_module
|
||||||
|
Activities::CreateActivityService
|
||||||
|
.call(activity_type: :edit_image_on_result,
|
||||||
|
owner: current_user,
|
||||||
|
subject: asset.result,
|
||||||
|
team: my_module.experiment.project.team,
|
||||||
|
project: my_module.experiment.project,
|
||||||
|
message_items: {
|
||||||
|
result: asset.result.id,
|
||||||
|
asset_name: { id: asset.id, value_for: 'file_file_name' },
|
||||||
|
action: action
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -233,7 +233,7 @@ class Extends
|
||||||
experiment: [*27..31, 57],
|
experiment: [*27..31, 57],
|
||||||
reports: [48, 50, 49],
|
reports: [48, 50, 49],
|
||||||
inventories: [70, 71, 105, 72, 73, 74, 102, 75, 76, 77, 78, 96, 107],
|
inventories: [70, 71, 105, 72, 73, 74, 102, 75, 76, 77, 78, 96, 107],
|
||||||
protocol_repository: [80, 103, 89, 87, 79, 90, 91, 88, 85, 86, 84, 81, 82, 83, 101, 102],
|
protocol_repository: [80, 103, 89, 87, 79, 90, 91, 88, 85, 86, 84, 81, 82, 83, 101, 112],
|
||||||
team: [92, 94, 93, 97, 104]
|
team: [92, 94, 93, 97, 104]
|
||||||
}.freeze
|
}.freeze
|
||||||
end
|
end
|
||||||
|
|
|
@ -593,7 +593,7 @@ Rails.application.routes.draw do
|
||||||
post 'files/create_wopi_file',
|
post 'files/create_wopi_file',
|
||||||
to: 'assets#create_wopi_file',
|
to: 'assets#create_wopi_file',
|
||||||
as: 'create_wopi_file'
|
as: 'create_wopi_file'
|
||||||
post 'files/:id/start_edit', to: 'assets#start_edit', as: 'start_edit_asset'
|
post 'files/:id/start_edit_image', to: 'assets#create_start_edit_image_activity', as: 'start_edit_image'
|
||||||
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
get 'avatar/:id/:style' => 'users/registrations#avatar', as: 'avatar'
|
get 'avatar/:id/:style' => 'users/registrations#avatar', as: 'avatar'
|
||||||
|
|
Loading…
Add table
Reference in a new issue