mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-09 22:23:28 +08:00
Merge pull request #7159 from G-Chubinidze/gc_SCI_10251
Inventory duplicating and stock column issues [SCI-10251]
This commit is contained in:
commit
ca26f60f7a
5 changed files with 16 additions and 4 deletions
|
@ -236,6 +236,13 @@ class RepositoriesController < ApplicationController
|
||||||
render json: @tmp_repository.errors, status: :unprocessable_entity
|
render json: @tmp_repository.errors, status: :unprocessable_entity
|
||||||
else
|
else
|
||||||
copied_repository = @repository.copy(current_user, @tmp_repository.name)
|
copied_repository = @repository.copy(current_user, @tmp_repository.name)
|
||||||
|
old_repo_stock_column = @repository.repository_columns.find_by(data_type: 'RepositoryStockValue')
|
||||||
|
copied_repo_stock_column = copied_repository.repository_columns.find_by(data_type: 'RepositoryStockValue')
|
||||||
|
|
||||||
|
if old_repo_stock_column && copied_repo_stock_column
|
||||||
|
copied_repo_stock_column.repository_stock_unit_items = old_repo_stock_column.repository_stock_unit_items
|
||||||
|
copied_repository.save!
|
||||||
|
end
|
||||||
|
|
||||||
if !copied_repository
|
if !copied_repository
|
||||||
render json: { name: ['Server error'] }, status: :unprocessable_entity
|
render json: { name: ['Server error'] }, status: :unprocessable_entity
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
<button type='button' class='btn btn-secondary' data-dismiss='modal'>
|
<button type='button' class='btn btn-secondary' data-dismiss='modal'>
|
||||||
{{ i18n.t('general.cancel') }}
|
{{ i18n.t('general.cancel') }}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-primary" @click="validateAndsaveStockValue">
|
<button class="btn btn-primary" @click="validateAndsaveStockValue" :disabled="isSaving">
|
||||||
{{ i18n.t('repository_stock_values.manage_modal.save_stock') }}
|
{{ i18n.t('repository_stock_values.manage_modal.save_stock') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -161,6 +161,7 @@ export default {
|
||||||
units: null,
|
units: null,
|
||||||
unit: null,
|
unit: null,
|
||||||
reminderEnabled: false,
|
reminderEnabled: false,
|
||||||
|
isSaving: false,
|
||||||
lowStockTreshold: null,
|
lowStockTreshold: null,
|
||||||
comment: null,
|
comment: null,
|
||||||
errors: {}
|
errors: {}
|
||||||
|
@ -263,6 +264,7 @@ export default {
|
||||||
this.errors = newErrors;
|
this.errors = newErrors;
|
||||||
|
|
||||||
if (!$.isEmptyObject(newErrors)) return;
|
if (!$.isEmptyObject(newErrors)) return;
|
||||||
|
this.isSaving = true;
|
||||||
|
|
||||||
const $this = this;
|
const $this = this;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -282,6 +284,7 @@ export default {
|
||||||
},
|
},
|
||||||
success: (result) => {
|
success: (result) => {
|
||||||
$this.stockValue = null;
|
$this.stockValue = null;
|
||||||
|
$this.isSaving = false;
|
||||||
$this.closeModal();
|
$this.closeModal();
|
||||||
$this.closeCallback && $this.closeCallback(result);
|
$this.closeCallback && $this.closeCallback(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,12 @@
|
||||||
<div class="form-group sci-input-container">
|
<div class="form-group sci-input-container">
|
||||||
<label><%= t("repositories.index.modal_copy.name") %></label>
|
<label><%= t("repositories.index.modal_copy.name") %></label>
|
||||||
<%= f.text_field :name,
|
<%= f.text_field :name,
|
||||||
help: t("repositories.index.modal_copy.description"),
|
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
class: "sci-input-field",
|
class: "sci-input-field",
|
||||||
placeholder: t("repositories.index.modal_copy.name_placeholder") %>
|
placeholder: t("repositories.index.modal_copy.name_placeholder") %>
|
||||||
|
<div class="text-red-500">
|
||||||
|
<%= t("repositories.index.modal_copy.description") %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,5 +12,5 @@
|
||||||
data: { min: 0, max: Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS }) %>
|
data: { min: 0, max: Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS }) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= javascript_include_tag 'repository_columns/manage_column_partials/number' %>
|
<%= javascript_include_tag 'repository_columns/manage_column_partials/number', nonce: true %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
class: 'form-control stock-column',
|
class: 'form-control stock-column',
|
||||||
data: { min: 0, max: Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS }) %>
|
data: { min: 0, max: Constants::REPOSITORY_NUMBER_TYPE_MAX_DECIMALS }) %>
|
||||||
|
|
||||||
<%= javascript_include_tag 'repository_columns/manage_column_partials/stock' %>
|
<%= javascript_include_tag 'repository_columns/manage_column_partials/stock', nonce: true %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
Loading…
Reference in a new issue