From 7ee3f10247f1c68a19dade24657cad5284de4cb6 Mon Sep 17 00:00:00 2001 From: Andrej Date: Tue, 8 Oct 2024 13:50:12 +0200 Subject: [PATCH 01/20] Add legacy support for modals [SCI-11155] --- app/javascript/vue/shared/datatable/action_toolbar.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/javascript/vue/shared/datatable/action_toolbar.vue b/app/javascript/vue/shared/datatable/action_toolbar.vue index 6d97bfb6c..9486b946b 100644 --- a/app/javascript/vue/shared/datatable/action_toolbar.vue +++ b/app/javascript/vue/shared/datatable/action_toolbar.vue @@ -11,6 +11,8 @@ Date: Tue, 8 Oct 2024 14:39:08 +0200 Subject: [PATCH 02/20] Fix for storage locations import [SCI-11152] --- app/services/storage_locations/import_service.rb | 4 +++- config/locales/en.yml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/services/storage_locations/import_service.rb b/app/services/storage_locations/import_service.rb index 74f55c883..70bcb6ab0 100644 --- a/app/services/storage_locations/import_service.rb +++ b/app/services/storage_locations/import_service.rb @@ -15,7 +15,7 @@ module StorageLocations end def import_items - @rows = SpreadsheetParser.spreadsheet_enumerator(@sheet).reject { |r| r.all?(&:blank?) } + @rows = SpreadsheetParser.spreadsheet_enumerator(@sheet).to_a # Check if the file has proper headers header = SpreadsheetParser.parse_row(@rows[0], @sheet) @@ -73,6 +73,8 @@ module StorageLocations repository_row_id: (row[1].to_s.gsub('IT', '') if row[1].present?) } end + + @rows.reject! { |r| r[:repository_row_id].blank? && r[:position].blank? } end def import_row!(row) diff --git a/config/locales/en.yml b/config/locales/en.yml index 8fbd20bce..780dbbe20 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2709,7 +2709,7 @@ en: import_modal: import_button: 'Import items' title: "Import items to a box" - description: "Import items to a box allows for assigning items to a box and updating positions within a grid box. First, export the current box data to download a file listing the items already in the box. Then, edit the exported file to add or update the items you want to place in the box. When importing the file, ensure it includes the ‘Position’ and ‘Item ID’ columns for a successful import." + description: "Import items to a box allows for assigning items to a box and updating positions within a grid box. First, export the current box data to download a file listing the items already in the box. Then, edit the exported file to add or update the items you want to place in the box. When importing the file, ensure it includes the ‘Box position’ and ‘Item ID’ columns for a successful import." export: "Export" export_button: "Export current box" import: "Import" From 8ccc805cd872155c3742ff5a099c32928f07ad60 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 8 Oct 2024 15:22:25 +0200 Subject: [PATCH 03/20] Fix shared location duplication [SCI-11161] --- app/controllers/storage_locations_controller.rb | 2 +- app/models/storage_location.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/storage_locations_controller.rb b/app/controllers/storage_locations_controller.rb index 13da18b9c..43e3a6588 100644 --- a/app/controllers/storage_locations_controller.rb +++ b/app/controllers/storage_locations_controller.rb @@ -86,7 +86,7 @@ class StorageLocationsController < ApplicationController def duplicate ActiveRecord::Base.transaction do - new_storage_location = @storage_location.duplicate!(current_user) + new_storage_location = @storage_location.duplicate!(current_user, current_team) if new_storage_location @storage_location = new_storage_location log_activity('storage_location_created') diff --git a/app/models/storage_location.rb b/app/models/storage_location.rb index c2880c6fc..2553e9132 100644 --- a/app/models/storage_location.rb +++ b/app/models/storage_location.rb @@ -61,14 +61,15 @@ class StorageLocation < ApplicationRecord storage_location_repository_rows.count.zero? end - def duplicate!(user) + def duplicate!(user, team) ActiveRecord::Base.transaction do new_storage_location = dup new_storage_location.name = next_clone_name + new_storage_location.team = team unless parent_id new_storage_location.created_by = user new_storage_location.save! copy_image(self, new_storage_location) - recursive_duplicate(id, new_storage_location.id, user) + recursive_duplicate(id, new_storage_location.id, user, new_storage_location.team) new_storage_location rescue ActiveRecord::RecordInvalid false @@ -144,14 +145,15 @@ class StorageLocation < ApplicationRecord private - def recursive_duplicate(old_parent_id = nil, new_parent_id = nil, user = nil) + def recursive_duplicate(old_parent_id = nil, new_parent_id = nil, user = nil, team = nil) StorageLocation.where(parent_id: old_parent_id).find_each do |child| new_child = child.dup new_child.parent_id = new_parent_id + new_child.team = team new_child.created_by = user new_child.save! copy_image(child, new_child) - recursive_duplicate(child.id, new_child.id, user) + recursive_duplicate(child.id, new_child.id, user, team) end end From 024486d1402bf8bcdd556e0d8eb6d0be8e89c26d Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 9 Oct 2024 10:26:34 +0200 Subject: [PATCH 04/20] Fix moving inside shared storage locations [SCI-11149] --- app/controllers/storage_locations_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/storage_locations_controller.rb b/app/controllers/storage_locations_controller.rb index 13da18b9c..bdd615100 100644 --- a/app/controllers/storage_locations_controller.rb +++ b/app/controllers/storage_locations_controller.rb @@ -104,9 +104,11 @@ class StorageLocationsController < ApplicationController if move_params[:destination_storage_location_id] == 'root_storage_location' nil else - current_team.storage_locations.find(move_params[:destination_storage_location_id]) + StorageLocation.find(move_params[:destination_storage_location_id]) end + render_403 and return unless can_manage_storage_location?(destination_storage_location) + @storage_location.update!(parent: destination_storage_location) log_activity('storage_location_moved', { From 826feea2bb89ec59faf7a3114f263fbeae5d485f Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 9 Oct 2024 10:37:56 +0200 Subject: [PATCH 05/20] Add validation for unselected container [SCI-11167] --- app/javascript/vue/storage_locations/modals/assign.vue | 7 +++++-- app/javascript/vue/storage_locations/modals/move.vue | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/javascript/vue/storage_locations/modals/assign.vue b/app/javascript/vue/storage_locations/modals/assign.vue index 2cb53d78f..0a97fe58e 100644 --- a/app/javascript/vue/storage_locations/modals/assign.vue +++ b/app/javascript/vue/storage_locations/modals/assign.vue @@ -27,14 +27,14 @@ @@ -70,6 +70,9 @@ export default { }, mixins: [modalMixin], computed: { + validObject() { + return this.rowId && this.containerId && this.containerId > 0 && this.position; + }, createUrl() { return storage_location_storage_location_repository_rows_path({ storage_location_id: this.containerId diff --git a/app/javascript/vue/storage_locations/modals/move.vue b/app/javascript/vue/storage_locations/modals/move.vue index fd8cb851d..741bf8dd0 100644 --- a/app/javascript/vue/storage_locations/modals/move.vue +++ b/app/javascript/vue/storage_locations/modals/move.vue @@ -43,7 +43,7 @@ @@ -69,6 +69,11 @@ export default { created() { this.teamId = this.selectedObject.team_id; }, + computed: { + validContainer() { + return (this.selectedStorageLocationId && this.selectedStorageLocationId > 0) || this.selectedStorageLocationId === null; + } + }, mixins: [modalMixin, MoveTreeMixin], data() { return { From 746ac085077beb9581315a0d453de36eb4b2e7cb Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Wed, 9 Oct 2024 11:13:19 +0200 Subject: [PATCH 06/20] Add warning modal when unsharing inventories from teams [SCI-11159] --- app/javascript/vue/repositories/table.vue | 19 ++++++++++++ app/javascript/vue/shared/share_modal.vue | 37 +++++++++++++++++++---- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/app/javascript/vue/repositories/table.vue b/app/javascript/vue/repositories/table.vue index 9aaf91157..a7c11ce8e 100644 --- a/app/javascript/vue/repositories/table.vue +++ b/app/javascript/vue/repositories/table.vue @@ -54,8 +54,27 @@ v-if="shareRepository" :object="shareRepository" :globalShareEnabled="true" + :confirmationModal="$refs.shareConfirmationModal" @close="shareRepository = null" @share="updateTable" /> +