mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-05 20:54:27 +08:00
Update stock value without reloading the table [SCI-6745] (#4041)
This commit is contained in:
parent
42f79255df
commit
f9357611a0
2 changed files with 15 additions and 4 deletions
|
@ -41,6 +41,9 @@ var RepositoryStockValues = (function() {
|
|||
let amountChanged = false;
|
||||
|
||||
$('.repository-show').on('click', '.manage-repository-stock-value-link', function() {
|
||||
let colIndex = this.parentNode.cellIndex;
|
||||
let rowIndex = this.parentNode.parentNode.rowIndex;
|
||||
|
||||
$.ajax({
|
||||
url: $(this).closest('tr').data('manage-stock-url'),
|
||||
type: 'GET',
|
||||
|
@ -73,10 +76,13 @@ var RepositoryStockValues = (function() {
|
|||
.dropdown-selector-container .search-field
|
||||
`).attr('tabindex', 2);
|
||||
|
||||
$manageModal.find('form').on('ajax:success', function() {
|
||||
var dataTable = $('.dataTable').DataTable();
|
||||
$manageModal.find('form').on('ajax:success', function(_, data) {
|
||||
$manageModal.modal('hide');
|
||||
dataTable.ajax.reload(null, false);
|
||||
$('.dataTable').find(
|
||||
`tr:nth-child(${rowIndex}) td:nth-child(${colIndex + 1})`
|
||||
).html(
|
||||
$.fn.dataTable.render.RepositoryStockValue(data)
|
||||
);
|
||||
});
|
||||
|
||||
$('.stock-operator-option').click(function() {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RepositoryStockValuesController < ApplicationController
|
||||
include RepositoryDatatableHelper # for use of display_cell_value method on stock update
|
||||
|
||||
before_action :load_vars
|
||||
before_action :check_manage_permissions
|
||||
|
||||
|
@ -45,7 +47,10 @@ class RepositoryStockValuesController < ApplicationController
|
|||
)
|
||||
end
|
||||
|
||||
render json: @repository_stock_value
|
||||
render json: {
|
||||
stock_managable: true,
|
||||
stock_status: @repository_stock_value.status
|
||||
}.merge(display_cell_value(@repository_stock_value.repository_cell, current_team, @repository))
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Reference in a new issue