Skip to content

Commit

Permalink
clean code tagnav_init
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-TBT committed Dec 15, 2023
1 parent 6089b10 commit 4b54b32
Showing 1 changed file with 2 additions and 85 deletions.
87 changes: 2 additions & 85 deletions omero_tagsearch/templates/omero_tagsearch/tagnav_init.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,103 +2,20 @@
<script>

$(function() {

$("#tagnav_panel").omeroweb_center_plugin({
plugin_index: {{ forloop.counter }}, // since we're in a Django template loop
empty_on_sel_change: false, // Do not completely erase content when changing selection
load_plugin_content: function(selected, dtype, oid){

// this may have been called before datatree was initialised...
// var datatree = $.jstree._focused();
// if (!datatree) return;

// we use the tree to access selected objects, since we can traverse to check parents etc...
// var tree_selected = datatree.data.ui.selected;

//TODO if nothing selected, simply update selection
// var sel_objs = $("body").data("selected_objects.ome");
// if (sel_objs.length == 0) {
// if (force_update === true) {
// $("div#content_details").empty();
// $("div#content_details").removeAttr('rel');
// }
// return;
// }

// TODO Multiple selection
// if (selected.length > 1) {
// //TODO if any non-images are selected, clear the centre panel
// if (selected.filter('li:not([id|=image])').length > 0) {
// $("div#content_details").empty();
// $("div#content_details").removeAttr('rel');
// return;
// }
// }

// handle single object (or multi-image) selection...
// These are not used as the list of ids and the type are passed into this function
// var oid = selected.attr('id'); // E.g. 'dataset-501'
// var orel = selected.attr('rel').replace("-locked", ""); // E.g. 'dataset'

var standby_then_load = function() {
// Display waiting message
// Check if the Tag Navigation Page is already loaded
if (!$('#tagSearchForm').length) {
$("div#tagnav_panel").html('<p class="loading_center">Loading... please wait. <img src ="{% static "webgateway/img/spinner_big.gif" %}"/></p>');

// Get and load actual contents
tagnav_url = '{% url 'tagsearch' %}';
$("div#tagnav_panel").load(tagnav_url);
};

// Check if the Tag Navigation Page is already loaded
if (!$('#tagSearchForm').length) {
standby_then_load();
}


// var check_same_dataset = function(new_datasetId) {
// // Check if this dataset is already being displayed
// var crel = $("div#auto_tag_panel").attr('rel');
// if (crel !== undefined && crel.length > 0 ) {
// var cdsId = crel.split("-")[1];
// if (cdsId === new_datasetId) {
// return true;
// }
// }
// return false;
// };

// var auto_tag_url;
// if (dtype=="image") {
// var pr = tree_selected.parent().parent();
// if (pr.length>0) {
// var dsId = pr.attr('id').split("-")[1];

// // Check if this dataset is already being displayed
// // If so, change selection instead of reloading
// if (check_same_dataset(dsId)) {
// //TODO Change selection
// return;
// }
// // Otherwise, load is require
// standby_then_load(dsId);
// } else {
// return;
// }

// } else if (dtype=="dataset") {
// // Check if this dataset is already being displayed
// // If so, selecting dataset itself equates to no images selected
// if (check_same_dataset(oid)) {
// //TODO Change selection to none
// return;
// }
// // Otherwise, load is required
// standby_then_load(oid);
// } else {
// return;
// }
},
// supported_obj_types: ['dataset', 'image']
});
});

Expand Down

0 comments on commit 4b54b32

Please sign in to comment.