mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 07:26:15 +08:00
Prevent create empty dropdown in inventories
This commit is contained in:
parent
bf1fac0b10
commit
b2580c1704
|
@ -506,7 +506,7 @@ var dropdownSelector = (function() {
|
||||||
container.find('.dropdown-group, .dropdown-option, .empty-dropdown, .delimiter').remove();
|
container.find('.dropdown-group, .dropdown-option, .empty-dropdown, .delimiter').remove();
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
||||||
if (data.length > 0) {
|
if (data.length > 0 && !(data.length === 1 && data[0].value === '')) {
|
||||||
// If we use select-by-group option we need first draw groups
|
// If we use select-by-group option we need first draw groups
|
||||||
if (selector.data('select-by-group')) {
|
if (selector.data('select-by-group')) {
|
||||||
$.each(data, function(gi, group) {
|
$.each(data, function(gi, group) {
|
||||||
|
@ -741,14 +741,14 @@ var dropdownSelector = (function() {
|
||||||
ajaxParams = customParams ? customParams(defaultParams) : defaultParams;
|
ajaxParams = customParams ? customParams(defaultParams) : defaultParams;
|
||||||
|
|
||||||
$.get(selector.data('ajax-url'), ajaxParams, (data) => {
|
$.get(selector.data('ajax-url'), ajaxParams, (data) => {
|
||||||
var optionsAjax = data;
|
var optionsAjax = data.constructor === Array ? data : [];
|
||||||
if (selector.data('config').emptyOptionAjax) {
|
if (selector.data('config').emptyOptionAjax) {
|
||||||
optionsAjax = [{
|
optionsAjax = [{
|
||||||
label: '',
|
label: selector.data('placeholder') || '',
|
||||||
value: '',
|
value: '',
|
||||||
group: null,
|
group: null,
|
||||||
params: {}
|
params: {}
|
||||||
}].concat(data);
|
}].concat(optionsAjax);
|
||||||
}
|
}
|
||||||
loadData(selector, container, optionsAjax);
|
loadData(selector, container, optionsAjax);
|
||||||
PerfectSb().update_all();
|
PerfectSb().update_all();
|
||||||
|
|
|
@ -163,9 +163,14 @@
|
||||||
background: $color-concrete;
|
background: $color-concrete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&[data-value=""] {
|
||||||
|
opacity: .7;
|
||||||
|
}
|
||||||
|
|
||||||
&.select {
|
&.select {
|
||||||
background: $brand-primary;
|
background: $brand-primary;
|
||||||
color: $color-white;
|
color: $color-white;
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -267,6 +272,10 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
|
&[data-ds-tag-id=""] {
|
||||||
|
opacity: .7;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.fa-times {
|
.fa-times {
|
||||||
|
|
|
@ -27,6 +27,9 @@ class RepositoryColumn < ApplicationRecord
|
||||||
uniqueness: { scope: :repository_id, case_sensitive: true }
|
uniqueness: { scope: :repository_id, case_sensitive: true }
|
||||||
validates :name, :data_type, :repository, :created_by, presence: true
|
validates :name, :data_type, :repository, :created_by, presence: true
|
||||||
|
|
||||||
|
validates :repository_list_items, presence: { if: proc { |collumn| collumn.data_type == 'RepositoryListValue' } }
|
||||||
|
validates :repository_status_items, presence: { if: proc { |collumn| collumn.data_type == 'RepositoryStatusValue' } }
|
||||||
|
|
||||||
after_create :update_repository_table_states_with_new_column
|
after_create :update_repository_table_states_with_new_column
|
||||||
around_destroy :update_repository_table_states_with_removed_column
|
around_destroy :update_repository_table_states_with_removed_column
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<%= text_area_tag 'items-textarea', column.repository_list_items.pluck(:data).join(selected_delimiter_char), rows: 10, class: 'form-control items-textarea' %>
|
<%= text_area_tag 'items-textarea', column.repository_list_items.pluck(:data).join(selected_delimiter_char), rows: 10, class: 'form-control items-textarea', name: "repository_column[repository_list_items]" %>
|
||||||
<% unless column.new_record? %>
|
<% unless column.new_record? %>
|
||||||
<div class="bg-danger hidden changing-existing-list-items-warning">
|
<div class="bg-danger hidden changing-existing-list-items-warning">
|
||||||
<%= t('libraries.manange_modal_column.change_multi_select_items_warning') %>
|
<%= t('libraries.manange_modal_column.change_multi_select_items_warning') %>
|
||||||
|
|
Loading…
Reference in a new issue