From 5be4e5b2a76cc9f4ab574e2c505a0779f6e0eec9 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Mon, 7 Mar 2016 13:46:49 +0000 Subject: [PATCH] SSDM-3292 : New Toolbar. SVN: 35815 --- .../webapps/eln-lims/html/js/util/FormUtil.js | 15 ++++ .../js/views/SampleForm/SampleFormView.js | 77 ++++++++++--------- 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js index d9c5ad92e87..f8efc10a767 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js @@ -665,4 +665,19 @@ var FormUtil = new function() { } return originalValue; } + + this.getToolbar = function(toolbarModel) { + var $toolbarContainer = $("<div>"); + + for(var tbIdx = 0; tbIdx < toolbarModel.length; tbIdx++) { + var $toolbarComponent = toolbarModel[tbIdx].component; + var toolbarComponentTooltip = toolbarModel[tbIdx].tooltip; + $toolbarComponent.attr("title", toolbarComponentTooltip); + $toolbarComponent.tooltipster(); + $toolbarContainer.append($toolbarComponent); + $toolbarContainer.append(" "); + } + + return $toolbarContainer; + } } \ No newline at end of file diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js index 298efc0620b..9347e45c262 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js @@ -129,9 +129,28 @@ function SampleFormView(sampleFormController, sampleFormModel) { } // - // TITLE BUTTONS + // Toolbar // if(this._sampleFormModel.mode !== FormMode.CREATE) { + var toolbarModel = []; + + //Edit + if(this._sampleFormModel.mode === FormMode.VIEW) { + var $editButton = $("<a>", { 'class' : 'btn btn-default'} ) + .append($('<span>', { 'class' : 'glyphicon glyphicon-edit' })); + + $editButton.click(function() { + mainController.changeView('showEditSamplePageFromPermId', _this._sampleFormModel.sample.permId); + }); + toolbarModel.push({ component : $editButton, tooltip: "Enable Editing" }); + } + + //Copy + var $copyButton = $("<a>", { 'class' : 'btn btn-default'} ) + .append($('<img>', { 'src' : './img/copy-icon.png', 'style' : 'width:16px; height:16px;' })); + $copyButton.click(_this._getCopyButtonEvent()); + toolbarModel.push({ component : $copyButton, tooltip: "Copy" }); + //Delete var warningText = null; if(this._sampleFormModel.sample.children.length > 0 || this._sampleFormModel.datasets.length > 0) { @@ -163,51 +182,35 @@ function SampleFormView(sampleFormController, sampleFormModel) { } } } - - $formTitle.append(FormUtil.getDeleteButton(function(reason) { + + var $deleteButton = FormUtil.getDeleteButton(function(reason) { _this._sampleFormController.deleteSample(reason); - }, true, warningText)); - //Hierarchy - $formTitle.append(" "); - $formTitle.append(FormUtil.getHierarchyButton(this._sampleFormModel.sample.permId)); - //Table hierarchy - $formTitle.append(" "); - var $tableHierarchyButton = $("<a>", { 'class' : 'btn btn-default'} ) - .append($('<img>', { 'src' : './img/hierarchy-icon.png', 'style' : 'width:16px; height:17px;' })) - .append(' T'); - $tableHierarchyButton.click(function () { - mainController.changeView('showSampleHierarchyTablePage', _this._sampleFormModel.sample.permId); - }); - $formTitle.append($tableHierarchyButton); - //Copy - $formTitle.append(" "); - var $copyButton = $("<a>", { 'class' : 'btn btn-default'} ) - .append($('<img>', { 'src' : './img/copy-icon.png', 'style' : 'width:16px; height:16px;' })); - $copyButton.click(_this._getCopyButtonEvent()); - $formTitle.append($copyButton); + }, true, warningText); + toolbarModel.push({ component : $deleteButton, tooltip: "Delete" }); + //Print - $formTitle.append(" "); var $printButton = $("<a>", { 'class' : 'btn btn-default'} ).append($('<span>', { 'class' : 'glyphicon glyphicon-print' })); $printButton.click(function() { PrintUtil.printEntity(_this._sampleFormModel.sample); }); - $formTitle.append($printButton); - //Edit - if(this._sampleFormModel.mode === FormMode.VIEW) { - $formTitle.append(" "); - var $editButton = $("<a>", { 'class' : 'btn btn-default'} ) - .append($('<span>', { 'class' : 'glyphicon glyphicon-edit' })) - .append(' Enable Editing'); - - $editButton.click(function() { - mainController.changeView('showEditSamplePageFromPermId', _this._sampleFormModel.sample.permId); - }); - - $formTitle.append($editButton); - } + toolbarModel.push({ component : $printButton, tooltip: "Print" }); + + //Hierarchy Graph + var $hierarchyGraph = FormUtil.getButtonWithImage("./img/hierarchy-icon.png", function () { + mainController.changeView('showSampleHierarchyPage', _this._sampleFormModel.sample.permId); + }); + toolbarModel.push({ component : $hierarchyGraph, tooltip: "Hierarchy Graph" }); + + //Hierarchy Table + var $hierarchyTable = FormUtil.getButtonWithIcon("glyphicon-list", function () { + mainController.changeView('showSampleHierarchyTablePage', _this._sampleFormModel.sample.permId); + }); + + toolbarModel.push({ component : $hierarchyTable, tooltip: "Hierarchy Table" }); } $formColumn.append($formTitle); + $formColumn.append(FormUtil.getToolbar(toolbarModel)); $formColumn.append($("<br>")); // // PREVIEW IMAGE -- GitLab