From cbe1eef8afe4b3059400425851559a983e96b799 Mon Sep 17 00:00:00 2001 From: Soufiane Date: Wed, 3 Jan 2024 14:15:30 +0100 Subject: [PATCH] Add the ability to unlink parent/child items [SCI-9712] (#6725) --- .../RepositoryItemSidebar.vue | 51 ++++++++++++------- .../repository_item_sidebar/unlink_modal.vue | 48 +++++++++++++++++ app/views/repository_rows/show.json.jbuilder | 10 ++++ config/locales/en.yml | 4 ++ 4 files changed, 96 insertions(+), 17 deletions(-) create mode 100644 app/javascript/vue/repository_item_sidebar/unlink_modal.vue diff --git a/app/javascript/vue/repository_item_sidebar/RepositoryItemSidebar.vue b/app/javascript/vue/repository_item_sidebar/RepositoryItemSidebar.vue index a11550917..256ebd98f 100644 --- a/app/javascript/vue/repository_item_sidebar/RepositoryItemSidebar.vue +++ b/app/javascript/vue/repository_item_sidebar/RepositoryItemSidebar.vue @@ -147,16 +147,15 @@
- + {{ i18n.t('repositories.item_card.relationships.item') }} {{ parent.name }} - +

@@ -194,12 +193,10 @@ {{ i18n.t('repositories.item_card.relationships.item') }} {{ child.name }} - +

@@ -309,6 +306,10 @@

+ + + + diff --git a/app/views/repository_rows/show.json.jbuilder b/app/views/repository_rows/show.json.jbuilder index b3bd57cd2..2f12b849e 100644 --- a/app/views/repository_rows/show.json.jbuilder +++ b/app/views/repository_rows/show.json.jbuilder @@ -52,20 +52,30 @@ json.relationships do json.children_count @repository_row.child_connections_count json.parents do json.array! @repository_row.parent_repository_rows.preload(:repository).each do |parent| + json.id parent.id json.code parent.code json.name parent.name json.path repository_repository_row_path(parent.repository, parent) json.repository_name parent.repository.name json.repository_path repository_path(parent.repository) + json.unlink_path repository_repository_row_repository_row_connection_path(parent.repository, + parent, + @repository_row.parent_connections + .find_by(parent: parent)) end end json.children do json.array! @repository_row.child_repository_rows.preload(:repository).each do |child| + json.id child.id json.code child.code json.name child.name json.path repository_repository_row_path(child.repository, child) json.repository_name child.repository.name json.repository_path repository_path(child.repository) + json.unlink_path repository_repository_row_repository_row_connection_path(child.repository, + child, + @repository_row.child_connections + .find_by(child: child)) end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index a7620b283..d6de24273 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2268,6 +2268,10 @@ en: children: count: "Children (%{count})" empty: "" + unlink_modal: + title: "Unlink item" + description: "Are you sure you want to unlink the item? Reconnection is possible later if needed." + unlink: "Unlink" default_columns: repository_name: "Inventory" id: "Item ID"