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

SSDM-344 : New Free Form Table structure (ongoing work).

SVN: 32249
parent 1f2ff631
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
}
......
......@@ -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);
......
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