mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-09 14:46:47 +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;
|
let amountChanged = false;
|
||||||
|
|
||||||
$('.repository-show').on('click', '.manage-repository-stock-value-link', function() {
|
$('.repository-show').on('click', '.manage-repository-stock-value-link', function() {
|
||||||
|
let colIndex = this.parentNode.cellIndex;
|
||||||
|
let rowIndex = this.parentNode.parentNode.rowIndex;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $(this).closest('tr').data('manage-stock-url'),
|
url: $(this).closest('tr').data('manage-stock-url'),
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
@ -73,10 +76,13 @@ var RepositoryStockValues = (function() {
|
||||||
.dropdown-selector-container .search-field
|
.dropdown-selector-container .search-field
|
||||||
`).attr('tabindex', 2);
|
`).attr('tabindex', 2);
|
||||||
|
|
||||||
$manageModal.find('form').on('ajax:success', function() {
|
$manageModal.find('form').on('ajax:success', function(_, data) {
|
||||||
var dataTable = $('.dataTable').DataTable();
|
|
||||||
$manageModal.modal('hide');
|
$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() {
|
$('.stock-operator-option').click(function() {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class RepositoryStockValuesController < ApplicationController
|
class RepositoryStockValuesController < ApplicationController
|
||||||
|
include RepositoryDatatableHelper # for use of display_cell_value method on stock update
|
||||||
|
|
||||||
before_action :load_vars
|
before_action :load_vars
|
||||||
before_action :check_manage_permissions
|
before_action :check_manage_permissions
|
||||||
|
|
||||||
|
@ -45,7 +47,10 @@ class RepositoryStockValuesController < ApplicationController
|
||||||
)
|
)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Add table
Reference in a new issue