diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/widgets/FreeFormTableController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/widgets/FreeFormTableController.js index be0e123e093a3fc80733ae209c1a693fda161421..eff6e842422a02abc58732ae0397b7c1a548e19c 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/widgets/FreeFormTableController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/widgets/FreeFormTableController.js @@ -19,12 +19,25 @@ function FreeFormTableController(sample, isEnabled) { this._freeFormTableView = new FreeFormTableView(this, this._freeFormTableModel); this.init = function($container) { + this.load(); this._freeFormTableView.repaint($container); } // // API // + this.save = function() { + sample.properties[this._freeFormTableModel.samplePropertyCode] = JSON.stringify(this._freeFormTableModel.tables); + } + + this.load = function() { + $("#" + this._freeFormTableModel.samplePropertyCode).parent().parent().hide(); //Hide State Field + var state = sample.properties[this._freeFormTableModel.samplePropertyCode]; + if(state && state !== "") { + this._freeFormTableModel.tables = JSON.parse(state); + } + } + this.addTable = function(tableIdx) { } diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/widgets/FreeFormTableView.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/widgets/FreeFormTableView.js index 64f52f3b734c99916f270b52267a0f13155e8fb5..9a0ffe0465eecf99ab52baa329c91c8f379a1d44 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/widgets/FreeFormTableView.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/widgets/FreeFormTableView.js @@ -53,6 +53,7 @@ function FreeFormTableView(freeFormTableController, freeFormTableModel) { } this._getMiniTable = function(modelMini) { + var _this = this; var $colsTitle = $("<h4>").append("Columns"); var $colsContainer = $("<div>"); for(var i = 0; i < modelMini.columns.length; i++) { @@ -62,6 +63,7 @@ function FreeFormTableView(freeFormTableController, freeFormTableModel) { var keyUpEvent = function(columIdx, modelMini) { return function() { modelMini.columns[columIdx] = $(this).val(); + _this._dilutionTableController.save(); }; } $textField.keyup(keyUpEvent(i, modelMini)); @@ -97,6 +99,7 @@ function FreeFormTableView(freeFormTableController, freeFormTableModel) { } this._getDetailedTable = function(modelDetailed) { + var _this = this; var $table = $("<table>", { 'class' : 'table table-bordered' }); for(var i = 0; i < modelDetailed.length; i++) { var $row = $("<tr>"); @@ -112,6 +115,7 @@ function FreeFormTableView(freeFormTableController, freeFormTableModel) { var keyUpEvent = function(rowIdx, columIdx, modelDetailed) { return function() { modelDetailed[rowIdx][columIdx] = $(this).val(); + _this._dilutionTableController.save(); }; } $textField.keyup(keyUpEvent(i, j, modelDetailed)); @@ -127,6 +131,7 @@ function FreeFormTableView(freeFormTableController, freeFormTableModel) { } this.repaint = function($container) { + var _this = this; $container.empty(); for(var tableIdx = 0; tableIdx < this._freeFormTableModel.tables.length; tableIdx++) { var tableData = this._freeFormTableModel.tables[tableIdx]; @@ -141,6 +146,13 @@ function FreeFormTableView(freeFormTableController, freeFormTableModel) { if(this._freeFormTableModel.isEnabled) { $title = $("<input>", { 'type' : 'text', 'style' : 'width:250px;' }); $title.val(tableData.name); + var keyUpEvent = function(tableData) { + return function() { + tableData.name = $(this).val(); + _this._dilutionTableController.save(); + }; + } + $title.keyup(keyUpEvent(tableData)); } else { $title = $("<h3>"); $title.append(tableData.name);