Skip to content

Commit

Permalink
Merge pull request ome#25 from will-moore/autocomplete_screens_experi…
Browse files Browse the repository at this point in the history
…ments

Fix selection of experiments/screens auto-complete item
  • Loading branch information
will-moore committed Feb 3, 2023
2 parents 4a42b61 + 77b3212 commit 0f2694b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
3.9.1 (February 2023)
---------------------

- Fix selection of Experiments/Screens auto-complete item [#25](https://github.com/IDR/idr-gallery/pull/25)

3.9.0 (February 2023)
---------------------
Expand Down
10 changes: 6 additions & 4 deletions idr_gallery/static/idr_gallery/omero_search_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ const NAME_KEY = "name";
// display this on the keyFields <select> in place of "name" key
const NAME_IDR_NUMBER = "Name (IDR number)";

const CONTAINER_TYPE = "container";

const DISPLAY_TYPES = {
image: "image",
project: "experiment",
screen: "screen",
"experiments/screens": "experiments/screen",
container: "experiments/screen",
};

// projects or screens might match Name or Description.
Expand Down Expand Up @@ -199,7 +201,7 @@ async function getAutoCompleteResults(key, query, knownKeys, operator) {
// we have duplicate result for project & screen - simply add counts
console.log("Combining", obj, projectScreenHits[id]);
projectScreenHits[id].count = projectScreenHits[id].count + obj.count;
projectScreenHits[id].type = "experiments/screens";
projectScreenHits[id].type = CONTAINER_TYPE;
}
});
console.log("projectScreenHits", projectScreenHits);
Expand Down Expand Up @@ -267,7 +269,7 @@ async function getAutoCompleteResults(key, query, knownKeys, operator) {
// result.dtype can be 'project', 'screen', 'experiments/screens'
if (result.dtype == "project" || result.dtype == "screen") {
if (!keyCounts[key].type.includes(result.dtype)) {
keyCounts[key].type = "experiments/screens";
keyCounts[key].type = CONTAINER_TYPE;
}
}
keyCounts[key].count += result.count;
Expand Down Expand Up @@ -600,7 +602,7 @@ class OmeroSearchForm {
let $select = $(".keyFields", $parent);
if ($(`option[value='${key}']`, $select).length == 0) {
// update this.resources_data and re-render <select>
if (resource == "container") {
if (resource == CONTAINER_TYPE) {
resource = "project";
}
this.resources_data[resource].push(key);
Expand Down

0 comments on commit 0f2694b

Please sign in to comment.