Skip to content

Commit 2d7aa81

Browse files
made changes on all the tables for consistency
1 parent c170afe commit 2d7aa81

File tree

1 file changed

+39
-102
lines changed

1 file changed

+39
-102
lines changed

sde_indexing_helper/static/js/delta_url_list.js

Lines changed: 39 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,10 @@ function initializeDataTable() {
578578
$("#exclude-patterns-dropdown-1").prop("disabled", true);
579579
} else if (index === 1) {
580580
$("#exclude-patterns-dropdown-1").on("change", function () {
581-
if ($(this).val() === "") table.columns(6).search("").draw();
581+
if ($(this).val() === "") table.columns(7).search("").draw();
582582
else {
583-
table
584-
.column(6)
585-
.search(matchPatternTypeMap[$(this).val()])
586-
.draw();
583+
const patternType = matchPatternTypeMap[$(this).val()];
584+
table.column(7).search(patternType).draw();
587585
}
588586
});
589587
}
@@ -621,7 +619,7 @@ function initializeDataTable() {
621619
},
622620
},
623621
{ data: "id", visible: false, searchable: false },
624-
{ data: "match_pattern_type", visible: false },
622+
{ data: "match_pattern_type", visible: false, searchable: true },
625623
],
626624
});
627625

@@ -671,11 +669,11 @@ function initializeDataTable() {
671669
} else {
672670
if (index === 1) {
673671
$("#include-patterns-dropdown-1").on("change", function () {
674-
if ($(this).val() === "") table.columns(5).search("").draw();
675-
table
676-
.column(5)
677-
.search(matchPatternTypeMap[$(this).val()])
678-
.draw();
672+
if ($(this).val() === "") table.columns(6).search("").draw();
673+
else {
674+
const patternType = matchPatternTypeMap[$(this).val()];
675+
table.column(6).search(patternType).draw();
676+
}
679677
});
680678
}
681679
}
@@ -707,7 +705,7 @@ function initializeDataTable() {
707705
},
708706
},
709707
{ data: "id", visible: false, searchable: false },
710-
{ data: "match_pattern_type", visible: false },
708+
{ data: "match_pattern_type", visible: false, searchable: true },
711709
],
712710
});
713711

@@ -831,53 +829,19 @@ function initializeDataTable() {
831829
pageLength: 100,
832830
ajax: `/api/document-type-patterns/?format=datatables&collection_id=${collection_id}`,
833831
initComplete: function (data) {
834-
this.api()
835-
.columns()
836-
.every(function (index) {
837-
var table = $("#document_type_patterns_table").DataTable();
838-
839-
let addDropdownSelect = {
840-
1: {
841-
columnToSearch: 6,
842-
matchPattern: {
843-
"Individual URL Pattern": 1,
844-
"Multi-URL Pattern": 2,
845-
},
846-
},
847-
2: {
848-
columnToSearch: 7,
849-
matchPattern: {
850-
Images: 1,
851-
Data: 2,
852-
Documentation: 3,
853-
"Software and Tools": 4,
854-
"Missions and Instruments": 5,
855-
},
856-
},
857-
};
858-
859-
let column = this;
860-
if (column.data().length === 0) {
861-
$(`#document-type-patterns-dropdown-${index}`).prop(
862-
"disabled",
863-
true
864-
);
865-
} else if (index in addDropdownSelect) {
866-
$("#document-type-patterns-dropdown-" + index).on(
867-
"change",
868-
function () {
869-
let col = addDropdownSelect[index].columnToSearch;
870-
let searchInput =
871-
addDropdownSelect[index].matchPattern[$(this).val()];
872-
if ($(this).val() === "" || $(this).val() === undefined)
873-
table.columns(col).search("").draw();
874-
else {
875-
table.columns(col).search(searchInput).draw();
876-
}
877-
}
878-
);
879-
}
880-
});
832+
var table = $("#document_type_patterns_table").DataTable();
833+
this.api().columns().every(function (index) {
834+
if (index === 1) {
835+
$("#document-type-patterns-dropdown-1").on("change", function () {
836+
if ($(this).val() === "") {
837+
table.column(7).search("").draw();
838+
} else {
839+
const patternType = matchPatternTypeMap[$(this).val()];
840+
table.column(7).search(patternType).draw();
841+
}
842+
});
843+
}
844+
});
881845
},
882846

883847
columns: [
@@ -907,7 +871,7 @@ function initializeDataTable() {
907871
},
908872
},
909873
{ data: "id", visible: false, searchable: false },
910-
{ data: "match_pattern_type", visible: false },
874+
{ data: "match_pattern_type", visible: false, searchable: true },
911875
{ data: "document_type", visible: false },
912876
],
913877
});
@@ -943,47 +907,20 @@ var division_patterns_table = $("#division_patterns_table").DataTable({
943907
pageLength: 100,
944908
ajax: `/api/division-patterns/?format=datatables&collection_id=${collection_id}`,
945909
initComplete: function (data) {
946-
this.api()
947-
.columns()
948-
.every(function (index) {
949-
var table = $("#division_patterns_table").DataTable();
950-
951-
let addDropdownSelect = {
952-
1: {
953-
columnToSearch: 6,
954-
matchPattern: {
955-
"Individual URL Pattern": 1,
956-
"Multi-URL Pattern": 2,
957-
},
958-
},
959-
2: {
960-
columnToSearch: 7,
961-
matchPattern: {
962-
"Astrophysics": 1,
963-
"Biological and Physical Sciences": 2,
964-
"Earth Science": 3,
965-
"Heliophysics": 4,
966-
"Planetary Science": 5,
967-
},
968-
},
969-
};
970-
971-
let column = this;
972-
if (column.data().length === 0) {
973-
$(`#division-patterns-dropdown-${index}`).prop("disabled", true);
974-
} else if (index in addDropdownSelect) {
975-
$("#division-patterns-dropdown-" + index).on("change", function () {
976-
let col = addDropdownSelect[index].columnToSearch;
977-
let searchInput =
978-
addDropdownSelect[index].matchPattern[$(this).val()];
979-
if ($(this).val() === "" || $(this).val() === undefined)
980-
table.columns(col).search("").draw();
981-
else {
982-
table.columns(col).search(searchInput).draw();
983-
}
984-
});
985-
}
986-
});
910+
var table = $("#division_patterns_table").DataTable();
911+
this.api().columns().every(function (index) {
912+
if (index === 1) {
913+
// Updated pattern type dropdown handler
914+
$("#division-patterns-dropdown-1").on("change", function () {
915+
if ($(this).val() === "") {
916+
table.column(7).search("").draw();
917+
} else {
918+
const patternType = matchPatternTypeMap[$(this).val()];
919+
table.column(7).search(patternType).draw();
920+
}
921+
});
922+
}
923+
});
987924
},
988925

989926
columns: [
@@ -1013,7 +950,7 @@ var division_patterns_table = $("#division_patterns_table").DataTable({
1013950
},
1014951
},
1015952
{ data: "id", visible: false, searchable: false },
1016-
{ data: "match_pattern_type", visible: false },
953+
{ data: "match_pattern_type", visible: false, searchable: true },
1017954
{ data: "division", visible: false },
1018955
],
1019956
});

0 commit comments

Comments
 (0)