Skip to content

Commit

Permalink
Merge solgenomics/master into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mlm483 committed Dec 15, 2023
2 parents 40a9d2c + 1de9975 commit 02c663b
Show file tree
Hide file tree
Showing 48 changed files with 2,813 additions and 1,613 deletions.
138 changes: 31 additions & 107 deletions js/source/entries/fieldmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,96 +148,20 @@ export function init() {
}
}

traverse_map(plot_arr, planting_or_harvesting_order_layout) {
var local_this = this;
let coord_matrix = [];
var row = this.meta_data[planting_or_harvesting_order_layout].includes('row') ? "positionCoordinateY" : "positionCoordinateX";
var col = this.meta_data[planting_or_harvesting_order_layout].includes('row') ? "positionCoordinateX" : "positionCoordinateY";

for (let plot of plot_arr) {
if (!coord_matrix[plot.observationUnitPosition[row]]) {
coord_matrix[plot.observationUnitPosition[row]] = [];
coord_matrix[plot.observationUnitPosition[row]][plot.observationUnitPosition[col]] = plot;
} else {
coord_matrix[plot.observationUnitPosition[row]][plot.observationUnitPosition[col]] = plot;
}
}

coord_matrix = coord_matrix.filter(plot_arr => Array.isArray(plot_arr));
if (!document.getElementById("invert_row_checkmark").checked && this.meta_data[planting_or_harvesting_order_layout].includes('row') && planting_or_harvesting_order_layout.includes('planting')) {
if ((this.meta_data.top_border_selection && !this.meta_data.bottom_border_selection) || (!this.meta_data.top_border_selection && this.meta_data.bottom_border_selection)) {
if (this.meta_data.top_border_selection) {
var top_borders = coord_matrix.shift();
coord_matrix.push(top_borders);
} else if (this.meta_data.bottom_border_selection) {
var bottom_borders = coord_matrix.pop();
coord_matrix.unshift(bottom_borders);
}
}
}


if (this.meta_data[planting_or_harvesting_order_layout].includes('serpentine')) {
for (let i = 0; i < coord_matrix.length; i++) {
if (i % 2 == 1) {
coord_matrix[i].reverse();
}
}
}

var final_arr = [];
for (let plot_arr of coord_matrix) {
plot_arr = plot_arr.filter(plot => plot !== undefined);
if (!document.getElementById("invert_row_checkmark").checked && local_this.meta_data[planting_or_harvesting_order_layout].includes('col') && planting_or_harvesting_order_layout.includes('planting')) {
if ((local_this.meta_data.top_border_selection && !local_this.meta_data.bottom_border_selection) || (!local_this.meta_data.top_border_selection && local_this.meta_data.bottom_border_selection)) {
if (local_this.meta_data.top_border_selection) {
var top_border_plot = plot_arr.shift();
plot_arr.push(top_border_plot);
} else if (local_this.meta_data.bottom_border_selection) {
var bottom_border_plot = plot_arr.pop();
plot_arr.unshift(bottom_border_plot);
}
}
}
final_arr.push(...plot_arr);
}

var csv = [
planting_or_harvesting_order_layout == "planting_order_layout" ? 'planting_order': "harvesting_order",
'location_name',
'trial_name',
'plot_number',
'plot_name',
'accession_name',
'seedlot_name',
].join(',');
csv += "\n";
final_arr = final_arr.filter(plot => plot !== undefined);
let order_number = 1;
final_arr.forEach(function(plot) {
csv += [
order_number++,
"\"" + plot.locationName + "\"",
plot.studyName,
plot.observationUnitPosition.observationLevel ? plot.observationUnitPosition.observationLevel.levelCode : "N/A",
plot.observationUnitName,
plot.germplasmName,
plot.seedLotName ? plot.seedLotName : ''
].join(',');
csv += "\n";
});

var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
hiddenElement.target = '_blank';
hiddenElement.download = `Trial_${this.trial_id}_${this.meta_data[planting_or_harvesting_order_layout]}_${planting_or_harvesting_order_layout}.csv`;
hiddenElement.click();
}

get_plot_order(type, order, include_borders) {
let k = type === 'planting' ? 'planting_order_layout' : 'harvesting_order_layout';
this.meta_data[k] = order;
this.traverse_map(this.plot_arr.filter(plot => include_borders || plot.type !== "border"), k);
get_plot_order(type, order, start, include_borders, include_gaps, additional_properties) {
let q = new URLSearchParams({
'trial_ids': [this.trial_id, ...Object.keys(this.linked_trials).map((e) => this.linked_trials[e].id)].join(','),
'type': type,
'order': order,
'start': start,
'top_border': !!include_borders && !!this.meta_data.top_border_selection,
'right_border': !!include_borders && !!this.meta_data.right_border_selection,
'bottom_border': !!include_borders && !!this.meta_data.bottom_border_selection,
'left_border': !!include_borders && !!this.meta_data.left_border_selection,
'gaps': !!include_gaps,
...additional_properties
}).toString();
window.open(`/ajax/breeders/trial_plot_order?${q}`, '_blank');
}

set_meta_data() {
Expand Down Expand Up @@ -419,14 +343,14 @@ export function init() {
this.meta_data.num_cols = this.meta_data.num_rows;
this.meta_data.num_rows = tempNumCols;

d3.select("svg").remove();
d3v3.select("svg").remove();
this.add_borders();
this.render();

}

clickcancel() {
var event = d3.dispatch('click', 'dblclick');
var event = d3v3.dispatch('click', 'dblclick');
function cc(selection) {
var down,
tolerance = 5,
Expand All @@ -436,33 +360,33 @@ export function init() {
return Math.sqrt(Math.pow(a[0] - b[0], 2), Math.pow(a[1] - b[1], 2));
}
selection.on('mousedown', function() {
down = d3.mouse(document.body);
down = d3v3.mouse(document.body);
last = +new Date();
});
selection.on('mouseup', function() {
if (dist(down, d3.mouse(document.body)) > tolerance) {
if (dist(down, d3v3.mouse(document.body)) > tolerance) {
return;
} else {
if (wait) {
window.clearTimeout(wait);
wait = null;
event.dblclick(d3.event);
event.dblclick(d3v3.event);
} else {
wait = window.setTimeout((function(e) {
return function() {
event.click(e);
wait = null;
};
})(d3.event), 300);
})(d3v3.event), 300);
}
}
});
};
return d3.rebind(cc, event, 'on');
return d3v3.rebind(cc, event, 'on');
}

heatmap_plot_click(plot, heatmap_object, trait_name) {
if (d3.event && d3.event.detail > 1) {
if (d3v3.event && d3v3.event.detail > 1) {
return;
} else if (trait_name in heatmap_object && heatmap_object[trait_name][plot.observationUnitDbId]) {
let val, plot_name, pheno_id;
Expand All @@ -478,7 +402,7 @@ export function init() {
}

fieldmap_plot_click(plot) {
if (d3.event && d3.event.detail > 1) {
if (d3v3.event && d3v3.event.detail > 1) {
return;
} else {
function btnClick(n){
Expand Down Expand Up @@ -559,7 +483,7 @@ export function init() {
for (let obs_unit of Object.values(plots_with_selected_trait)) {
trait_vals.push(obs_unit.val);
}
var colorScale = d3.scale.quantile()
var colorScale = d3v3.scale.quantile()
.domain(trait_vals)
.range(colors);
}
Expand Down Expand Up @@ -648,7 +572,7 @@ export function init() {

var handle_mouseover = function(d) {
if (d.observationUnitPosition.observationLevel) {
d3.select(`#fieldmap-plot-${d.observationUnitDbId}`)
d3v3.select(`#fieldmap-plot-${d.observationUnitDbId}`)
.style('fill', 'green')
.style('cursor', 'pointer')
.style("stroke-width", 3)
Expand All @@ -661,7 +585,7 @@ export function init() {
}

var handle_mouseout = function(d) {
d3.select(`#fieldmap-plot-${d.observationUnitDbId}`)
d3v3.select(`#fieldmap-plot-${d.observationUnitDbId}`)
.style('fill', !isHeatMap ? get_fieldmap_plot_color(d) : get_heatmap_plot_color(d))
.style('cursor', 'default')
.style("stroke-width", 2)
Expand Down Expand Up @@ -734,12 +658,12 @@ export function init() {
var num_rows = this.meta_data.num_rows;
var isHeatMap = this.heatmap_selected;

var grid = d3.select("#fieldmap_chart")
var grid = d3v3.select("#fieldmap_chart")
.append("svg")
.attr("width", width * 50 + 20 + "px")
.attr("height", height * 50 + 20 + "px")

var tooltip = d3.select("#fieldmap_chart")
var tooltip = d3v3.select("#fieldmap_chart")
.append("rect")
.attr("id", "tooltip")
.attr("class", "tooltip")
Expand All @@ -764,11 +688,11 @@ export function init() {
.call(cc);

cc.on("click", (el) => {
var plot = d3.select(el.srcElement).data()[0];
var plot = d3v3.select(el.srcElement).data()[0];
plot_click(plot, heatmap_object, trait_name)
});
cc.on("dblclick", (el) => {
var me = d3.select(el.srcElement);
var me = d3v3.select(el.srcElement);
var d = me.data()[0];
if (d.observationUnitDbId) {
window.open('/stock/'+d.observationUnitDbId+'/view');
Expand Down Expand Up @@ -861,7 +785,7 @@ export function init() {


load() {
d3.select("svg").remove();
d3v3.select("svg").remove();
this.change_dimensions(this.meta_data.num_cols, this.meta_data.num_rows);
this.add_borders();
this.render();
Expand Down
2 changes: 1 addition & 1 deletion js/source/legacy/d3/d3Min.js

Large diffs are not rendered by default.

41 changes: 31 additions & 10 deletions js/source/legacy/tools/LabelDesigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,27 +307,23 @@ $(document).ready(function($) {
});

$('#design_label_button').click(function() {
$("#d3-draw-area").prependTo("#save_and_download");
});

$('#design_label_button').click(function() {
$("#d3-draw-area").prependTo("#save_and_download");
$("#d3-draw-area").prependTo("#save-labels-display");
$(".workflow-complete").click(function() {
var title = $(this).children().text();
//console.log("workflow element with title "+title+" was just clicked\n");

if (title == "Design Your Label") {
$("#d3-draw-area").prependTo("#d3-draw-div");
} else if (title == "More Options, Save, And Download") {
$("#d3-draw-area").prependTo("#save_and_download");
$("#d3-draw-area").prependTo("#save-labels-display");
}

});
$("ol.workflow-prog li").click(function() {
var title = $(this).children().text();
//console.log("workflow element with title "+title+" was just clicked\n");
if (title == "More Options, Save, And Download") {
$("#d3-draw-area").prependTo("#save_and_download");
$("#d3-draw-area").prependTo("#save-labels-display");
}

});
Expand Down Expand Up @@ -704,7 +700,7 @@ function updateFields(data_type, source_id, data_level){
reps = response.reps;
num_units = response.num_units;
addPlotFilter(reps);
addSortOrders(add_fields);
addSortOrders(add_fields, data_type, data_level);
createAdders(add_fields);
initializeCustomModal(add_fields);
showLoadOption();
Expand Down Expand Up @@ -1299,10 +1295,27 @@ function addPlotFilter(reps) {

}

function addSortOrders(add_fields) {
function addSortOrders(add_fields, data_type, data_level) {

// Set type-specific sorting options
let data_type_fields = [];
// Sort by trial layout for plot-level labels...
if ( ['Field Trials', 'Lists', 'Public Lists'].includes(data_type) && data_level === 'plots' ) {
data_type_fields = ['Trial Layout: Plot Order'];
}

//load options
d3.selectAll("#sort_order_1, #sort_order_2, #sort_order_3").selectAll("option").remove();
d3.selectAll("#sort_order_1, #sort_order_2, #sort_order_3").selectAll("option")
d3.selectAll("#sort_order_1").selectAll("option")
.data(["Select a field", ...data_type_fields, ...Object.keys(add_fields).sort()])
.enter().append("option")
.text(function(d) {
return d
})
.attr("value", function(d) {
return d
});
d3.selectAll("#sort_order_2, #sort_order_3").selectAll("option")
.data(["Select a field", ...Object.keys(add_fields).sort()])
.enter().append("option")
.text(function(d) {
Expand All @@ -1315,9 +1328,15 @@ function addSortOrders(add_fields) {
const sel = jQuery("#sort_order_1").val();
if ( sel === 'Select a field' ) {
jQuery("#sort_order_2_container, #sort_order_3_container").hide();
jQuery("#sort_order_layout_order_container, #sort_order_layout_start_container").hide();
}
else if ( sel === 'Trial Layout: Plot Order' ) {
jQuery("#sort_order_2_container, #sort_order_3_container").hide();
jQuery("#sort_order_layout_order_container, #sort_order_layout_start_container").show();
}
else {
jQuery("#sort_order_2_container").show();
jQuery("#sort_order_layout_order_container, #sort_order_layout_start_container").hide();
}
});
jQuery("#sort_order_2").off("change").on("change", () => {
Expand Down Expand Up @@ -1419,6 +1438,8 @@ function retrievePageParams() {
sort_order_1: document.getElementById("sort_order_1").value,
sort_order_2: document.getElementById("sort_order_2").value,
sort_order_3: document.getElementById("sort_order_3").value,
sort_order_layout_order: document.getElementById("sort_order_layout_order").value,
sort_order_layout_start: document.getElementById("sort_order_layout_start").value,
copies_per_plot: document.getElementById("copies_per_plot").value,
labels_to_download: document.getElementById("label_designer_labels_to_download").value,
start_number: document.getElementById("label_designer_start_number").value,
Expand Down
2 changes: 1 addition & 1 deletion lib/CXGN/List.pm
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ sub exists_list {
my $name = shift;
my $owner = shift;

my $q = "SELECT list_id, cvterm.name FROM sgn_people.list AS list LEFT JOIN cvterm ON (type_id=cvterm_id) WHERE list.name = ? AND list.owner=?";
my $q = "SELECT list_id, cvterm.name FROM sgn_people.list AS list LEFT JOIN cvterm ON (type_id=cvterm_id) WHERE list.name=? AND (list.owner=? OR list.is_public=TRUE)";
my $h = $dbh->prepare($q);
$h->execute($name, $owner);
my ($list_id, $list_type) = $h->fetchrow_array();
Expand Down
Loading

0 comments on commit 02c663b

Please sign in to comment.