diff --git a/app/controllers/storage_location_repository_rows_controller.rb b/app/controllers/storage_location_repository_rows_controller.rb
index d59ebb08f..947a5c574 100644
--- a/app/controllers/storage_location_repository_rows_controller.rb
+++ b/app/controllers/storage_location_repository_rows_controller.rb
@@ -56,7 +56,10 @@ class StorageLocationRepositoryRowsController < ApplicationController
def actions_toolbar
render json: {
- actions: []
+ actions: Toolbars::StorageLocationRepositoryRowsService.new(
+ current_user,
+ items_ids: JSON.parse(params[:items]).map { |i| i['id'] }
+ ).actions
}
end
diff --git a/app/javascript/vue/storage_locations/box.vue b/app/javascript/vue/storage_locations/box.vue
index cc0811478..7b7140673 100644
--- a/app/javascript/vue/storage_locations/box.vue
+++ b/app/javascript/vue/storage_locations/box.vue
@@ -3,7 +3,10 @@
-
+
@@ -99,6 +102,17 @@ export default {
},
toolbarActions() {
const left = [];
+
+ if (!this.withGrid) {
+ left.push({
+ name: 'assign',
+ icon: 'sn-icon sn-icon-new-task',
+ label: this.i18n.t('storage_locations.show.toolbar.assign'),
+ type: 'emit',
+ buttonStyle: 'btn btn-primary'
+ });
+ }
+
return {
left,
right: []
diff --git a/app/services/toolbars/storage_location_repository_rows_service.rb b/app/services/toolbars/storage_location_repository_rows_service.rb
new file mode 100644
index 000000000..51acf366f
--- /dev/null
+++ b/app/services/toolbars/storage_location_repository_rows_service.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+module Toolbars
+ class StorageLocationRepositoryRowsService
+ attr_reader :current_user
+
+ include Canaid::Helpers::PermissionsHelper
+ include Rails.application.routes.url_helpers
+
+ def initialize(current_user, items_ids: [])
+ @current_user = current_user
+ @assigned_rows = StorageLocationRepositoryRow.where(id: items_ids)
+ @storage_location = @assigned_rows.first&.storage_location
+
+ @single = @assigned_rows.length == 1
+ end
+
+ def actions
+ return [] if @assigned_rows.none?
+
+ [
+ unassign_action,
+ move_action
+ ].compact
+ end
+
+ private
+
+ def unassign_action
+ {
+ name: 'edit',
+ label: I18n.t('storage_locations.show.toolbar.unassign'),
+ icon: 'sn-icon sn-icon-close',
+ path: unassign_storage_location_storage_location_repository_rows_path(
+ @storage_location, ids: @assigned_rows.pluck(:id)
+ ),
+ type: :emit
+ }
+ end
+
+ def move_action
+ return unless @single
+
+ {
+ name: 'move',
+ label: I18n.t('storage_locations.show.toolbar.move'),
+ icon: 'sn-icon sn-icon-move',
+ path: move_storage_location_storage_location_repository_row_path(
+ @storage_location, @assigned_rows.first
+ ),
+ type: :emit
+ }
+ end
+ end
+end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a81190bb9..b41684841 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2680,6 +2680,10 @@ en:
row_id: "Item ID"
row_name: "Name"
stock: "Stock"
+ toolbar:
+ assign: 'Assign item'
+ unassign: 'Unassign'
+ move: 'Move'
index:
head_title: "Locations"
new_location: "New location"
diff --git a/config/routes.rb b/config/routes.rb
index b4589d7db..22aa7ef24 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -819,6 +819,10 @@ Rails.application.routes.draw do
resources :storage_location_repository_rows, only: %i(index create destroy update) do
collection do
get :actions_toolbar
+ post :unassign
+ end
+ member do
+ post :move
end
end
end