diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js index cfefe1dd31624bbba72005221a9603c853e852db..0300c9a575f829d7c25ffbe15d10b41a5c9888d7 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js @@ -747,6 +747,9 @@ function ServerFacade(openbisServer) { if(fetchOptions.withProjects) { fetchOptions.withProjects(); } + if(fetchOptions.withProperties) { + fetchOptions.withProperties(); + } //Operator var operator = advancedSearchCriteria.logicalOperator; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormController.js index 500d79e9413ac773cbb0549315ac744c51329690..7cfe5d7e6483feabe0286b49efa346dd097562a0 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormController.js @@ -168,8 +168,10 @@ function DataSetFormController(parentController, mode, sample, dataSet, isMini) if(_this._dataSetFormModel.mode === FormMode.CREATE) { Util.showSuccess("DataSet Created.", callbackOk); + mainController.sideMenu.refreshCurrentNode(); } else if(_this._dataSetFormModel.mode === FormMode.EDIT) { Util.showSuccess("DataSet Updated.", callbackOk); + mainController.sideMenu.refreshNodeParent(_this._dataSetFormModel.dataSet.code); } } else { //This should never happen diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormView.js index ab8d11a7b8d35d717905a59327beea3c64502c80..736a740bc07fbf9c436a1830829fbefc7646e278 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormView.js @@ -81,6 +81,7 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { //Delete Button var $deleteBtn = FormUtil.getDeleteButton(function(reason) { _this._dataSetFormController.deleteDataSet(reason); + mainController.sideMenu.deleteNodeByEntityPermId(_this._dataSetFormModel.dataSet.code, true); }, true); toolbarModel.push({ component : $deleteBtn, tooltip: "Delete" }); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormController.js index cc953fdb44f35e34c92170d3e2860a721ce5c0c9..5cf63c2039f316b065044efe96ac2ec593459d57 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormController.js @@ -49,7 +49,7 @@ function ExperimentFormController(mainController, mode, experiment) { Util.showSuccess("Experiment Deleted"); //Delete experiment from UI - mainController.sideMenu.deleteUniqueIdAndMoveToParent(_this._experimentFormModel.experiment.identifier); + mainController.sideMenu.deleteNodeByEntityPermId(_this._experimentFormModel.experiment.permId, true); } }); }); @@ -108,14 +108,13 @@ function ExperimentFormController(mainController, mode, experiment) { } var callbackOk = function() { - var projectIdentifier = "/" + experimentSpace + "/" + experimentProject; + _this._experimentFormModel.isFormDirty = false; + if(_this._experimentFormModel.mode === FormMode.CREATE) { - var isInventory = profile.isInventorySpace(experimentSpace); - _this._mainController.sideMenu.refreshExperiment(experiment, isInventory); + _this._mainController.sideMenu.refreshCurrentNode(); //Project } else if(_this._experimentFormModel.mode === FormMode.EDIT) { - _this._mainController.sideMenu.updateExperimentName(experiment); + _this._mainController.sideMenu.refreshNodeParent(_this._experimentFormModel.experiment.permId); } - _this._experimentFormModel.isFormDirty = false; var isInventory = profile.isInventorySpace(experimentSpace); if(isInventory) { @@ -123,7 +122,6 @@ function ExperimentFormController(mainController, mode, experiment) { } else { _this._mainController.changeView("showExperimentPageFromIdentifier", experimentIdentifier); } - Util.unblockUI(); } diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormController.js index c4dc4870bcac3139170802c395b6337de4eb0fb3..3c230246ff117062ea4781ca1e0f6724124c2548 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormController.js @@ -30,8 +30,7 @@ function ProjectFormController(mainController, mode, project) { Util.showError(data.error.message); } else { Util.showSuccess("Project Deleted"); - var projectIdentifier = "/" + _this._projectFormModel.project.spaceCode + "/" + _this._projectFormModel.project.code; - mainController.sideMenu.deleteUniqueIdAndMoveToParent(projectIdentifier); + mainController.sideMenu.deleteNodeByEntityPermId(_this._projectFormModel.project.permId, true); } }); } @@ -87,7 +86,7 @@ function ProjectFormController(mainController, mode, project) { var message = ""; if(_this._projectFormModel.mode === FormMode.CREATE) { message = "Project Created."; - _this._mainController.sideMenu.refreshProject(_this._projectFormModel.project.spaceCode, _this._projectFormModel.project.code); + _this._mainController.sideMenu.refreshCurrentNode(); //Space Node } else if(_this._projectFormModel.mode === FormMode.EDIT) { message = "Project Updated."; } diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js index 46e2fe6b6cccf50ae63978572aaf3a4af1caaed3..6574545cdbc582d1a18a635f9f36282c6f6ee8d6 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js @@ -96,7 +96,7 @@ function SampleFormController(mainController, mode, sample) { } else { Util.showSuccess("Sample Deleted"); if(_this._sampleFormModel.isELNSample) { - mainController.sideMenu.deleteUniqueIdAndMoveToParent(_this._sampleFormModel.sample.identifier); + mainController.sideMenu.deleteNodeByEntityPermId(_this._sampleFormModel.sample.permId, true); } else { mainController.changeView('showSamplesPage', ":" + _this._sampleFormModel.sample.experimentIdentifierOrNull); } @@ -320,7 +320,11 @@ function SampleFormController(mainController, mode, sample) { var callbackOk = function() { if((isCopyWithNewCode || _this._sampleFormModel.mode === FormMode.CREATE || _this._sampleFormModel.mode === FormMode.EDIT) && _this._sampleFormModel.isELNSample) { - mainController.sideMenu.refreshSubExperiment(_this._sampleFormModel.sample.experimentIdentifierOrNull); + if(_this._sampleFormModel.mode === FormMode.CREATE) { + mainController.sideMenu.refreshCurrentNode(); + } else if(_this._sampleFormModel.mode === FormMode.EDIT) { + mainController.sideMenu.refreshNodeParent(_this._sampleFormModel.sample.permId); + } } var sampleCodeToOpen = null; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleController.js index dbffbd326dc2189cca27843549adf5edfc251fea..997ee37f410b4a6c820d471198308432ffb624f8 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleController.js @@ -52,7 +52,7 @@ function MoveSampleController(samplePermId, successAction) { Util.unblockUI(); if(_this._moveSampleModel.successAction) { //Delete Sample from current experiment menu - mainController.sideMenu.deleteUniqueIdAndMoveToParent(_this._moveSampleModel.sample.identifier, true); + mainController.sideMenu.deleteNodeByEntityPermId(_this._moveSampleModel.sample.permId, true); //Add Experiment to the menu if new if(_this._moveSampleModel.isNewExperiment) { @@ -67,7 +67,7 @@ function MoveSampleController(samplePermId, successAction) { } //Refresh Experiment where sample was moved - mainController.sideMenu.refreshSubExperiment(_this._moveSampleModel.experimentIdentifier); + mainController.sideMenu.refreshNodeParent(_this._moveSampleModel.sample.permId); _this._moveSampleModel.successAction(); } diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetController.js index bbe53c603daf84a1f5d80c6c0caef5712dbe760e..27100129d7d1bdfc80cf3ac2584cd62a573044f3 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetController.js @@ -30,39 +30,6 @@ function SideMenuWidgetController(mainController) { // External API for real time updates // - this.deleteUniqueIdAndMoveToParent = function(uniqueId, notMoveToParent, notRepaint) { - var itemsToCheck = [this._sideMenuWidgetModel.menuStructure]; - var currentItem = null; - while(currentItem = itemsToCheck.shift()) { - if(currentItem.newMenuIfSelected) { - for (var i = 0; i < currentItem.newMenuIfSelected.children.length; i++) { - var currentItemChild = currentItem.newMenuIfSelected.children[i]; - if(currentItemChild.uniqueId === uniqueId) { - currentItem.newMenuIfSelected.children.splice(i,1); - if(!notMoveToParent) { - this._sideMenuWidgetModel.pointerToMenuNode = currentItem; - mainController.changeView(currentItem.newViewIfSelected, currentItem.newViewIfSelectedData); - } - - if(!notRepaint) { - this._sideMenuWidgetView.repaint(); - } - return; - } - itemsToCheck.push(currentItemChild); - } - } - } - }; - - this.toggleMenuSize = function() { - this._sideMenuWidgetView.toggleMenuSize(); - } - - this.toggleNavType = function() { - this._sideMenuWidgetView.toggleNavType(); - } - this.hideSideMenu = function() { this._sideMenuWidgetView.hideSideMenu(); }; @@ -72,132 +39,30 @@ function SideMenuWidgetController(mainController) { }; this.getCurrentNodeId = function() { - return this._sideMenuWidgetModel.pointerToMenuNode.uniqueId; - } - - this.moveToNodeId = function(uniqueId) { - var nodesToCheck = [this._sideMenuWidgetModel.menuStructure]; - while(nodesToCheck.length > 0) { - var current = nodesToCheck[0]; - nodesToCheck.splice(0, 1); - - if(current.uniqueId === uniqueId) { - this._sideMenuWidgetModel.pointerToMenuNode = current; - this._sideMenuWidgetView.repaint(); - break; - } else { - if(current.newMenuIfSelected) { - for (var i = 0; i < current.newMenuIfSelected.children.length; i++) { - nodesToCheck.push(current.newMenuIfSelected.children[i]); - } - } - } - } - } - - - this.refreshProject = function(spaceCode, projectCode) { - var menuItemSpace = this._getUniqueId(spaceCode); - var newMenuIfSelectedProject = { - children: [] - }; - var projectIdentifier = "/" + spaceCode + "/" + projectCode; - var projectDisplayName = Util.getDisplayNameFromCode(projectCode); - var menuItemProject = new SideMenuWidgetComponent(true, false, projectDisplayName, projectIdentifier, menuItemSpace, newMenuIfSelectedProject, "showProjectPageFromIdentifier", projectIdentifier, "(Project)"); - menuItemSpace.newMenuIfSelected.children.push(menuItemProject); - menuItemSpace.newMenuIfSelected.children.sort(naturalSortSideMenuWidgetComponent); - this._sideMenuWidgetView.repaint(); + return (this._sideMenuWidgetModel.selectedNodeData)?this._sideMenuWidgetModel.selectedNodeData.key:null; }; - - this._getUniqueId = function(uniqueId) { - var itemsToCheck = [this._sideMenuWidgetModel.menuStructure]; - var currentItem = null; - while(currentItem = itemsToCheck.shift()) { - if(currentItem.newMenuIfSelected) { - for (var i = 0; i < currentItem.newMenuIfSelected.children.length; i++) { - var currentItemChild = currentItem.newMenuIfSelected.children[i]; - if(currentItemChild.uniqueId === uniqueId) { - return currentItemChild; - } - itemsToCheck.push(currentItemChild); - } - } + + this.deleteNodeByEntityPermId = function(key, isMoveToParent) { + var node = $(this._sideMenuWidgetModel.tree).fancytree('getTree').getNodeByKey(key); + if(isMoveToParent) { + var parent = node.getParent(); + this._showNodeView(parent); } + node.remove(); }; - this.updateExperimentName = function(experiment) { - var node = this._getUniqueId(experiment.identifier); - - var displayName = null; - if (profile.hideCodes) { - displayName = experiment.properties[profile.propertyReplacingCode]; - } - if (!displayName) { - displayName = experiment.code; - } - - node.displayName = displayName; - this._sideMenuWidgetView.repaint(); + this.refreshCurrentNode = function() { + this._refreshNode(this.getCurrentNodeId()); } - this.refreshExperiment = function(experiment, isInventory) { - var projectIdentifierEnd = experiment.identifier.lastIndexOf("/"); - var projectIdentifier = experiment.identifier.substring(0, projectIdentifierEnd); - var projectNode = this._getUniqueId(projectIdentifier); - - var newMenuIfSelectedExperiment = { - children: [] - }; - - var displayName = null; - if (profile.hideCodes) { - displayName = experiment.properties[profile.propertyReplacingCode]; - } - if (!displayName) { - displayName = experiment.code; - } - - var menuItemExperiment = null; - if (isInventory) { - menuItemExperiment = new SideMenuWidgetComponent(true, false, displayName, experiment.identifier, projectNode, null, "showSamplesPage", experiment.identifier); - } else { - menuItemExperiment = new SideMenuWidgetComponent(true, false, displayName, experiment.identifier, projectNode, newMenuIfSelectedExperiment, "showExperimentPageFromIdentifier", experiment.identifier, "(Experiment)"); - } - - projectNode.newMenuIfSelected.children.push(menuItemExperiment); - projectNode.newMenuIfSelected.children.sort(naturalSortSideMenuWidgetComponent); - this._sideMenuWidgetView.repaint(); - }; - - this.refreshSubExperiment = function(experimentIdentifier) { - var _this = this; - mainController.serverFacade.listExperimentsForIdentifiers([experimentIdentifier], function(data) { - var experimentToAskForSamples = data.result[0]; - mainController.serverFacade.listSamplesForExperiments([experimentToAskForSamples], function(subExperiments) { - var nodeCleared = false; - for (var i = 0; i < subExperiments.result.length; i++) { - var subExperiment = subExperiments.result[i]; - if (subExperiment.experimentIdentifierOrNull) { - var experimentNode = _this._getUniqueId(subExperiment.experimentIdentifierOrNull); - var displayName = null; - if (profile.hideCodes) { - displayName = subExperiment.properties[profile.propertyReplacingCode]; - } - if (!displayName) { - displayName = subExperiment.code; - } - if (!nodeCleared) { - experimentNode.newMenuIfSelected.children = []; - nodeCleared = true; - } - var menuItemSubExperiment = new SideMenuWidgetComponent(true, false, displayName, subExperiment.identifier, experimentNode, null, "showViewSamplePageFromPermId", subExperiment.permId, "(Sub Exp.)"); - experimentNode.newMenuIfSelected.children.push(menuItemSubExperiment); - } - } - _this._sideMenuWidgetView.repaint(); - }); - }); - }; + this.refreshNodeParent = function(key) { + var node = $(this._sideMenuWidgetModel.tree).fancytree('getTree').getNodeByKey(key); + this._refreshNode(node.getParent().key); + } + + this.moveToNodeId = function(uniqueId) { + // Can't be implemented initially, it will be required to keep the whole menu path to know all parents that need to be loaded + } // // Init method that builds the menu object hierarchy @@ -206,274 +71,8 @@ function SideMenuWidgetController(mainController) { this._sideMenuWidgetModel.$container = $container; var _this = this; - var labNotebookNode = new SideMenuWidgetComponent(true, true, "Lab Notebook", "LAB_NOTEBOOK", this._sideMenuWidgetModel.menuStructure, { children: [] }, 'showLabNotebookPage', null, ""); - this._sideMenuWidgetModel.menuStructure.newMenuIfSelected.children.push(labNotebookNode); - - mainController.serverFacade.listSpacesWithProjectsAndRoleAssignments(null, function(dataWithSpacesAndProjects) { - //Fill Spaces - var spaces = dataWithSpacesAndProjects.result; - var projectsToAskForExperiments = []; - for (var i = 0; i < spaces.length; i++) { - var space = spaces[i]; - - if ($.inArray(space.code, profile.inventorySpaces) !== -1 && profile.inventorySpaces.length > 0) { - continue; - } - - var newMenuIfSelectedSpace = { - children: [] - }; - var spaceDisplayName = Util.getDisplayNameFromCode(space.code); - var menuItemSpace = new SideMenuWidgetComponent(true, false, spaceDisplayName, space.code, labNotebookNode, newMenuIfSelectedSpace, 'showSpacePage', space.code, "(Space)"); - labNotebookNode.newMenuIfSelected.children.push(menuItemSpace); - - //Fill Projects - for (var j = 0; j < space.projects.length; j++) { - var project = space.projects[j]; - delete project["@id"]; - delete project["@type"]; - projectsToAskForExperiments.push(project); - - var newMenuIfSelectedProject = { - children: [] - }; - var projectIdentifier = "/" + project.spaceCode + "/" + project.code; - var projectDisplayName = Util.getDisplayNameFromCode(project.code); - var menuItemProject = new SideMenuWidgetComponent(true, false, projectDisplayName, projectIdentifier, menuItemSpace, newMenuIfSelectedProject, "showProjectPageFromPermId", project.permId, "(Project)"); - newMenuIfSelectedSpace.children.push(menuItemProject); - } - - newMenuIfSelectedSpace.children.sort(naturalSortSideMenuWidgetComponent); //Sort Projects - } - - //Fill Experiments - mainController.serverFacade.listExperiments(projectsToAskForExperiments, function(experiments) { - var experimentsToAskForSamples = []; - - if (experiments.result) { - var toSortExperiments = {}; - - for (var i = 0; i < experiments.result.length; i++) { - var experiment = experiments.result[i]; - experimentsToAskForSamples.push(experiment); - var projectIdentifierEnd = experiment.identifier.lastIndexOf("/"); - var projectIdentifier = experiment.identifier.substring(0, projectIdentifierEnd); - var projectNode = _this._getUniqueId(projectIdentifier); - toSortExperiments[projectNode.uniqueId] = projectNode; - var newMenuIfSelectedExperiment = { - children: [] - }; - - var displayName = null; - if (profile.hideCodes) { - displayName = experiment.properties[profile.propertyReplacingCode]; - } - if (!displayName) { - displayName = experiment.code; - } - - var menuItemExperiment = new SideMenuWidgetComponent(true, false, displayName, experiment.identifier, projectNode, newMenuIfSelectedExperiment, "showExperimentPageFromIdentifier", experiment.identifier, "(Experiment)"); - projectNode.newMenuIfSelected.children.push(menuItemExperiment); - } - - for(uniqueId in toSortExperiments) { - toSortExperiments[uniqueId].newMenuIfSelected.children.sort(naturalSortSideMenuWidgetComponent); //Sort Experiments - } - } - - //Fill Sub Experiments - mainController.serverFacade.listSamplesForExperiments(experimentsToAskForSamples, function(subExperiments) { - if (subExperiments.result) { - var toSortSubExperiments = {}; - - for (var i = 0; i < subExperiments.result.length; i++) { - var subExperiment = subExperiments.result[i]; - if(!profile.isSampleTypeHidden(subExperiment.sampleTypeCode)) { - var experimentNode = _this._getUniqueId(subExperiment.experimentIdentifierOrNull); - toSortSubExperiments[experimentNode.uniqueId] = experimentNode; - if (subExperiment.experimentIdentifierOrNull) { - var displayName = null; - if (profile.hideCodes) { - displayName = subExperiment.properties[profile.propertyReplacingCode]; - } - if (!displayName) { - displayName = subExperiment.code; - } - var menuItemSubExperiment = new SideMenuWidgetComponent(true, false, displayName, subExperiment.identifier, experimentNode, null, "showViewSamplePageFromPermId", subExperiment.permId, "(Sub Exp.)"); - experimentNode.newMenuIfSelected.children.push(menuItemSubExperiment); - } - } - } - - var childrenLimit = 20; - for(uniqueId in toSortSubExperiments) { - var experimentNode = toSortSubExperiments[uniqueId]; - if(experimentNode.newMenuIfSelected.children.length > childrenLimit) { - experimentNode.newMenuIfSelected.children = []; - var menuItemSubExperiment = new SideMenuWidgetComponent(false, false, "Too many Experiment components for the menu, please check the experiment form.", null, experimentNode, null, null, null, "(Too many Experiment components.)"); - experimentNode.newMenuIfSelected.children.push(menuItemSubExperiment); - } else { - experimentNode.newMenuIfSelected.children.sort(naturalSortSideMenuWidgetComponent); //Sort Sub Experiments - } - } - - } - - - - //Fill Inventory - var inventoryNode = new SideMenuWidgetComponent(true, true, "Inventory", "INVENTORY", _this._sideMenuWidgetModel.menuStructure, { children: [] }, 'showInventoryPage', null, ""); - _this._sideMenuWidgetModel.menuStructure.newMenuIfSelected.children.push(inventoryNode); - - //Fill Spaces - var spaces = dataWithSpacesAndProjects.result; - var projectsToAskForExperiments = []; - for (var i = 0; i < spaces.length; i++) { - var space = spaces[i]; - - if ($.inArray(space.code, profile.inventorySpaces) === -1) { - continue; - } - - var newMenuIfSelectedSpace = { - children: [] - }; - var spaceDisplayName = Util.getDisplayNameFromCode(space.code); - var menuItemSpace = new SideMenuWidgetComponent(true, false, spaceDisplayName, space.code, inventoryNode, newMenuIfSelectedSpace, 'showSpacePage', space.code, "(Space)"); - inventoryNode.newMenuIfSelected.children.push(menuItemSpace); - - //Fill Projects - for (var j = 0; j < space.projects.length; j++) { - var project = space.projects[j]; - delete project["@id"]; - delete project["@type"]; - projectsToAskForExperiments.push(project); - - var newMenuIfSelectedProject = { - children: [] - }; - var projectIdentifier = "/" + project.spaceCode + "/" + project.code; - var projectDisplayName = Util.getDisplayNameFromCode(project.code); - var menuItemProject = new SideMenuWidgetComponent(true, false, projectDisplayName, projectIdentifier, menuItemSpace, newMenuIfSelectedProject, "showProjectPageFromPermId", project.permId, "(Project)"); - newMenuIfSelectedSpace.children.push(menuItemProject); - } - newMenuIfSelectedSpace.children.sort(naturalSortSideMenuWidgetComponent); //Sort Projects - } - - mainController.serverFacade.listExperiments(projectsToAskForExperiments, function(experiments) { - var experimentsToAskForSamples = []; - - if (experiments.result) { - for (var i = 0; i < experiments.result.length; i++) { - var experiment = experiments.result[i]; - experimentsToAskForSamples.push(experiment); - var projectIdentifierEnd = experiment.identifier.lastIndexOf("/"); - var projectIdentifier = experiment.identifier.substring(0, projectIdentifierEnd); - var projectNode = _this._getUniqueId(projectIdentifier); - - var newMenuIfSelectedExperiment = { - children: [] - }; - - var displayName = null; - if (profile.hideCodes) { - displayName = experiment.properties[profile.propertyReplacingCode]; - } - if (!displayName) { - displayName = experiment.code; - } - - var menuItemExperiment = new SideMenuWidgetComponent(true, false, displayName, experiment.identifier, projectNode, newMenuIfSelectedExperiment, "showSamplesPage", experiment.identifier, ""); - projectNode.newMenuIfSelected.children.push(menuItemExperiment); - } - projectNode.newMenuIfSelected.children.sort(naturalSortSideMenuWidgetComponent); //Sort Experiments - } - - //Clean unused menu parts - if(!profile.mainMenu.showLabNotebook) { - _this.deleteUniqueIdAndMoveToParent("LAB_NOTEBOOK", true, true); - } - - if(!profile.mainMenu.showInventory) { - _this.deleteUniqueIdAndMoveToParent("INVENTORY", true, true); - } - - //Fill Utils - var utilities = new SideMenuWidgetComponent(true, true, "Utilities", "UTILITIES", _this._sideMenuWidgetModel.menuStructure, { children : [] } , null, null, ""); - _this._sideMenuWidgetModel.menuStructure.newMenuIfSelected.children.push(utilities); - - _this._sideMenuWidgetModel.menuStructure.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "About", "ABOUT", _this._sideMenuWidgetModel.menuStructure, null, "showAbout", null, "") - ); - - if(profile.mainMenu.showDrawingBoard) { - utilities.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "Drawing Board", "DRAWING_BOARD", utilities, null, "showDrawingBoard", null, "") - ); - } - - if(profile.mainMenu.showSampleBrowser) { - utilities.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "Sample Browser", "SAMPLE_BROWSER", utilities, null, "showSamplesPage", null, "") - ); - } - - if(profile.mainMenu.showExports) { - utilities.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "Export Builder", "EXPORT_BUILDER", utilities, null, "showExportTreePage", null, "") - ); - } - - if(profile.mainMenu.showStorageManager && profile.storagesConfiguration["isEnabled"]) { - utilities.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "Storage Manager", "STORAGE_MANAGER", utilities, null, "showStorageManager", null, "") - ); - } - - if(profile.mainMenu.showAdvancedSearch) { - utilities.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "Advanced Search", "ADVANCED_SEARCH", utilities, null, "showAdvancedSearchPage", null, "") - ); - } - - if(profile.mainMenu.showTrashcan) { - utilities.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "Trashcan", "TRASHCAN", utilities, null, "showTrashcanPage", null, "") - ); - } - - if(profile.mainMenu.showVocabularyViewer) { - utilities.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "Vocabulary Viewer", "VOCABULARY_VIEWER", utilities, null, "showVocabularyManagerPage", null, "") - ); - } - - var nextToDo = function() { - _this._sideMenuWidgetView.repaintFirst($container); - initCallback(); - } - - if(profile.mainMenu.showUserManager) { - mainController.serverFacade.listPersons(function(data) { - if(data.result && data.result.length > 0) { - utilities.newMenuIfSelected.children.push( - new SideMenuWidgetComponent(true, false, "User Manager", "USER_MANAGER", utilities, null, "showUserManagerPage", null, "") - ); - } - - nextToDo(); - }); - } else { - nextToDo(); - } - - }); - - }); - - }); - }); - + _this._sideMenuWidgetView.repaint($container); + $(window).scroll(function(event) { var sideMenuWidth = $("#sideMenu").width(); var windowWidth = $(window).width(); @@ -500,8 +99,27 @@ function SideMenuWidgetController(mainController) { //TO-DO 17px is a hack to be able to scroll properly to the last item on the iPad $elementBody.css('max-height', (windowHeight - sideMenuHeaderHeight - 17) + "px"); }); - }; - + + initCallback(); + } + + this._showNodeView = function(node) { + if(node.data.view) { + mainController.changeView(node.data.view, node.data.viewData); + this._sideMenuWidgetModel.selectedNodeData = { + key : node.key, + view : node.data.view, + viewData : node.data.viewData + }; + } + } + + this._refreshNode = function(key) { + var node = $(this._sideMenuWidgetModel.tree).fancytree('getTree').getNodeByKey(key); + node.removeChildren(); + node.resetLazy(); + node.setExpanded(true); + } } function SideMenuWidgetComponent(isSelectable, isTitle, displayName, uniqueId, parent, newMenuIfSelected, newViewIfSelected, newViewIfSelectedData, contextTitle) { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetModel.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetModel.js index ec4c25589e6105d78db6b06e6a2bb9080d8f30b9..9c74bbed6576f0578f204fd543b49a074e9503b2 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetModel.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetModel.js @@ -21,11 +21,9 @@ * @this {SideMenuWidgetModel} */ function SideMenuWidgetModel() { - this.menuDOMTitle = null; this.menuDOMBody = null; - this.menuStructure = new SideMenuWidgetComponent(false, true, "Main Menu", "MAIN_MENU", null, {children: []}, 'showBlancPage', null, ""); - this.pointerToMenuNode = this.menuStructure; this.isHidden = false; - this.isTreeNavigation = true; this.$container = null; + this.tree = null; + this.selectedNodeData = null; } \ No newline at end of file diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js index 400ab0c55e847f2eb9c2542910265c06e6b3d229..badc528724f3b6367313440db00454694a01732c 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js @@ -24,27 +24,11 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { this._sideMenuWidgetController = sideMenuWidgetController; this._sideMenuWidgetModel = sideMenuWidgetModel; - var $toggleNavButtonIcon = null; var toggleMenuSizeBig = false; var DISPLAY_NAME_LENGTH_SHORT = 15; var DISPLAY_NAME_LENGTH_LONG = 300; var cutDisplayNameAtLength = DISPLAY_NAME_LENGTH_SHORT; // Fix for long names - this._updateNavButtonIcon = function() { - if(this._sideMenuWidgetModel.isTreeNavigation) { - $toggleNavButtonIcon.removeClass( "glyphicon-align-left" ); - $toggleNavButtonIcon.addClass( "glyphicon-list" ); - } else { - $toggleNavButtonIcon.removeClass( "glyphicon-list" ); - $toggleNavButtonIcon.addClass( "glyphicon-align-left" ); - } - } - this.toggleNavType = function() { - this._sideMenuWidgetModel.isTreeNavigation = !this._sideMenuWidgetModel.isTreeNavigation; - this._updateNavButtonIcon(); - this.repaint(); - } - this.hideSideMenu = function() { this._sideMenuWidgetModel.$container.hide(); @@ -64,7 +48,7 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { this._sideMenuWidgetModel.isHidden = false; }; - this.repaintFirst = function($container) { + this.repaint = function($container) { var _this = this; var $widget = $("<div>"); // @@ -72,9 +56,8 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { // var $header = $("<div>", {"id": "sideMenuHeader"}); var $headerItemList = $("<ul>", {"class": "nav navbar-nav"}); - var $headerItemList2 = $("<ul>", {"class": "nav navbar-nav"}); $header.append($("<nav>", {"class": "navbar navbar-default", "role": "navigation", "style": "margin:0px; border-left-width:0px; border-right-width:0px;"}) - .append($headerItemList).append($("<br>")).append($headerItemList2) + .append($headerItemList).append($("<br>")) ); var $toggleButton = $("<li>") @@ -82,13 +65,6 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { .append($("<span>", {"class": "glyphicon glyphicon-resize-full"})) ); - $toggleNavButtonIcon = $("<span>", { "class" : "glyphicon" }); - this._updateNavButtonIcon(); - var $toggleNavButton = $("<li>") - .append($("<a>", {"href": "javascript:mainController.sideMenu.toggleNavType();"}) - .append($toggleNavButtonIcon) - ); - var dropDownSearch = ""; var searchDomains = profile.getSearchDomains(); @@ -175,12 +151,10 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { $headerItemList.append($logoutButton); $headerItemList.append($toggleButton); - //$headerItemList.append($toggleMenuButton); - $headerItemList.append($toggleNavButton); + $headerItemList.append($searchForm); - $headerItemList2.append($searchForm); if(dropDownSearch !== "") { - $headerItemList2.append($searchFormDropdown); + $headerItemList.append($searchFormDropdown); } var $body = $("<div>", {"id": "sideMenuBody"}); @@ -188,29 +162,16 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { .append($header) .append($body); - var $title = $("<div>", {"class": "sideMenuTitle"}); - $header - .append($title); - $container.empty(); $container.append($widget); // // Print Menu // - this._sideMenuWidgetModel.menuDOMTitle = $title; this._sideMenuWidgetModel.menuDOMBody = $body; - this.repaint(); + this.repaintTreeMenuDinamic(); }; - this.repaint = function() { - if(this._sideMenuWidgetModel.isTreeNavigation) { - this.repaintTreeMenu(); - } else { - this.repaintListMenu(); - } - } - this._getDisplayNameLinkForNode = function(menuItem, isTreeMenu) { var menuItemDisplayName = menuItem.displayName; if (!menuItemDisplayName) { @@ -242,62 +203,32 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { return $menuItemLink; } - this.repaintTreeMenu = function() { + this.repaintTreeMenuDinamic = function() { var _this = this; - this._sideMenuWidgetModel.menuDOMTitle.empty(); this._sideMenuWidgetModel.menuDOMBody.empty(); - var tree = $("<div>", { "id" : "tree" }); + var $tree = $("<div>", { "id" : "tree" }); // // Body // -// var rootNode = { title : "Main Menu", key : "MAIN_MENU", menuData : this._sideMenuWidgetModel.menuStructure }; -// var sourceByKey = { "MAIN_MENU" : rootNode }; -// var treeModel = [rootNode]; - - var sourceByKey = { }; - var treeModel = []; - var todo = this._sideMenuWidgetModel.menuStructure.newMenuIfSelected.children.slice(); - - while(todo.length > 0) { - var modelNode = todo.shift(); - - //Add Root Source if not found - var treeModelRoot = null; - if(!sourceByKey[modelNode.uniqueId]) { - treeModelRoot = {title : modelNode.displayName, key : modelNode.uniqueId, menuData : modelNode}; - treeModel.push(treeModelRoot); - sourceByKey[modelNode.uniqueId] = treeModelRoot; - } else { - treeModelRoot = sourceByKey[modelNode.uniqueId]; - } - - //Create children if new - if(modelNode.newMenuIfSelected && !treeModelRoot.children) { - treeModelRoot.folder = true; - treeModelRoot.children = []; - } - - if(modelNode.newMenuIfSelected && modelNode.newMenuIfSelected.children.length !== 0) { - for(var cIdx = 0; cIdx < modelNode.newMenuIfSelected.children.length; cIdx++) { - var modelNodeChild = modelNode.newMenuIfSelected.children[cIdx]; - var $titleWithLink = this._getDisplayNameLinkForNode(modelNodeChild, true); - if($titleWithLink.outerHTML) { - $titleWithLink = $titleWithLink.outerHTML; - } - var treeModelChild = {title : $titleWithLink, key : modelNodeChild.uniqueId, menuData : modelNodeChild}; - - //Add Child - treeModelRoot.children.push(treeModelChild); - - //Push child for next - todo.push(modelNodeChild); - sourceByKey[treeModelChild.key] = treeModelChild; - } - } - } - glyph_opts = { + var treeModel = [ + { title : "Lab Notebook", entityType: "LAB_NOTEBOOK", key : "LAB_NOTEBOOK", folder : true, lazy : true, view : "showLabNotebookPage" }, + { title : "Inventory", entityType: "INVENTORY", key : "INVENTORY", folder : true, lazy : true, view : "showInventoryPage" }, + { title : "Utilities", entityType: "UTILITIES", key : "UTILITIES", folder : true, lazy : false, children : [ + { title : "Drawing Board", entityType: "DRAWING_BOARD", key : "DRAWING_BOARD", folder : false, lazy : false, view : "showDrawingBoard" }, + { title : "Sample Browser", entityType: "SAMPLE_BROWSER", key : "SAMPLE_BROWSER", folder : false, lazy : false, view : "showSamplesPage" }, + { title : "Export Builder", entityType: "EXPORT_BUILDER", key : "EXPORT_BUILDER", folder : false, lazy : false, view : "showExportTreePage" }, + { title : "Storage Manager", entityType: "STORAGE_MANAGER", key : "STORAGE_MANAGER", folder : false, lazy : false, view : "showStorageManager" }, + { title : "Advanced Search", entityType: "ADVANCED_SEARCH", key : "ADVANCED_SEARCH", folder : false, lazy : false, view : "showAdvancedSearchPage" }, + { title : "Trashcan", entityType: "TRASHCAN", key : "TRASHCAN", folder : false, lazy : false, view : "showTrashcanPage" }, + { title : "Vocabulary Viewer", entityType: "VOCABULARY_VIEWER", key : "VOCABULARY_VIEWER", folder : false, lazy : false, view : "showVocabularyManagerPage" }, + { title : "User Manager", entityType: "USER_MANAGER", key : "USER_MANAGER", folder : false, lazy : false, view : "showUserManagerPage" } + ] }, + { title : "About", entityType: "ABOUT", key : "ABOUT", folder : false, lazy : false, view : "showAbout" } + ]; + + var glyph_opts = { map: { doc: "glyphicon glyphicon-file", docOpen: "glyphicon glyphicon-file", @@ -315,185 +246,142 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { loading: "glyphicon glyphicon-refresh" } }; - -// var updateIcons = function(treeDataNode) { -// var menuData = treeDataNode.node.data.menuData; -// if(menuData.parent && (menuData.parent.uniqueId == "UTILITIES")) { -// var node = treeDataNode.node; -// var $span = $(node.span); -// var $icon = $span.find("> span.fancytree-icon"); -// $icon.removeClass("glyphicon-file"); -// $icon.addClass("glyphicon-briefcase"); -// } -// } - - var onActivate = function(event, data) { + + var onLazyLoad = function(event, data) { + var dfd = new $.Deferred(); + data.result = dfd.promise(); + var type = data.node.data.entityType; + var permId = data.node.key; + + switch(type) { + case "LAB_NOTEBOOK": + case "INVENTORY": + var spaceRules = { entityKind : "SPACE", logicalOperator : "AND", rules : { } }; + mainController.serverFacade.searchForSpacesAdvanced(spaceRules, function(searchResult) { + var results = []; + var spaces = searchResult.objects; + for (var i = 0; i < spaces.length; i++) { + var space = spaces[i]; + var isInventorySpace = profile.isInventorySpace(space.code); + if((type === "LAB_NOTEBOOK" && !isInventorySpace) || (type === "INVENTORY" && isInventorySpace)) { + var normalizedSpaceTitle = Util.getDisplayNameFromCode(space.code); + results.push({ title : normalizedSpaceTitle, entityType: "SPACE", key : space.getCode(), folder : true, lazy : true, view : "showSpacePage", viewData: space.getCode() }); + } + } + dfd.resolve(results); + }); + break; + case "SPACE": + var projectRules = { "UUIDv4" : { type : "Attribute", name : "SPACE", value : permId } }; + mainController.serverFacade.searchForProjectsAdvanced({ entityKind : "PROJECT", logicalOperator : "AND", rules : projectRules }, function(searchResult) { + var results = []; + var projects = searchResult.objects; + for (var i = 0; i < projects.length; i++) { + var project = projects[i]; + var normalizedProjectTitle = Util.getDisplayNameFromCode(project.code); + results.push({ title : normalizedProjectTitle, entityType: "PROJECT", key : project.getPermId().getPermId(), folder : true, lazy : true, view : "showProjectPageFromPermId", viewData: project.getPermId().getPermId() }); + } + dfd.resolve(results); + }); + break; + case "PROJECT": + var experimentRules = { "UUIDv4" : { type : "Attribute", name : "PROJECT_PERM_ID", value : permId } }; + mainController.serverFacade.searchForExperimentsAdvanced({ entityKind : "EXPERIMENT", logicalOperator : "AND", rules : experimentRules }, function(searchResult) { + var results = []; + var experiments = searchResult.objects; + for (var i = 0; i < experiments.length; i++) { + var experiment = experiments[i]; + var experimentDisplayName = experiment.code; + if(experiment.properties && experiment.properties[profile.propertyReplacingCode]) { + experimentDisplayName = experiment.properties[profile.propertyReplacingCode]; + } + var isInventorySpace = profile.isInventorySpace(experiment.getIdentifier().getIdentifier().split("/")[1]); + var viewToUse = null; + var loadSamples = null; + if(isInventorySpace) { + viewToUse = "showSamplesPage"; + loadSamples = false; + } else { + viewToUse = "showExperimentPageFromIdentifier"; + loadSamples = true; + } + + results.push({ title : experimentDisplayName, entityType: "EXPERIMENT", key : experiment.getPermId().getPermId(), folder : true, lazy : loadSamples, view : viewToUse, viewData: experiment.getIdentifier().getIdentifier() }); + } + dfd.resolve(results); + }); + break; + case "EXPERIMENT": + var sampleRules = { "UUIDv4" : { type : "Experiment", name : "ATTR.PERM_ID", value : permId } }; + mainController.serverFacade.searchForSamplesAdvanced({ entityKind : "SAMPLE", logicalOperator : "AND", rules : sampleRules }, function(searchResult) { + var results = []; + var samples = searchResult.objects; + + if(samples.length > 30) { + Util.showInfo("More than 30 Samples, please use the sample table on the experiment to navigate them."); + } else { + for (var i = 0; i < samples.length; i++) { + var sample = samples[i]; + var sampleDisplayName = sample.code; + if(sample.properties && sample.properties[profile.propertyReplacingCode]) { + sampleDisplayName = sample.properties[profile.propertyReplacingCode]; + } + results.push({ title : sampleDisplayName, entityType: "SAMPLE", key : sample.getPermId().getPermId(), folder : true, lazy : true, view : "showViewSamplePageFromPermId", viewData: sample.getPermId().getPermId() }); + } + } + + dfd.resolve(results); + }); + break; + case "SAMPLE": + var datasetRules = { "UUIDv4" : { type : "Sample", name : "ATTR.PERM_ID", value : permId } }; + mainController.serverFacade.searchForDataSetsAdvanced({ entityKind : "DATASET", logicalOperator : "AND", rules : datasetRules }, function(searchResult) { + var results = []; + var datasets = searchResult.objects; + + if(datasets.length > 30) { + Util.showInfo("More than 30 Datasets, please use the dataset viewer on the sample to navigate them."); + } else { + for (var i = 0; i < datasets.length; i++) { + var dataset = datasets[i]; + var datasetDisplayName = dataset.code; + if(dataset.properties && dataset.properties[profile.propertyReplacingCode]) { + datasetDisplayName = dataset.properties[profile.propertyReplacingCode]; + } + + results.push({ title : datasetDisplayName, entityType: "DATASET", key : dataset.getPermId().getPermId(), folder : true, lazy : false, view : "showViewDataSetPageFromPermId", viewData: dataset.getPermId().getPermId() }); + } + } + + + dfd.resolve(results); + }); + break; + case "DATASET": + break; + } + }; + + var onActivate = function(event, data) { data.node.setExpanded(true); }; - var onClick = function(event, data){ - var menuData = data.node.data.menuData; - if(menuData.isSelectable) { - _this._sideMenuWidgetModel.pointerToMenuNode = menuData; - if(menuData.newViewIfSelected) { - mainController.changeView(menuData.newViewIfSelected, menuData.newViewIfSelectedData); - } + var onClick = function(event, data) { + if(data.node.data.view) { + _this._sideMenuWidgetController._showNodeView(data.node); } }; - tree.fancytree({ + $tree.fancytree({ extensions: ["dnd", "edit", "glyph"], //, "wide" glyph: glyph_opts, source: treeModel, - activate: onActivate, - click: onClick + lazyLoad : onLazyLoad, + click : onClick, + activate: onActivate }); - - this._sideMenuWidgetModel.menuDOMBody.append(tree); - - //Expand Tree Node - var expandToParent = function(tree, menuData, isRoot) { - var node = tree.fancytree("getTree").getNodeByKey(menuData.uniqueId); - if(node) { - node.setExpanded(true); - if(isRoot) { - node.setActive(true); - } - if(menuData.parent) { - expandToParent(tree, menuData.parent, false); - } - } - } - - var menuToPaint = this._sideMenuWidgetModel.pointerToMenuNode; - expandToParent(tree, menuToPaint, true); + + this._sideMenuWidgetModel.menuDOMBody.append($tree); + this._sideMenuWidgetModel.tree = $tree; } - - this.repaintListMenu = function() { - var _this = this; - var menuToPaint = this._sideMenuWidgetModel.pointerToMenuNode; - // - // Title - // - var titleShowTooltip = menuToPaint.displayName.length > cutDisplayNameAtLength; - if (titleShowTooltip) { - var titleDisplayName = (menuToPaint.displayName).substring(0, cutDisplayNameAtLength) + "..."; - } else { - var titleDisplayName = (menuToPaint.displayName); - } - // - this._sideMenuWidgetModel.menuDOMTitle.empty(); - var isBackButtonShown = menuToPaint.parent !== null; - if (isBackButtonShown) { - var backButton = $("<a>", {"id": "back-button", "href": "javascript:void(0);", "style": "float:left; color:black; padding-left:10px;"}).append($("<span>", {"class": "glyphicon glyphicon-arrow-left"})); - var backButtonClick = function(menuItem) { - return function() { - var parent = menuItem.parent; - _this._sideMenuWidgetModel.pointerToMenuNode = parent; - _this.repaint(); - - if (parent.newViewIfSelected !== null) { - mainController.changeView(parent.newViewIfSelected, parent.newViewIfSelectedData); - } - }; - }; - backButton.click(backButtonClick(menuToPaint)); - this._sideMenuWidgetModel.menuDOMTitle.append(backButton); - } - - var $titleAsTextOrLink = null; - if (menuToPaint.newViewIfSelected && menuToPaint.newViewIfSelected !== "showBlancPage") { - $titleAsTextOrLink = $("<a>", {"href": "javascript:void(0);"}).append(titleDisplayName); - - var clickFunction = function(menuToPaint) { - return function() { - mainController.changeView(menuToPaint.newViewIfSelected, menuToPaint.newViewIfSelectedData); - }; - }; - - $titleAsTextOrLink.click(clickFunction(menuToPaint)); - } else { - $titleAsTextOrLink = $("<span>").text(titleDisplayName); - } - - if (titleShowTooltip) { - $titleAsTextOrLink.attr("title", menuToPaint.displayName); - $titleAsTextOrLink.tooltipster(); - } - - var $mainTitle = $("<span>").append($titleAsTextOrLink); - - if (isBackButtonShown) { - $mainTitle.css({ - "margin-left": "-24px" - }); - } - - this._sideMenuWidgetModel.menuDOMTitle.append($mainTitle); - - - // - // Body - // - this._sideMenuWidgetModel.menuDOMBody.empty(); - for (var mIdx = 0; mIdx < menuToPaint.newMenuIfSelected.children.length; mIdx++) { - var menuItem = menuToPaint.newMenuIfSelected.children[mIdx]; - - - var $menuItem = $("<div>", {"class": "sideMenuItem"}); - - var menuItemDisplayName = menuItem.displayName; - if (!menuItemDisplayName) { - menuItemDisplayName = menuItem.unqueId; - } - - // - var itemShowTooltip = menuItemDisplayName.length > cutDisplayNameAtLength; - if (itemShowTooltip) { - var itemDisplayName = menuItemDisplayName.substring(0, cutDisplayNameAtLength) + "..."; - } else { - var itemDisplayName = menuItemDisplayName; - } - // - var $menuItemLink = this._getDisplayNameLinkForNode(menuItem); - var $menuItemTitle = $("<span>").append($menuItemLink); - - if (itemShowTooltip) { - $menuItem.attr("title", menuItemDisplayName); - $menuItem.tooltipster(); - } - - $menuItem.append($menuItemTitle); - - if (menuItem.isTitle) { - $menuItem.addClass("sideMenuItemTitle"); - } - - if (menuItem.isSelectable) { - $menuItem.addClass("sideMenuItemSelectable"); - if (menuItem.newMenuIfSelected && menuItem.newMenuIfSelected.children.length > 0) { - $menuItem.append("<span class='glyphicon glyphicon-chevron-right put-chevron-right'></span>"); - } - - var clickFunction = function(menuItem) { - return function() { - if (menuItem.newMenuIfSelected && menuItem.newMenuIfSelected.children.length > 0) { - _this._sideMenuWidgetModel.pointerToMenuNode = menuItem; - _this.repaint(); - } - - if (menuItem.newViewIfSelected !== null) { - mainController.changeView(menuItem.newViewIfSelected, menuItem.newViewIfSelectedData); - } - }; - }; - - $menuItem.click(clickFunction(menuItem)); - } - - this._sideMenuWidgetModel.menuDOMBody.append($menuItem); - } - - $(window).resize(); - }; } \ No newline at end of file