Skip to content
Snippets Groups Projects
Commit b95d0561 authored by juanf's avatar juanf
Browse files

ELN UI - PAPER - Support Domain-specific searching

SVN: 32533
parent 997128e5
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ $.extend(DefaultProfile.prototype, { ...@@ -31,6 +31,7 @@ $.extend(DefaultProfile.prototype, {
// DEFAULTS, TYPICALLY DON'T TOUCH IF YOU DON'T KNOW WHAT YOU DO // DEFAULTS, TYPICALLY DON'T TOUCH IF YOU DON'T KNOW WHAT YOU DO
// //
this.searchDomains = [ { "@id" : -1, "@type" : "GobalSearch", label : "Global", name : "global"}];
this.ELNExperiments = ["SYSTEM_EXPERIMENT"]; this.ELNExperiments = ["SYSTEM_EXPERIMENT"];
this.notShowTypes = ["SYSTEM_EXPERIMENT"]; this.notShowTypes = ["SYSTEM_EXPERIMENT"];
this.inventorySpaces = []; this.inventorySpaces = [];
...@@ -68,6 +69,10 @@ $.extend(DefaultProfile.prototype, { ...@@ -68,6 +69,10 @@ $.extend(DefaultProfile.prototype, {
"isEnabled" : false "isEnabled" : false
}; };
this.getSearchDomains = function() {
return this.searchDomains;
}
this.getDefaultDataStoreCode = function() { this.getDefaultDataStoreCode = function() {
var dataStoreCode = null; var dataStoreCode = null;
if(this.allDataStores.length > 0) { if(this.allDataStores.length > 0) {
...@@ -493,6 +498,18 @@ $.extend(DefaultProfile.prototype, { ...@@ -493,6 +498,18 @@ $.extend(DefaultProfile.prototype, {
); );
} }
this.initSearchDomains = function(callback) {
var _this = this;
this.serverFacade.listSearchDomains(function(data) {
if(data && data.result) {
for(var i = 0; i < data.result.length; i++) {
_this.searchDomains.push(data.result[i]);
}
}
callback();
});
}
// //
// Initializes // Initializes
// //
...@@ -501,7 +518,9 @@ $.extend(DefaultProfile.prototype, { ...@@ -501,7 +518,9 @@ $.extend(DefaultProfile.prototype, {
this.initPropertyTypes(function(){ this.initPropertyTypes(function(){
_this.initVocabulariesForSampleTypes(function() { _this.initVocabulariesForSampleTypes(function() {
callbackWhenDone(); _this.initSearchDomains(function() {
callbackWhenDone();
});
}); });
}); });
} }
......
...@@ -154,6 +154,13 @@ function ServerFacade(openbisServer) { ...@@ -154,6 +154,13 @@ function ServerFacade(openbisServer) {
} }
} }
this.listSearchDomains = function(callbackFunction) {
if(this.openbisServer.listAvailableSearchDomains) {
this.openbisServer.listAvailableSearchDomains(callbackFunction);
} else {
callbackFunction();
}
}
// //
// Others // Others
// //
......
...@@ -20,6 +20,48 @@ var FormUtil = new function() { ...@@ -20,6 +20,48 @@ var FormUtil = new function() {
// Standard Form Fields // Standard Form Fields
// //
this.getDropDownToogleWithSelectedFeedback = function(prefixElement, labelWithEvents, isSelectedFeedback) {
var $dropDownToogle = $('<span>', { class : 'dropdown' });
if(prefixElement) {
$dropDownToogle.append(prefixElement);
}
$dropDownToogle.append($('<a>', { 'href' : '#', 'data-toggle' : 'dropdown', 'class' : 'dropdown-toggle btn btn-default'}).append($('<b>', { 'class' : 'caret' })));
var $dropDownToogleOptions = $('<ul>', { class : 'dropdown-menu', 'role' : 'menu' });
$dropDownToogle.append($dropDownToogleOptions);
for(var i = 0; i < labelWithEvents.length; i++) {
var selectedFeedback = $('<span>', { 'id' : 'dropdown-' + labelWithEvents[i].id });
if(isSelectedFeedback && i === 0) {
selectedFeedback.append("<span class='glyphicon glyphicon-ok'></span>");
}
var $a = $('<a>', { class : '', 'title' : labelWithEvents[i].title }).append(selectedFeedback).append('&nbsp;').append(labelWithEvents[i].title);
var clickFunction = function(labelWithEvents, selectedIndex, isSelectedFeedback) {
return function() {
if(isSelectedFeedback) {
for(var j = 0; j < labelWithEvents.length; j++) {
if(j === selectedIndex) {
$("#" + 'dropdown-' + labelWithEvents[j].id).append("<span class='glyphicon glyphicon-ok'></span>");
} else {
$("#" + 'dropdown-' + labelWithEvents[j].id).empty();
}
}
}
labelWithEvents[selectedIndex].href();
};
}
$a.click(clickFunction(labelWithEvents, i, isSelectedFeedback));
$dropDownToogleOptions.append($('<li>', { 'role' : 'presentation' }).append($a));
}
return $dropDownToogle;
}
this.getDefaultBenchDropDown = function(id, isRequired) { this.getDefaultBenchDropDown = function(id, isRequired) {
var $storageDropDown = this.getDefaultStoragesDropDown(id, isRequired); var $storageDropDown = this.getDefaultStoragesDropDown(id, isRequired);
if(!$storageDropDown) { if(!$storageDropDown) {
......
...@@ -393,9 +393,50 @@ function SideMenuWidget(mainController, containerId, serverFacade) { ...@@ -393,9 +393,50 @@ function SideMenuWidget(mainController, containerId, serverFacade) {
.append($("<span>", { "class" : "glyphicon glyphicon-resize-horizontal" })) .append($("<span>", { "class" : "glyphicon glyphicon-resize-horizontal" }))
); );
var dropDownSearch = "";
var searchDomains = profile.getSearchDomains();
if(searchDomains.length > 1) {
//Default Selected for the prefix
var defaultSelected = "";
if(searchDomains[0].label.length > 3) {
defaultSelected = searchDomains[0].label.substring(0, 2) + ".";
} else {
defaultSelected = searchDomains[0].label.label;
}
//Prefix function
var selectedFunction = function(selectedSearchDomain) {
return function() {
var $component = $("#prefix-selected-search-domain");
$component.empty();
if(selectedSearchDomain.label.length > 3) {
$component.append(selectedSearchDomain.label.substring(0, 2) + ".");
} else {
$component.append(selectedSearchDomain.label);
}
$component.attr('selected-name', selectedSearchDomain.name);
};
}
//Dropdown elements
var dropDownComponents = [];
for(var i = 0; i < searchDomains.length; i++) {
dropDownComponents.push({
href : selectedFunction(searchDomains[i]),
title : searchDomains[i].label,
id : searchDomains[i].name
});
}
dropDownSearch = FormUtil.getDropDownToogleWithSelectedFeedback($('<span>', { id : 'prefix-selected-search-domain', class : 'btn btn-default disabled', 'selected-name' : searchDomains[0].name }).append(defaultSelected),dropDownComponents, true);
}
var $searchForm = $("<li>") var $searchForm = $("<li>")
.append($("<form>", { "class" : "navbar-form", "onsubmit" : "return false;"}) .append($("<form>", { "class" : "navbar-form", "onsubmit" : "return false;"})
.append($("<input>", { "id" : "search", "type" : "text", "onkeyup" : "mainController.changeView(\"showSearchPage\", event.target.value);", "class" : "form-control search-query", "placeholder" : "Search"})) .append($("<input>", { "id" : "search", "type" : "text", "onkeyup" : "mainController.changeView(\"showSearchPage\", event.target.value);", "class" : "form-control search-query", "placeholder" : "Search"}))
.append('&nbsp;')
.append(dropDownSearch)
); );
var logoutButton = $("<a>", { "id" : "logout-button", "href" : "" }).append($("<span>", { "class" : "glyphicon glyphicon-off"})); var logoutButton = $("<a>", { "id" : "logout-button", "href" : "" }).append($("<span>", { "class" : "glyphicon glyphicon-off"}));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment