mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 11:14:24 +08:00
Update front end validation for columns managment [SCI-6657] (#3962)
Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
parent
725549c8ca
commit
103e20ee9a
6 changed files with 58 additions and 21 deletions
|
@ -31,7 +31,7 @@ var RepositoryStockColumnType = (function() {
|
|||
dropdownOptions,
|
||||
GLOBAL_CONSTANTS.REPOSITORY_LIST_ITEMS_PER_COLUMN
|
||||
);
|
||||
$('.changing-existing-list-items-warning').removeClass('hidden');
|
||||
$('.changing-existing-stock-units-warning').removeClass('hidden');
|
||||
initStockUnitDropdown();
|
||||
})
|
||||
.on('columnModal::partialLoadedForRepositoryStockValue', function() {
|
||||
|
@ -53,6 +53,12 @@ var RepositoryStockColumnType = (function() {
|
|||
checkValidation: () => {
|
||||
var $manageModal = $(manageModal);
|
||||
var count = $manageModal.find('.items-count').attr('data-count');
|
||||
if ($manageModal.find('.stock-column-type .items-textarea').val().length) {
|
||||
$manageModal.find('.stock-column-type .items-textarea').parent().removeClass('error');
|
||||
} else {
|
||||
$manageModal.find('.stock-column-type .items-textarea').parent().addClass('error');
|
||||
return false;
|
||||
}
|
||||
return count <= GLOBAL_CONSTANTS.REPOSITORY_STOCK_UNIT_ITEMS_PER_COLUMN;
|
||||
},
|
||||
loadParams: () => {
|
||||
|
|
|
@ -68,13 +68,18 @@ var RepositoryColumns = (function() {
|
|||
}
|
||||
|
||||
function checkData() {
|
||||
var status = true;
|
||||
var currentPartial = $('#repository-column-data-type').val();
|
||||
|
||||
if (columnTypeClassNames[currentPartial]) {
|
||||
return eval(columnTypeClassNames[currentPartial])
|
||||
.checkValidation();
|
||||
if ($('#repository-column-name').val().length === 0) {
|
||||
$('#repository-column-name').parent().addClass('error');
|
||||
status = false;
|
||||
} else {
|
||||
$('#repository-column-name').parent().removeClass('error');
|
||||
}
|
||||
return true;
|
||||
if (columnTypeClassNames[currentPartial]) {
|
||||
status = eval(columnTypeClassNames[currentPartial]).checkValidation() && status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
function addSpecificParams(type, params) {
|
||||
|
|
|
@ -4,5 +4,24 @@
|
|||
@include font-small;
|
||||
color: $color-silver-chalice;
|
||||
}
|
||||
|
||||
.changing-existing-stock-units-warning {
|
||||
@include font-small;
|
||||
background-color: $brand-warning-light;
|
||||
padding: .5em;
|
||||
}
|
||||
|
||||
.sci-input-container.error {
|
||||
margin-bottom: 3em;
|
||||
|
||||
.changing-existing-stock-units-warning {
|
||||
bottom: -3.5em;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.units-info-description {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,13 @@
|
|||
<%= t('libraries.manange_modal_column.name') %>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<input placeholder="<%= t('libraries.manange_modal_column.name_placeholder') %>"
|
||||
class="form-control"
|
||||
type="text"
|
||||
name="repository_column[name]"
|
||||
id="repository-column-name" value="<%= @repository_column.name unless @repository_column.new_record? %>">
|
||||
<div class="sci-input-container" data-error-text="<%= t('libraries.manange_modal_column.empty_name_error') %>">
|
||||
<input placeholder="<%= t('libraries.manange_modal_column.name_placeholder') %>"
|
||||
class="sci-input-field"
|
||||
type="text"
|
||||
name="repository_column[name]"
|
||||
id="repository-column-name" value="<%= @repository_column.name unless @repository_column.new_record? %>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
@ -24,17 +24,19 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<% units = column.new_record? ? RepositoryStockUnitItem::DEFAULT_UNITS : column.repository_stock_unit_items.pluck(:data) %>
|
||||
<%= text_area_tag 'items-textarea', units.join(Constants::REPOSITORY_LIST_ITEMS_DELIMITERS_MAP[:return]),
|
||||
rows: 10, class: 'form-control items-textarea',
|
||||
placeholder: t('libraries.manange_modal_column.stock_type.textarea_placeholder_html') %>
|
||||
<% unless column.new_record? %>
|
||||
<div class="bg-danger hidden changing-existing-list-items-warning">
|
||||
<%= t('libraries.manange_modal_column.change_multi_select_items_warning') %>
|
||||
<div class="sci-input-container" data-error-text="<%= t('libraries.manange_modal_column.stock_type.empty_units_error') %>">
|
||||
<% units = column.new_record? ? RepositoryStockUnitItem::DEFAULT_UNITS : column.repository_stock_unit_items.pluck(:data) %>
|
||||
<%= text_area_tag 'items-textarea', units.join(Constants::REPOSITORY_LIST_ITEMS_DELIMITERS_MAP[:return]),
|
||||
rows: 10, class: 'form-control items-textarea sci-input-field',
|
||||
placeholder: t('libraries.manange_modal_column.stock_type.textarea_placeholder_html') %>
|
||||
<% unless column.new_record? %>
|
||||
<div class="hidden changing-existing-stock-units-warning">
|
||||
<%= t('libraries.manange_modal_column.stock_type.units_changing_warning') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="units-info-description">
|
||||
<%= t('libraries.manange_modal_column.stock_type.units_description') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="units-info-description">
|
||||
<%= t('libraries.manange_modal_column.stock_type.units_description') %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1731,6 +1731,7 @@ en:
|
|||
add_column: "Add column"
|
||||
manange_modal_column:
|
||||
name_placeholder: "Enter column name..."
|
||||
empty_name_error: "Colmun must have a name."
|
||||
name: "Name"
|
||||
colum_type: "Column type"
|
||||
dropdown_item_descirption: "Dropdown items should be separated by comma."
|
||||
|
@ -1802,6 +1803,8 @@ en:
|
|||
stock_consumption_locked: "Can't consume"
|
||||
no_item_stock: 'No item stock'
|
||||
textarea_placeholder_html: 'Enter your preferred units in separate rows Just Like This'
|
||||
units_changing_warning: 'Careful: Changing units will remove previously selected units'
|
||||
empty_units_error: 'Enter at least one unit.'
|
||||
checklist_type:
|
||||
multiple_options: 'selected'
|
||||
all_options: 'All options'
|
||||
|
|
Loading…
Reference in a new issue