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

SSDM-616: Add ability to create Projects in the ELN (Refactoring)

SVN: 32097
parent edeccd1e
No related branches found
No related tags found
No related merge requests found
Showing
with 368 additions and 28 deletions
......@@ -38,7 +38,7 @@
<script type="text/javascript" src="/ch.systemsx.cisd.openbis.OpenBIS/resources/js/openbis.js"></script>
<script type="text/javascript" src="/ch.systemsx.cisd.openbis.OpenBIS/resources/js/openbis-login.js"></script>
<!-- For production ussage
<!-- For production usage
<script type="text/javascript" src="/openbis/resources/js/jquery.js"></script>
<script type="text/javascript" src="/openbis/resources/js/openbis.js"></script>
<script type="text/javascript" src="/openbis/resources/js/openbis-login.js"></script>
......@@ -89,7 +89,7 @@
<script type="text/javascript" src="./js/views/SampleHierarchy.js"></script>
<script type="text/javascript" src="./js/views/SampleTable.js"></script>
<script type="text/javascript" src="./js/views/ExperimentForm.js"></script>
<script type="text/javascript" src="./js/views/ProjectForm.js"></script>
<script type="text/javascript" src="./js/views/StorageManager/StorageManagerController.js"></script>
<script type="text/javascript" src="./js/views/StorageManager/StorageManagerModel.js"></script>
<script type="text/javascript" src="./js/views/StorageManager/StorageManagerView.js"></script>
......@@ -99,6 +99,14 @@
<script type="text/javascript" src="./js/views/StorageManager/widgets/GridController.js"></script>
<script type="text/javascript" src="./js/views/StorageManager/widgets/GridModel.js"></script>
<script type="text/javascript" src="./js/views/StorageManager/widgets/GridView.js"></script>
<!--
<script type="text/javascript" src="./js/views/Examine/ExamineController.js"></script>
<script type="text/javascript" src="./js/views/Examine/ExamineModel.js"></script>
<script type="text/javascript" src="./js/views/Examine/ExamineView.js"></script>
-->
<script type="text/javascript" src="./js/views/ProjectForm/ProjectFormController.js"></script>
<script type="text/javascript" src="./js/views/ProjectForm/ProjectFormModel.js"></script>
<script type="text/javascript" src="./js/views/ProjectForm/ProjectFormView.js"></script>
<script type="text/javascript" src="./js/widgets/DataSetViewer.js"></script>
<script type="text/javascript" src="./js/widgets/SampleLinksWidget.js"></script>
......
......@@ -307,10 +307,14 @@ function MainController(profile) {
this._showStorageManager = function() {
var storageManagerController = new StorageManagerController(this);
storageManagerController.init($("#mainContainer"));
this.currentView = storageManagerController;
}
this._showInspectors = function() {
//Show Inspectors
//var examineController = new ExamineController(this);
//examineController.init($("#mainContainer"));
//this.currentView = examineController;
this.inspector.repaint();
}
......@@ -384,9 +388,13 @@ function MainController(profile) {
this._showProjectPage = function(project) {
//Show Form
var projectForm = new ProjectForm("mainContainer", this, project);
projectForm.init();
this.currentView = projectForm;
var projectFormController = new ProjectFormController(this, FormMode.VIEW, project);
projectFormController.init($("#mainContainer"));
this.currentView = projectFormController;
//var projectForm = new ProjectForm("mainContainer", this, project);
//projectForm.init();
//this.currentView = projectForm;
}
this._showExperimentPage = function(experiment, mode) {
......
/*
* Copyright 2014 ETH Zuerich, Scientific IT Services
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ExamineController(mainController) {
this._mainController = mainController;
this._examineModel = new ExamineModel();
this._examineView = new ExamineView(this._examineModel);
this.init = function($container) {
this._examineView.repaint($container);
}
}
\ No newline at end of file
/*
* Copyright 2014 ETH Zuerich, Scientific IT Services
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ExamineModel() {
this.inspectedEntities = new Array();
}
\ No newline at end of file
/*
* Copyright 2014 ETH Zuerich, Scientific IT Services
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ExamineView(examineModel) {
this._examineModel = examineModel;
this.repaint = function($container) {
$container.empty();
$container.append("Hello world!");
}
this.getSampleRelationsLinks = function(parentsChildrenList, withLinks) {
var allParentCodesByType = {};
if(parentsChildrenList) {
for(var i = 0; i < parentsChildrenList.length; i++) {
var parent = parentsChildrenList[i];
var parentsWithType = allParentCodesByType[parent.sampleTypeCode];
if(parentsWithType === null || parentsWithType === undefined) {
parentsWithType = new Array();
}
parentsWithType.push(parent);
allParentCodesByType[parent.sampleTypeCode] = parentsWithType;
}
}
var allParentCodesAsText = "";
for(var sampleType in allParentCodesByType) {
var displayName = mainController.profile.getSampleTypeForSampleTypeCode(sampleType).description;
if(displayName === null) {
displayName = sampleType;
}
allParentCodesAsText += displayName + ": ";
var parents = allParentCodesByType[sampleType];
for(var i = 0; i < parents.length; i++) {
var parent = parents[i];
if(withLinks) {
allParentCodesAsText += "<a href=\"javascript:mainController.inspector.showSampleOnInspector('" + parent.permId + "');\">" + parent.code + "</a> ";
} else {
allParentCodesAsText += parent.code + " ";
}
}
allParentCodesAsText += "</br>";
}
return allParentCodesAsText;
}
this.getSampleBlock = function(sample, showClose, withColors, withLinks, optionalTitle, isCondensed) {
var defaultColor = null;
if(!withColors) {
defaultColor = "#ffffff"
} else {
defaultColor = mainController.profile.getColorForInspectors(sample.sampleTypeCode);
}
var inspector = "";
var divID = sample.sampleTypeCode + "_" + sample.code + "_INSPECTOR";
var inspectorClass = null;
if(isCondensed) {
inspectorClass = 'inspectorCondensed';
} else {
inspectorClass = 'inspector';
}
inspector += "<div id='"+divID+"' class='" + inspectorClass + "' style='background-color:" + defaultColor + ";' >";
if(showClose) {
var removeButton = "<span class='btn inspectorToolbar btn-default' style='float:left; margin: 2px' onclick='mainController.inspector.closeNewInspector(\""+sample.id+"\")'><i class='glyphicon glyphicon-remove'></i></span>";
inspector += removeButton;
}
if(withLinks) {
var toogleButton = "<span class='btn inspectorToolbar btn-default' style='float:left; margin: 2px' onclick='mainController.inspector.toogleInspector(\""+sample.permId+"_TOOGLE\")'><i id='"+sample.permId+"_TOOGLE_ICON' class='glyphicon glyphicon-chevron-up'></i></span>";
inspector += toogleButton;
}
if(optionalTitle) {
inspector += optionalTitle;
} else {
inspector += "<strong>" + sample.code + "</strong>";
}
if(withLinks) {
var printButton = "<span class='btn btn-default inspectorToolbar' style='float:right; margin: 2px;' onclick='javascript:mainController.inspector.printInspector(\""+sample.permId+"\")'><i class='glyphicon glyphicon-print'></i></span>";
inspector += printButton;
var viewButton = "<span class='btn btn-default inspectorToolbar' style='float:right; margin: 2px' onclick='javascript:mainController.changeView(\"showViewSamplePageFromPermId\",\""+sample.permId+"\")'><i class='glyphicon glyphicon-edit'></i></span>";
inspector += viewButton;
var hierarchyButton = "<span class='btn btn-default inspectorToolbar' style='float:right; margin: 2px' onclick=\"javascript:mainController.changeView('showSampleHierarchyPage','"+sample.permId+"');\"><img src='./img/hierarchy-icon.png' style='width:16px; height:17px;' /></span>";
inspector += hierarchyButton;
}
inspector += "<table id='" + sample.permId +"_TOOGLE' class='properties table table-condensed'>"
//Show Properties following the order given on openBIS
var sampleTypePropertiesCode = mainController.profile.getAllPropertiCodesForTypeCode(sample.sampleTypeCode);
var sampleTypePropertiesDisplayName = mainController.profile.getPropertiesDisplayNamesForTypeCode(sample.sampleTypeCode, sampleTypePropertiesCode);
for(var i = 0; i < sampleTypePropertiesCode.length; i++) {
var propertyCode = sampleTypePropertiesCode[i];
var propertyLabel = sampleTypePropertiesDisplayName[i];
var propertyContent = sample.properties[propertyCode];
//
// Fix to show vocabulary labels instead of codes
//
var sampleType = mainController.profile.getSampleTypeForSampleTypeCode(sample.sampleTypeCode);
var propertyType = mainController.profile.getPropertyTypeFrom(sampleType, propertyCode);
if(propertyType && propertyType.dataType === "CONTROLLEDVOCABULARY") {
var vocabulary = null;
if(isNaN(propertyType.vocabulary)) {
vocabulary = mainController.profile.getVocabularyById(propertyType.vocabulary.id);
} else {
vocabulary = mainController.profile.getVocabularyById(propertyType.vocabulary);
}
if(vocabulary) {
for(var j = 0; j < vocabulary.terms.length; j++) {
if(vocabulary.terms[j].code === propertyContent) {
propertyContent = vocabulary.terms[j].label;
break;
}
}
}
}
// End Fix
propertyContent = Util.getEmptyIfNull(propertyContent);
var isSingleColumn = false;
if((propertyContent instanceof String) || (typeof propertyContent === "string")) {
var transformerResult = mainController.profile.inspectorContentTransformer(sample, propertyCode, propertyContent);
isSingleColumn = transformerResult["isSingleColumn"];
propertyContent = transformerResult["content"];
propertyContent = propertyContent.replace(/\n/g, "<br />");
}
if(propertyContent !== "") {
propertyContent = Util.replaceURLWithHTMLLinks(propertyContent);
inspector += "<tr>";
if(isSingleColumn) {
inspector += "<td class='property' colspan='2'>"+propertyLabel+"<br />"+propertyContent+"</td>";
} else {
inspector += "<td class='property'>"+propertyLabel+"</td>";
inspector += "<td class='property'>"+propertyContent+"</td>";
}
inspector += "</tr>";
}
}
//Show Properties not found on openBIS (TO-DO Clean duplicated code)
for(propertyCode in sample.properties) {
if($.inArray(propertyCode, sampleTypePropertiesCode) === -1) {
var propertyLabel = propertyCode;
var propertyContent = sample.properties[propertyCode];
propertyContent = Util.getEmptyIfNull(propertyContent);
var isSingleColumn = false;
if((propertyContent instanceof String) || (typeof propertyContent === "string")) {
var transformerResult = mainController.profile.inspectorContentTransformer(sample, propertyCode, propertyContent);
isSingleColumn = transformerResult["isSingleColumn"];
propertyContent = transformerResult["content"];
propertyContent = propertyContent.replace(/\n/g, "<br />");
}
if(propertyContent !== "") {
inspector += "<tr>";
if(isSingleColumn) {
inspector += "<td class='property' colspan='2'>"+propertyLabel+"<br />"+propertyContent+"</td>";
} else {
inspector += "<td class='property'>"+propertyLabel+"</td>";
inspector += "<td class='property'>"+propertyContent+"</td>";
}
inspector += "</tr>";
}
}
}
//Show Parent Codes
var allParentCodesAsText = this.getSampleRelationsLinks(sample.parents, withLinks);
if(allParentCodesAsText.length > 0) {
inspector += "<tr>";
inspector += "<td class='property'>Parents</td>";
inspector += "<td class='property'>"+allParentCodesAsText+"</td>";
inspector += "</tr>";
}
//Show Children Codes
var allChildrenCodesAsText = this.getSampleRelationsLinks(sample.children, withLinks);
if(allChildrenCodesAsText.length > 0) {
inspector += "<tr>";
inspector += "<td class='property'>Children</td>";
inspector += "<td class='property'>"+allChildrenCodesAsText+"</td>";
inspector += "</tr>";
}
//Show Modification Date
inspector += "<tr>";
inspector += "<td class='property'>Modification Date</td>";
inspector += "<td class='property'>"+new Date(sample.registrationDetails["modificationDate"])+"</td>";
inspector += "</tr>";
//Show Creation Date
inspector += "<tr>";
inspector += "<td class='property'>Registration Date</td>";
inspector += "<td class='property'>"+new Date(sample.registrationDetails["registrationDate"])+"</td>";
inspector += "</tr>";
inspector += "</table>"
var extraContainerId = sample.sampleTypeCode + "_" + sample.code+"_INSPECTOR_EXTRA";
inspector += "<div class='inspectorExtra' id='"+ extraContainerId + "'></div>";
mainController.profile.inspectorContentExtra(extraContainerId, sample);
inspector += "</div>"
return inspector;
}
}
\ No newline at end of file
/*
* Copyright 2014 ETH Zuerich, Scientific IT Services
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ProjectFormController(mainController, mode, project) {
this._mainController = mainController;
this._projectFormModel = new ProjectFormModel(mode, project);
this._projectFormView = new ProjectFormView(this._projectFormModel);
this.init = function($container) {
this._projectFormView.repaint($container);
}
}
\ No newline at end of file
/*
* Copyright 2014 ETH Zuerich, Scientific IT Services
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ProjectFormModel(mode, project) {
this.mode = mode;
this.project = project;
}
\ No newline at end of file
......@@ -13,29 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function ProjectForm(containerId, mainController, project) {
this._containerId = containerId;
this._mainController = mainController;
this._project = project;
this._formColumClass = 'col-md-12'
function ProjectFormView(projectFormModel) {
this._projectFormModel = projectFormModel;
this.init = function() {
this.repaint();
}
this.repaint = function() {
this.repaint = function($container) {
var _this = this;
$("#" + this._containerId).empty();
$container.empty();
var $form = $("<div>", { "class" : "form-horizontal row"});
var $formColumn = $("<div>", { "class" : this._formColumClass });
var $formColumn = $("<div>", { "class" : FormUtil.formColumClass });
$form.append($formColumn);
//
// Title
//
var $formTitle = $("<h2>").append("Project /" + this._project.spaceCode + "/" + this._project.code);
var $formTitle = $("<h2>").append("Project /" + this._projectFormModel.project.spaceCode + "/" + this._projectFormModel.project.code);
$formColumn.append($formTitle);
var $createExpBtn = $("<a>", { "class" : "btn btn-default"}).append("Create Experiment");
......@@ -47,7 +41,7 @@ function ProjectForm(containerId, mainController, project) {
var experimentTypeCode = $("#experimentTypeDropdown")[0].value;
var argsMap = {
"experimentTypeCode" : experimentTypeCode,
"projectIdentifier" : "/" + _this._project.spaceCode + "/" + _this._project.code
"projectIdentifier" : "/" + _this._projectFormModel.project.spaceCode + "/" + _this._projectFormModel.project.code
}
var argsMapStr = JSON.stringify(argsMap);
......@@ -65,15 +59,13 @@ function ProjectForm(containerId, mainController, project) {
// Metadata Fields
//
$formColumn.append($("<legend>").append("Identification Info"));
$formColumn.append(FormUtil.getFieldForLabelWithText("Space", this._project.spaceCode));
$formColumn.append(FormUtil.getFieldForLabelWithText("Code", this._project.spaceCode));
$formColumn.append(FormUtil.getFieldForLabelWithText("Description", this._project.description));
$formColumn.append(FormUtil.getFieldForLabelWithText("Registered By", this._project.registrationDetails.userId));
$formColumn.append(FormUtil.getFieldForLabelWithText("Registration Date", this._project.registrationDetails.registrationDate));
$formColumn.append(FormUtil.getFieldForLabelWithText("Modification Date", this._project.registrationDetails.modificationDate));
$formColumn.append(FormUtil.getFieldForLabelWithText("Space", this._projectFormModel.project.spaceCode));
$formColumn.append(FormUtil.getFieldForLabelWithText("Code", this._projectFormModel.project.spaceCode));
$formColumn.append(FormUtil.getFieldForLabelWithText("Description", this._projectFormModel.project.description));
$formColumn.append(FormUtil.getFieldForLabelWithText("Registered By", this._projectFormModel.project.registrationDetails.userId));
$formColumn.append(FormUtil.getFieldForLabelWithText("Registration Date", this._projectFormModel.project.registrationDetails.registrationDate));
$formColumn.append(FormUtil.getFieldForLabelWithText("Modification Date", this._projectFormModel.project.registrationDetails.modificationDate));
$("#" + this._containerId).append($form);
$container.append($form);
}
}
\ No newline at end of file
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