diff --git a/app/assets/javascripts/repositories/repository_datatable.js b/app/assets/javascripts/repositories/repository_datatable.js index f9a13a7bf..b2329d9a5 100644 --- a/app/assets/javascripts/repositories/repository_datatable.js +++ b/app/assets/javascripts/repositories/repository_datatable.js @@ -284,10 +284,6 @@ var RepositoryDatatable = (function(global) { }); } - function updateSelectedRowsForAssignments() { - window.AssignItemsToTaskModalComponent.setShowCallback(() => rowsSelected); - } - function checkAvailableColumns() { $.ajax({ url: $(TABLE_ID).data('available-columns'), @@ -887,7 +883,6 @@ var RepositoryDatatable = (function(global) { }) initRowSelection(); - updateSelectedRowsForAssignments(); return TABLE; } @@ -1023,7 +1018,7 @@ var RepositoryDatatable = (function(global) { e.preventDefault(); e.stopPropagation(); - window.AssignItemsToTaskModalComponentContainer.showModal(); + window.AssignItemsToTaskModalComponentContainer.showModal(rowsSelected); }) .on('click', '#deleteRepositoryRecords', function(e) { e.preventDefault(); diff --git a/app/assets/javascripts/sitewide/repository_row_card.js b/app/assets/javascripts/sitewide/repository_row_card.js index ef38a88ab..45b049241 100644 --- a/app/assets/javascripts/sitewide/repository_row_card.js +++ b/app/assets/javascripts/sitewide/repository_row_card.js @@ -4,11 +4,13 @@ 'use strict'; $(document).on('click', '.record-info-link', function(e) { + const myModuleId = $('.my-modules-protocols-index').data('task-id'); + const repositoryRowURL = $(this).attr('href'); + e.stopPropagation(); e.preventDefault(); - const repositoryRowURL = $(this).attr('href'); - window.repositoryItemSidebarComponent.toggleShowHideSidebar(repositoryRowURL); + window.repositoryItemSidebarComponent.toggleShowHideSidebar(repositoryRowURL, myModuleId); }); $(document).on('click', '.print-label-button', function(e) { @@ -30,8 +32,8 @@ $(document).on('click', '.assign-inventory-button', function(e) { e.preventDefault(); - let assignUrl = $(this).data('assignUrl'); - let repositoryRowId = $(this).data('repositoryRowId'); + const assignUrl = $(this).attr('data-assign-url'); + const repositoryRowId = $(this).attr('data-repository-row-id'); $.ajax({ url: assignUrl, @@ -44,6 +46,7 @@ if (typeof MyModuleRepositories !== 'undefined') { MyModuleRepositories.reloadRepositoriesList(repositoryRowId); } + window.repositoryItemSidebarComponent.reload(); }, error: function(error) { HelperModule.flashAlertMsg(error.responseJSON.flash, 'danger'); diff --git a/app/assets/stylesheets/tailwind/buttons.css b/app/assets/stylesheets/tailwind/buttons.css index 14d1c2001..6a3b96db4 100644 --- a/app/assets/stylesheets/tailwind/buttons.css +++ b/app/assets/stylesheets/tailwind/buttons.css @@ -137,4 +137,18 @@ .btn.btn-danger.disabled { @apply bg-sn-delete-red-disabled; } + + .btn-text-link { + @apply text-sn-blue text-sm cursor-pointer + } + + .btn-text-link:visited, + .btn-text-link:hover { + @apply text-sn-blue no-underline + } + + .btn-text-link.disabled, + .btn-text-link:disabled { + @apply text-sn-sleepy-grey + } } diff --git a/app/controllers/repository_rows_controller.rb b/app/controllers/repository_rows_controller.rb index fff4a0c87..d0b01d61d 100644 --- a/app/controllers/repository_rows_controller.rb +++ b/app/controllers/repository_rows_controller.rb @@ -46,7 +46,9 @@ class RepositoryRowsController < ApplicationController @repository_row = @repository.repository_rows.find_by(id: params[:id]) return render_404 unless @repository_row - @my_module = @repository_row.my_modules.find_by(id: params[:my_module_id]) + @my_module = if params[:my_module_id].present? + MyModule.repository_row_assignable_by_user(current_user).find_by(id: params[:my_module_id]) + end return render_403 if @my_module && !can_read_my_module?(@my_module) if @my_module diff --git a/app/javascript/packs/vue/assign_items_to_task_modal.js b/app/javascript/packs/vue/assign_items_to_task_modal.js index ab7ddad48..e21c428ba 100644 --- a/app/javascript/packs/vue/assign_items_to_task_modal.js +++ b/app/javascript/packs/vue/assign_items_to_task_modal.js @@ -20,6 +20,7 @@ function initAssignItemsToTaskModalComponent() { data() { return { visibility: false, + rowsToAssign: [], urls: { assign: container.data('assign-url'), projects: container.data('projects-url'), @@ -29,7 +30,8 @@ function initAssignItemsToTaskModalComponent() { }; }, methods: { - showModal() { + showModal(repositoryRows) { + this.rowsToAssign = repositoryRows; this.visibility = true; }, closeModal() { diff --git a/app/javascript/vue/assign_items_to_tasks_modal/container.vue b/app/javascript/vue/assign_items_to_tasks_modal/container.vue index 7c2eb4edd..aed6d0568 100644 --- a/app/javascript/vue/assign_items_to_tasks_modal/container.vue +++ b/app/javascript/vue/assign_items_to_tasks_modal/container.vue @@ -145,11 +145,11 @@ export default { name: "AssignItemsToTaskModalContainer", props: { visibility: Boolean, - urls: Object + urls: Object, + rowsToAssign: Array }, data() { return { - rowsToAssign: [], projects: [], experiments: [], tasks: [], @@ -159,15 +159,11 @@ export default { projectsLoading: null, experimentsLoading: null, tasksLoading: null, - showCallback: null }; }, components: { SelectSearch }, - created() { - window.AssignItemsToTaskModalComponent = this; - }, mounted() { $(this.$refs.modal).on("shown.bs.modal", () => { this.projectsLoading = true; @@ -239,8 +235,6 @@ export default { methods: { showModal() { $(this.$refs.modal).modal("show"); - - this.rowsToAssign = this.showCallback(); }, hideModal() { $(this.$refs.modal).modal("hide"); @@ -317,11 +311,9 @@ export default { }).always(() => { this.resetSelectors(); this.reloadTable(); + window.repositoryItemSidebarComponent.reload(); }); }, - setShowCallback(callback) { - this.showCallback = callback; - }, reloadTable() { $('.repository-row-selector:checked').trigger('click'); $('.repository-table') diff --git a/app/javascript/vue/repository_item_sidebar/RepositoryItemSidebar.vue b/app/javascript/vue/repository_item_sidebar/RepositoryItemSidebar.vue index bb8ff0a55..880dbf427 100644 --- a/app/javascript/vue/repository_item_sidebar/RepositoryItemSidebar.vue +++ b/app/javascript/vue/repository_item_sidebar/RepositoryItemSidebar.vue @@ -114,12 +114,21 @@
-