mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-14 09:04:56 +08:00
Task inventory activity for assigned item consumption [SCI-6453] (#3830)
* Add task inventory activity [SCI-6453]
This commit is contained in:
parent
bf058dea03
commit
959b86b40c
6 changed files with 43 additions and 3 deletions
|
@ -272,6 +272,12 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fa-comment {
|
||||
color: $color-silver-chalice;
|
||||
margin-right: 3px;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.no-activities-message {
|
||||
|
|
|
@ -160,6 +160,7 @@ class MyModuleRepositoriesController < ApplicationController
|
|||
def update_consumption
|
||||
module_repository_row = @my_module.my_module_repository_rows.find_by(id: params[:module_row_id])
|
||||
module_repository_row.with_lock do
|
||||
current_stock = module_repository_row.stock_consumption
|
||||
module_repository_row.assign_attributes(
|
||||
stock_consumption: params[:stock_consumption],
|
||||
repository_stock_unit_item_id:
|
||||
|
@ -168,6 +169,10 @@ class MyModuleRepositoriesController < ApplicationController
|
|||
comment: params[:comment]
|
||||
)
|
||||
module_repository_row.save!
|
||||
|
||||
log_activity(module_repository_row,
|
||||
current_stock,
|
||||
params[:comment])
|
||||
end
|
||||
|
||||
render json: {}, status: :ok
|
||||
|
@ -229,4 +234,22 @@ class MyModuleRepositoriesController < ApplicationController
|
|||
unassigned_items: unassigned_count)
|
||||
end
|
||||
end
|
||||
|
||||
def log_activity(module_repository_row, stock_consumption_was, comment)
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: :task_inventory_item_stock_consumed,
|
||||
owner: current_user,
|
||||
subject: @my_module,
|
||||
team: @repository.team,
|
||||
project: @my_module.experiment.project,
|
||||
message_items: {
|
||||
repository: @repository.id,
|
||||
repository_row: module_repository_row.repository_row_id,
|
||||
stock_consumption_was: stock_consumption_was || 0,
|
||||
unit: module_repository_row.repository_row.repository_stock_value.repository_stock_unit_item&.data || '',
|
||||
stock_consumption: module_repository_row.stock_consumption || 0,
|
||||
my_module: @my_module.id,
|
||||
comment: comment
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,10 @@ module GlobalActivitiesHelper
|
|||
else
|
||||
no_links ? generate_name(value) : generate_link(value, activity)
|
||||
end
|
||||
|
||||
if key == 'comment' && parameters[key].strip.present?
|
||||
parameters[key] = '<i class="fas fa-comment"></i>' + parameters[key]
|
||||
end
|
||||
end
|
||||
|
||||
if no_custom_links
|
||||
|
|
|
@ -47,4 +47,4 @@
|
|||
data-dismiss="modal"><%=t('general.cancel') %></button>
|
||||
<%= submit_tag t('general.save'), class: "btn btn-primary update-consumption-button", disabled: @module_repository_row.stock_consumption.nil? %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -328,7 +328,8 @@ class Extends
|
|||
register_molecule_on_step_in_repository: 179,
|
||||
inventory_item_stock_set: 180,
|
||||
inventory_item_stock_add: 181,
|
||||
inventory_item_stock_remove: 182
|
||||
inventory_item_stock_remove: 182,
|
||||
task_inventory_item_stock_consumed: 183
|
||||
}
|
||||
|
||||
ACTIVITY_GROUPS = {
|
||||
|
@ -338,7 +339,7 @@ class Extends
|
|||
*146..148, 166],
|
||||
task_protocol: [15, 22, 16, 18, 19, 20, 21, 17, 38, 39, 100, 111, 45, 46, 47, 121, 124, 115, 118, 127, 130, 137,
|
||||
168, 171, 177],
|
||||
task_inventory: [55, 56, 146, 147],
|
||||
task_inventory: [55, 56, 146, 147, 183],
|
||||
experiment: [*27..31, 57, 141, 165],
|
||||
reports: [48, 50, 49, 163, 164],
|
||||
inventories: [70, 71, 105, 144, 145, 72, 73, 74, 102, 142, 143, 75, 76, 77,
|
||||
|
|
|
@ -208,6 +208,7 @@ en:
|
|||
inventory_item_stock_set_html: "%{user} set total stock for %{repository_row} to %{new_amount} %{unit} in %{repository}"
|
||||
inventory_item_stock_add_html: "%{user} added %{change_amount} %{unit} of stock to a total of %{new_amount} %{unit} for %{repository_row} in %{repository}"
|
||||
inventory_item_stock_remove_html: "%{user} removed %{change_amount} %{unit} of stock to a total of %{new_amount} %{unit} for %{repository_row} in %{repository}"
|
||||
task_inventory_item_stock_consumed_html: "%{user} changed consumption of %{repository_row} from %{stock_consumption_was} %{unit} to %{stock_consumption} %{unit} in %{my_module} \n%{comment}"
|
||||
|
||||
activity_name:
|
||||
create_project: "Project created"
|
||||
|
@ -367,6 +368,11 @@ en:
|
|||
register_molecule_on_step: "Molecule on task step registered"
|
||||
register_molecule_on_result: "Molecule on result registered"
|
||||
register_molecule_on_step_in_repository: "Molecule on step registered"
|
||||
inventory_item_stock_set: "Inventory item stock set to"
|
||||
inventory_item_stock_add: "Inventory item stock added"
|
||||
inventory_item_stock_remove: "Inventory item stock removed"
|
||||
task_inventory_item_stock_consumed: "Task-assigned inventory item consumed"
|
||||
|
||||
|
||||
|
||||
activity_group:
|
||||
|
|
Loading…
Add table
Reference in a new issue