diff --git a/app/assets/javascripts/repository_columns/columns_initializers/stock_column_type.js b/app/assets/javascripts/repository_columns/columns_initializers/stock_column_type.js index c58a44081..1a2068cae 100644 --- a/app/assets/javascripts/repository_columns/columns_initializers/stock_column_type.js +++ b/app/assets/javascripts/repository_columns/columns_initializers/stock_column_type.js @@ -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: () => { diff --git a/app/assets/javascripts/repository_columns/index.js b/app/assets/javascripts/repository_columns/index.js index e9a495b7b..0fe71a2d0 100644 --- a/app/assets/javascripts/repository_columns/index.js +++ b/app/assets/javascripts/repository_columns/index.js @@ -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) { diff --git a/app/assets/stylesheets/repository_columns/stock_type.scss b/app/assets/stylesheets/repository_columns/stock_type.scss index 153aaa115..e8bfb7ccc 100644 --- a/app/assets/stylesheets/repository_columns/stock_type.scss +++ b/app/assets/stylesheets/repository_columns/stock_type.scss @@ -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; + } + } } } diff --git a/app/views/repository_columns/_manage_column_modal_content.html.erb b/app/views/repository_columns/_manage_column_modal_content.html.erb index 5ceb1adcb..0deb20dc9 100644 --- a/app/views/repository_columns/_manage_column_modal_content.html.erb +++ b/app/views/repository_columns/_manage_column_modal_content.html.erb @@ -22,11 +22,13 @@ <%= t('libraries.manange_modal_column.name') %>