Skip to content

Commit a018a10

Browse files
committed
Fix same value error for tables to ignore empty strings
1 parent 8fbc813 commit a018a10

File tree

1 file changed

+10
-6
lines changed
  • ckanext/querytool/fanstatic/javascript

1 file changed

+10
-6
lines changed

ckanext/querytool/fanstatic/javascript/vitals.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,11 @@ function checkTableCat(selected,chart_number){
822822
$(`#table_second_value_${chart_number} option[value='`+ selected +`']`).attr('disabled','disabled').siblings().removeAttr('disabled');
823823
$(`#table_category_name_${chart_number} option[value='`+ selected +`']`).attr('disabled','disabled').siblings().removeAttr('disabled');
824824

825-
if($(`#table_second_value_${chart_number} option`).filter(":selected").val() == selected){
825+
if($(`#table_second_value_${chart_number} option`).filter(":selected").val() == selected && selected != ''){
826826
$($(`#table_second_value_${chart_number}`)).val("")
827827
}
828828

829-
if($(`#table_category_name_${chart_number} option`).filter(":selected").val() == selected){
829+
if($(`#table_category_name_${chart_number} option`).filter(":selected").val() == selected && selected != ''){
830830
$($(`#table_category_name_${chart_number}`)).val("")
831831
}
832832

@@ -836,13 +836,15 @@ function checkTableCat(selected,chart_number){
836836
$('body').on('change','[id^=table_second_value_]',function(e){
837837
var selected = $(this).val();
838838
var chart_number = this.id.split('_').slice(-1)[0];
839+
console.log(selected)
840+
console.log('SECOND VAL')
839841

840-
if($(`#table_main_value_${chart_number} option`).filter(":selected").val() == selected){
842+
if($(`#table_main_value_${chart_number} option`).filter(":selected").val() == selected && selected != ''){
841843
$($(`#table_second_value_${chart_number}`)).val("")
842844
alert('Value cannot be same as main dimension')
843845
}
844846

845-
if($(`#table_category_name_${chart_number} option`).filter(":selected").val() == selected){
847+
if($(`#table_category_name_${chart_number} option`).filter(":selected").val() == selected && selected != ''){
846848
$($(`#table_second_value_${chart_number}`)).val("")
847849
alert('Value cannot be same as category')
848850
}
@@ -852,13 +854,15 @@ $('body').on('change','[id^=table_second_value_]',function(e){
852854
$('body').on('change','[id^=table_category_name_]',function(e){
853855
var selected = $(this).val();
854856
var chart_number = this.id.split('_').slice(-1)[0];
857+
console.log(selected)
858+
console.log('CAT NAME')
855859

856-
if($(`#table_main_value_${chart_number} option`).filter(":selected").val() == selected){
860+
if($(`#table_main_value_${chart_number} option`).filter(":selected").val() == selected && selected != ''){
857861
$($(`#table_category_name_${chart_number}`)).val("")
858862
alert('Value cannot be same as main dimension')
859863
}
860864

861-
if($(`#table_second_value_${chart_number} option`).filter(":selected").val() == selected){
865+
if($(`#table_second_value_${chart_number} option`).filter(":selected").val() == selected && selected != ''){
862866
$($(`#table_category_name_${chart_number}`)).val("")
863867
alert('Value cannot be same as sub dimension')
864868
}

0 commit comments

Comments
 (0)