diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..75bf826
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "editor.tabSize": 2,
+ "editor.insertSpaces": true,
+}
\ No newline at end of file
diff --git a/src/clusternetwork.js b/src/clusternetwork.js
index b6e4cbc..8158843 100755
--- a/src/clusternetwork.js
+++ b/src/clusternetwork.js
@@ -1,14 +1,18 @@
var d3 = require("d3"),
_ = require("underscore"),
jsConvert = require("js-convert-case"),
- misc = require("./misc"),
- helpers = require("./helpers"),
- colorPicker = require("./colorPicker"),
- scatterPlot = require("./scatterplot"),
topojson = require("topojson"),
jsPanel = require("jspanel4").jsPanel,
autocomplete = require("autocomplete.js");
+var misc = require("./misc"),
+ helpers = require("./helpers"),
+ colorPicker = require("./colorPicker"),
+ scatterPlot = require("./scatterplot"),
+ utils = require("./utils"),
+ tables = require("./tables");
+
+
const _networkSubclusterSeparator = ".";
const _networkNewNodeMarker = "[+]";
var _networkGraphAttrbuteID = "patient_attribute_schema";
@@ -685,18 +689,6 @@ var hivtrace_cluster_network_graph = function (
return d;
};
- self.get_ui_element_selector_by_role = function (role, not_nested) {
- if (not_nested && !self.primary_graph) {
- return undefined;
- }
- return (
- (not_nested ? "" : "#" + self.ui_container_selector) +
- " [data-hivtrace-ui-role='" +
- role +
- "']"
- );
- };
-
if (json.Settings && json.Settings.created) {
self.today = new Date(json.Settings.created);
} else {
@@ -882,7 +874,7 @@ var hivtrace_cluster_network_graph = function (
"#" + clicked_object.attr("aria-describedby")
);
var list_element = popover_div.selectAll(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"priority-membership-list",
true
)
@@ -1327,7 +1319,7 @@ var hivtrace_cluster_network_graph = function (
self.display_warning(self.warning_string, true);
}
- let tab_pill = self.get_ui_element_selector_by_role(
+ let tab_pill = utils.get_ui_element_selector_by_role(
"priority_set_counts",
true
);
@@ -2415,13 +2407,13 @@ var hivtrace_cluster_network_graph = function (
"#" + clicked_object.attr("aria-describedby")
);
var textarea_element = popover_div.selectAll(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"priority-description-form",
true
)
);
var button_element = popover_div.selectAll(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"priority-description-save",
true
)
@@ -2434,7 +2426,7 @@ var hivtrace_cluster_network_graph = function (
this_button.click();
});
button_element = popover_div.selectAll(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"priority-description-dismiss",
true
)
@@ -2739,7 +2731,7 @@ var hivtrace_cluster_network_graph = function (
(k) =>
$(
d3
- .select(self.get_ui_element_selector_by_role(k, true))
+ .select(utils.get_ui_element_selector_by_role(k, true))
.node()
).val()
);
@@ -2813,7 +2805,7 @@ var hivtrace_cluster_network_graph = function (
panel_object.close();
if (validation_mode == "validate") {
if (self.priority_set_table_writeable) {
- let tab_pill = self.get_ui_element_selector_by_role(
+ let tab_pill = utils.get_ui_element_selector_by_role(
"priority_set_counts",
true
),
@@ -2827,7 +2819,7 @@ var hivtrace_cluster_network_graph = function (
panel_object.first_save = false;
}
let panel_to_focus = document.querySelector(
- self.get_ui_element_selector_by_role("priority-panel-name", true)
+ utils.get_ui_element_selector_by_role("priority-panel-name", true)
);
if (panel_to_focus) panel_to_focus.focus();
return res;
@@ -2905,7 +2897,7 @@ var hivtrace_cluster_network_graph = function (
}
var auto_object = autocomplete(
- self.get_ui_element_selector_by_role("priority-panel-nodeids", true),
+ utils.get_ui_element_selector_by_role("priority-panel-nodeids", true),
{ hint: false },
[
{
@@ -3344,7 +3336,7 @@ var hivtrace_cluster_network_graph = function (
};
if (self._is_CDC_ && self.primary_graph) {
- let new_set = self.get_ui_element_selector_by_role(
+ let new_set = utils.get_ui_element_selector_by_role(
"new_priority_set",
true
);
@@ -3364,7 +3356,7 @@ var hivtrace_cluster_network_graph = function (
});
}
- let merge_sets = self.get_ui_element_selector_by_role(
+ let merge_sets = utils.get_ui_element_selector_by_role(
"merge_priority_sets",
true
);
@@ -3372,7 +3364,7 @@ var hivtrace_cluster_network_graph = function (
if (merge_sets) {
d3.selectAll(merge_sets).on("click", function (e) {
$(
- self.get_ui_element_selector_by_role("priority_set_merge", true)
+ utils.get_ui_element_selector_by_role("priority_set_merge", true)
).modal();
});
}
@@ -5688,7 +5680,7 @@ var hivtrace_cluster_network_graph = function (
}
d3.select(
- self.get_ui_element_selector_by_role("cluster_list_data_export", true)
+ utils.get_ui_element_selector_by_role("cluster_list_data_export", true)
).on("click", function (d) {
if (self._is_CDC_executive_mode) {
alert(_networkWarnExecutiveMode);
@@ -5744,7 +5736,7 @@ var hivtrace_cluster_network_graph = function (
self._setup_cluster_list_view = function () {
d3.select(
- self.get_ui_element_selector_by_role("cluster_list_view_toggle", true)
+ utils.get_ui_element_selector_by_role("cluster_list_view_toggle", true)
).on("click", function () {
d3.event.preventDefault();
var group_by_id = false;
@@ -5766,13 +5758,13 @@ var hivtrace_cluster_network_graph = function (
cluster_id ? cluster_id.toString() : "",
!group_by_id,
d3.select(
- self.get_ui_element_selector_by_role("cluster_list_payload", true)
+ utils.get_ui_element_selector_by_role("cluster_list_payload", true)
),
button_clicked.data("priority_list")
);
});
- $(self.get_ui_element_selector_by_role("cluster_list", true)).on(
+ $(utils.get_ui_element_selector_by_role("cluster_list", true)).on(
"show.bs.modal",
function (event) {
var link_clicked = $(event.relatedTarget);
@@ -5780,7 +5772,7 @@ var hivtrace_cluster_network_graph = function (
var priority_list = link_clicked.data("priority_set");
var modal = d3.select(
- self.get_ui_element_selector_by_role("cluster_list", true)
+ utils.get_ui_element_selector_by_role("cluster_list", true)
);
modal
.selectAll(".modal-title")
@@ -5792,7 +5784,7 @@ var hivtrace_cluster_network_graph = function (
);
var view_toggle = $(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"cluster_list_view_toggle",
true
)
@@ -5810,27 +5802,27 @@ var hivtrace_cluster_network_graph = function (
cluster_id,
//cluster_id,
$(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"cluster_list_view_toggle",
true
)
).data(__("clusters_tab")["view"]) != "id",
modal.select(
- self.get_ui_element_selector_by_role("cluster_list_payload", true)
+ utils.get_ui_element_selector_by_role("cluster_list_payload", true)
),
priority_list
);
}
);
- $(self.get_ui_element_selector_by_role("overlap_list", true)).on(
+ $(utils.get_ui_element_selector_by_role("overlap_list", true)).on(
"show.bs.modal",
function (event) {
var link_clicked = $(event.relatedTarget);
var priority_list = link_clicked.data("priority_set");
var modal = d3.select(
- self.get_ui_element_selector_by_role("overlap_list", true)
+ utils.get_ui_element_selector_by_role("overlap_list", true)
);
modal
.selectAll(".modal-title")
@@ -5875,7 +5867,7 @@ var hivtrace_cluster_network_graph = function (
});
d3.select(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"overlap_list_data_export",
true
)
@@ -5883,9 +5875,9 @@ var hivtrace_cluster_network_graph = function (
helpers.export_csv_button(rows_for_export, "overlap");
});
- add_a_sortable_table(
+ tables.add_a_sortable_table(
modal.select(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"overlap_list_data_table",
true
)
@@ -5893,23 +5885,24 @@ var hivtrace_cluster_network_graph = function (
headers,
rows,
true,
- null
+ null,
+ self.has_priority_set_editor()
);
}
);
};
- $(self.get_ui_element_selector_by_role("priority_set_merge", true)).on(
+ $(utils.get_ui_element_selector_by_role("priority_set_merge", true)).on(
"show.bs.modal",
function (event) {
var modal = d3.select(
- self.get_ui_element_selector_by_role("priority_set_merge", true)
+ utils.get_ui_element_selector_by_role("priority_set_merge", true)
);
let desc = modal.selectAll(".modal-desc");
let proceed_btn = d3.select(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"priority_set_merge_table_proceed",
true
)
@@ -6037,9 +6030,9 @@ var hivtrace_cluster_network_graph = function (
]);
});
- add_a_sortable_table(
+ tables.add_a_sortable_table(
modal.select(
- self.get_ui_element_selector_by_role(
+ utils.get_ui_element_selector_by_role(
"priority_set_merge_table",
true
)
@@ -6047,7 +6040,8 @@ var hivtrace_cluster_network_graph = function (
headers,
rows,
true,
- null
+ null,
+ self.has_priority_set_editor()
);
}
}
@@ -6057,7 +6051,7 @@ var hivtrace_cluster_network_graph = function (
self._setup_cluster_list_view();
var cluster_ui_container = d3.select(
- self.get_ui_element_selector_by_role("cluster_operations_container")
+ utils.get_ui_element_selector_by_role("cluster_operations_container")
);
cluster_ui_container.selectAll("li").remove();
@@ -6320,7 +6314,7 @@ var hivtrace_cluster_network_graph = function (
}, cluster_ui_container);
var button_group = d3.select(
- self.get_ui_element_selector_by_role("button_group")
+ utils.get_ui_element_selector_by_role("button_group")
);
if (!button_group.empty()) {
@@ -6387,7 +6381,7 @@ var hivtrace_cluster_network_graph = function (
}
var export_image = d3.select(
- self.get_ui_element_selector_by_role("export_image")
+ utils.get_ui_element_selector_by_role("export_image")
);
if (!export_image.empty()) {
@@ -6436,7 +6430,7 @@ var hivtrace_cluster_network_graph = function (
}
}
- $(self.get_ui_element_selector_by_role("filter"))
+ $(utils.get_ui_element_selector_by_role("filter"))
.off("input propertychange")
.on(
"input propertychange",
@@ -6446,7 +6440,7 @@ var hivtrace_cluster_network_graph = function (
}, 250)
);
- $(self.get_ui_element_selector_by_role("hide_filter"))
+ $(utils.get_ui_element_selector_by_role("hide_filter"))
.off("change")
.on(
"change",
@@ -6457,7 +6451,7 @@ var hivtrace_cluster_network_graph = function (
}, 250)
);
- $(self.get_ui_element_selector_by_role("show_small_clusters"))
+ $(utils.get_ui_element_selector_by_role("show_small_clusters"))
.off("change")
.on(
"change",
@@ -6472,7 +6466,7 @@ var hivtrace_cluster_network_graph = function (
}, 250)
);
- $(self.get_ui_element_selector_by_role("set_min_cluster_size"))
+ $(utils.get_ui_element_selector_by_role("set_min_cluster_size"))
.off("change")
.on(
"change",
@@ -6482,7 +6476,7 @@ var hivtrace_cluster_network_graph = function (
}, 250)
);
- $(self.get_ui_element_selector_by_role("pairwise_table_pecentage", true))
+ $(utils.get_ui_element_selector_by_role("pairwise_table_pecentage", true))
.off("change")
.on(
"change",
@@ -6557,11 +6551,11 @@ var hivtrace_cluster_network_graph = function (
try {
if (options && options["extra_menu"]) {
var extra_ui_container = d3.select(
- self.get_ui_element_selector_by_role("extra_operations_container")
+ utils.get_ui_element_selector_by_role("extra_operations_container")
);
d3.select(
- self.get_ui_element_selector_by_role("extra_operations_enclosure")
+ utils.get_ui_element_selector_by_role("extra_operations_enclosure")
)
.selectAll("button")
.text(options["extra_menu"]["title"])
@@ -6588,7 +6582,7 @@ var hivtrace_cluster_network_graph = function (
}, extra_ui_container);
d3.select(
- self.get_ui_element_selector_by_role("extra_operations_enclosure")
+ utils.get_ui_element_selector_by_role("extra_operations_enclosure")
).style("display", null);
}
} catch (err) {
@@ -6756,9 +6750,9 @@ var hivtrace_cluster_network_graph = function (
//valid_cats.splice (0,0, {'label' : 'None', 'index' : -1});
[
- d3.select(self.get_ui_element_selector_by_role("attributes")),
+ d3.select(utils.get_ui_element_selector_by_role("attributes")),
d3.select(
- self.get_ui_element_selector_by_role("attributes_cat", true)
+ utils.get_ui_element_selector_by_role("attributes_cat", true)
),
].forEach(function (m) {
//console.log (m);
@@ -6863,7 +6857,7 @@ var hivtrace_cluster_network_graph = function (
});
});
- [d3.select(self.get_ui_element_selector_by_role("shapes"))].forEach(
+ [d3.select(utils.get_ui_element_selector_by_role("shapes"))].forEach(
function (m) {
m.selectAll("li").remove();
var cat_menu = m.selectAll("li").data(
@@ -6938,7 +6932,7 @@ var hivtrace_cluster_network_graph = function (
}
);
- $(self.get_ui_element_selector_by_role("opacity_invert"))
+ $(utils.get_ui_element_selector_by_role("opacity_invert"))
.off("click")
.on("click", function (e) {
if (self.colorizer["opacity_scale"]) {
@@ -6951,7 +6945,7 @@ var hivtrace_cluster_network_graph = function (
$(this).toggleClass("btn-active btn-default");
});
- $(self.get_ui_element_selector_by_role("attributes_invert"))
+ $(utils.get_ui_element_selector_by_role("attributes_invert"))
.off("click")
.on("click", function (e) {
if (self.colorizer["category_id"]) {
@@ -6976,7 +6970,7 @@ var hivtrace_cluster_network_graph = function (
$(this).toggleClass("btn-active btn-default");
});
- [d3.select(self.get_ui_element_selector_by_role("opacity"))].forEach(
+ [d3.select(utils.get_ui_element_selector_by_role("opacity"))].forEach(
function (m) {
m.selectAll("li").remove();
var cat_menu = m.selectAll("li").data(
@@ -7178,22 +7172,6 @@ var hivtrace_cluster_network_graph = function (
self.update();
}
- function sort_table_toggle_icon(element, value) {
- //console.log (value);
- if (value) {
- $(element).data("sorted", value);
- d3.select(element)
- .selectAll("i")
- .classed("fa-sort-amount-desc", value == "desc")
- .classed("fa-sort-amount-asc", value == "asc")
- .classed("fa-sort", value == "unsorted");
- } else {
- var sorted_state = $(element).data("sorted");
- sort_table_toggle_icon(element, sorted_state == "asc" ? "desc" : "asc");
- return sorted_state == "asc" ? d3.descending : d3.ascending;
- }
- }
-
/** element is the sortable clicker **/
function filter_table_by_column_handler(datum, conditions) {
@@ -7274,7 +7252,7 @@ var hivtrace_cluster_network_graph = function (
});
d3.select(table_element[0])
.select("caption")
- .select(self.get_ui_element_selector_by_role("table-count-shown", true))
+ .select(utils.get_ui_element_selector_by_role("table-count-shown", true))
.text(shown_rows);
/*.selectAll("td").each (function (d, i) {
@@ -7297,437 +7275,6 @@ var hivtrace_cluster_network_graph = function (
}
}
- /** element is the sortable clicker **/
- function sort_table_by_column(element, datum) {
- if (d3.event) {
- d3.event.preventDefault();
- }
- var table_element = $(element).closest("table");
- if (table_element.length) {
- var sort_on = parseInt($(element).data("column-id"));
- var sort_key = datum.sort;
-
- var sorted_state = $(element).data("sorted");
- var sorted_function = sort_table_toggle_icon(element);
-
- var sort_accessor;
-
- if (sort_key) {
- if (_.isFunction(sort_key)) {
- sort_accessor = function (x) {
- return sort_key(x);
- };
- } else {
- sort_accessor = function (x) {
- var val = x[sort_key];
- if (_.isFunction(val)) return val();
- return val;
- };
- }
- } else {
- sort_accessor = function (x) {
- return x;
- };
- }
-
- d3.select(table_element[0])
- .select("tbody")
- .selectAll("tr")
- .sort(function (a, b) {
- return sorted_function(
- sort_accessor(a[sort_on]),
- sort_accessor(b[sort_on])
- );
- });
-
- // select all other elements from thead and toggle their icons
-
- $(table_element)
- .find("thead [data-column-id]")
- .filter(function () {
- return parseInt($(this).data("column-id")) != sort_on;
- })
- .each(function () {
- sort_table_toggle_icon(this, "unsorted");
- });
- }
- }
-
- function table_get_cell_value(data) {
- return _.isFunction(data.value) ? data.value() : data.value;
- }
-
- function format_a_cell(data, index, item) {
- var this_sel = d3.select(item);
- var current_value = table_get_cell_value(data);
- var handle_sort = this_sel;
-
- handle_sort.selectAll("*").remove();
-
- if ("callback" in data) {
- handle_sort = data.callback(item, current_value);
- } else {
- var repr = "format" in data ? data.format(current_value) : current_value;
- if ("html" in data && data.html) this_sel.html(repr);
- else this_sel.text(repr);
- }
-
- if ("filter" in data) {
- data.filter_term = "";
- data.column_id = index;
-
- if (data.value == _networkNodeIDField) {
- // this is an ugly hardcode.
- let pse = self.has_priority_set_editor();
- if (pse) {
- //console.log ("Here");
- var add_to_ps = handle_sort.append("a").property("href", "#");
- add_to_ps
- .append("i")
- .classed("fa fa-plus-square fa-lg", true)
- .style("margin-left", "0.2em")
- .attr(
- "title",
- "Add currently visible nodes to the Cluster of Interest"
- );
-
- add_to_ps.on("click", function (d) {
- let node_ids = [];
- self.node_table.selectAll("tr").each(function (d, i) {
- let this_row = d3.select(this);
- if (this_row.style("display") != "none") {
- this_row.selectAll("td").each(function (d, j) {
- if (j == data.column_id) {
- let has_marker = d.value.indexOf(_networkNewNodeMarker);
- if (has_marker > 0) {
- node_ids.push(d.value.substring(0, has_marker));
- } else {
- node_ids.push(d.value);
- }
- }
- });
- }
- });
- pse.append_nodes(node_ids);
- });
- }
- }
-
- var clicker = handle_sort.append("a").property("href", "#");
-
- clicker
- .append("i")
- .classed("fa fa-search", true)
- .style("margin-left", "0.2em");
-
- var search_form_generator = function () {
- return (
- '
\
-
\
-
\
- Type in text to select columns which \
- contain the term. \
- For example, typing in MSM will select rows\
- that have "MSM" as a part of the column value.\
- \
- Type in space separated terms (MSM IDU) to\
- search for either term. \
- Type in terms in quotes ("male") to search\
- for this exact term. \
- If columns have date information you can use\
- YYYYMMDD:YYYYMMDD to search for date ranges.\
- Use <value or >value\
- to search numerical columns\
-
\
+ Type in text to select columns which \
+ contain the term. \
+ For example, typing in MSM will select rows\
+ that have "MSM" as a part of the column value.\
+ \
+ Type in space separated terms (MSM IDU) to\
+ search for either term. \
+ Type in terms in quotes ("male") to search\
+ for this exact term. \
+ If columns have date information you can use\
+ YYYYMMDD:YYYYMMDD to search for date ranges.\
+ Use <value or >value\
+ to search numerical columns\
+