Stock editing and reminder fixes [SCI-6803] (#4078)

* Fix stock editing after adding new value [SCI-6803]

* Don't load reminders for snapshots [SCI-6803]
This commit is contained in:
artoscinote 2022-05-09 11:20:38 +02:00 committed by GitHub
parent 297c58c0cd
commit 98ac1c126f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -78,9 +78,11 @@ var RepositoryStockValues = (function() {
$manageModal.find('form').on('ajax:success', function(_, data) {
$manageModal.modal('hide');
$('.dataTable').find(
let $cell = $('.dataTable').find(
`tr:nth-child(${rowIndex}) td:nth-child(${colIndex + 1})`
).html(
);
$cell.parent().data('manage-stock-url', data.manageStockUrl);
$cell.html(
$.fn.dataTable.render.RepositoryStockValue(data)
);
});

View file

@ -49,7 +49,8 @@ class RepositoryStockValuesController < ApplicationController
render json: {
stock_managable: true,
stock_status: @repository_stock_value.status
stock_status: @repository_stock_value.status,
manageStockUrl: edit_repository_stock_repository_repository_row_url(@repository, @repository_row)
}.merge(display_cell_value(@repository_stock_value.repository_cell, current_team, @repository))
end

View file

@ -275,6 +275,9 @@ module RepositoryDatatableHelper
# don't load reminders for archived repositories
return [] if repository_rows.blank? || repository.archived?
# don't load reminders for snapshots
return [] if repository.is_a?(RepositorySnapshot)
repository_rows.active.with_active_reminders(current_user).to_a.pluck(:id).uniq
end