From d37f3af3056fb6a307d4e9b9f7967ba2e14ee8f2 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Mon, 31 Aug 2015 13:35:06 +0000 Subject: [PATCH] Research to use a drawing board on the ELN SVN: 34549 --- .../1/as/webapps/eln-lims/html/index.html | 4 ++ .../html/js/controllers/MainController.js | 27 ++-------- .../DrawingBoards/DrawingBoardsController.js | 25 +++++++++ .../views/DrawingBoards/DrawingBoardsModel.js | 19 +++++++ .../views/DrawingBoards/DrawingBoardsView.js | 53 +++++++++++++++++++ 5 files changed, 104 insertions(+), 24 deletions(-) create mode 100644 plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsController.js create mode 100644 plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsModel.js create mode 100644 plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsView.js diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html index dc7255c155c..a2e09644f56 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html @@ -171,6 +171,10 @@ <script type="text/javascript" src="./js/views/legacy/SampleLinksWidget.js"></script> <script type="text/javascript" src="./js/views/legacy/SampleHierarchy.js"></script> + <script type="text/javascript" src="./js/views/DrawingBoards/DrawingBoardsController.js"></script> + <script type="text/javascript" src="./js/views/DrawingBoards/DrawingBoardsModel.js"></script> + <script type="text/javascript" src="./js/views/DrawingBoards/DrawingBoardsView.js"></script> + <script type="text/javascript"> // // Configurations Available (Available under the js/config folder) diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js index a5c1cf2feb8..58b03d4d053 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js @@ -411,30 +411,9 @@ function MainController(profile) { } this._showDrawingBoard = function() { - var mainContainer = $("#mainContainer"); - mainContainer.empty(); - - var containerWidth = $(document).width() - $("#sideMenu").width() - 20; - var containerHeight = $(document).height() - 60; - - var $drawingboard = $("<div>", { "id" : "scratchboard", "style" : "width: " + containerWidth + "px; height: " + containerHeight + "px; padding: 10px;" }); - mainContainer.append($drawingboard); - - //pass options and add custom controls to a board - var customBoard = new DrawingBoard.Board('scratchboard', { - background: "#ffffff", - color: "#000", - webStorage: false, - size: 30, - controls: [ - { Size: { type: "dropdown" } }, - { Navigation: { back: false, forward: false } }, - 'DrawingMode', - 'Color', - 'Download' - ], - webStorage: 'local' - }); + var drawingBoardsController = new DrawingBoardsController(this); + drawingBoardsController.init($("#mainContainer")); + this.currentView = drawingBoardsController; } this._showUserManager = function() { diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsController.js new file mode 100644 index 00000000000..0d306e5564e --- /dev/null +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsController.js @@ -0,0 +1,25 @@ +/* + * 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 DrawingBoardsController(mainController) { + this._mainController = mainController; + this._drawingBoardsModel = new DrawingBoardsModel(); + this._drawingBoardsView = new DrawingBoardsView(this, this._drawingBoardsModel); + + this.init = function($container) { + this._drawingBoardsView.repaint($container); + } +} \ No newline at end of file diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsModel.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsModel.js new file mode 100644 index 00000000000..dede9b4375d --- /dev/null +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsModel.js @@ -0,0 +1,19 @@ +/* + * 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 DrawingBoardsModel() { + +} \ No newline at end of file diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsView.js new file mode 100644 index 00000000000..ad4fcab3a56 --- /dev/null +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DrawingBoards/DrawingBoardsView.js @@ -0,0 +1,53 @@ +/* + * 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 DrawingBoardsView(drawingBoardsController, drawingBoardsModel) { + this._drawingBoardsController = drawingBoardsController; + this._drawingBoardsModel = drawingBoardsModel; + + this.repaint = function($container) { + $container.empty(); + var $wrapper = $('<form>', { class : 'form-horizontal ', 'id' : 'mainDataSetForm', 'role' : 'form'}); + var $title = $('<h2>').append('Drawing Board'); + $wrapper.append($title); + var $createNewBtn = FormUtil.getButtonWithText('New Drawing Board', function() { + $container.empty(); + + var containerWidth = $(document).width() - $("#sideMenu").width() - 20; + var containerHeight = $(document).height() - 60; + + var $drawingboard = $("<div>", { "id" : "scratchboard", "style" : "width: " + containerWidth + "px; height: " + containerHeight + "px; padding: 10px;" }); + $container.append($drawingboard); + + //pass options and add custom controls to a board + var customBoard = new DrawingBoard.Board('scratchboard', { + background: "#ffffff", + color: "#000", + webStorage: false, + size: 30, + controls: [ + { Size: { type: "dropdown" } }, + { Navigation: { back: false, forward: false } }, + 'DrawingMode', + 'Color', + 'Download' + ] + }); + }); + $wrapper.append($createNewBtn); + $container.append($wrapper); + } +} \ No newline at end of file -- GitLab