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 93a2bdd4c9a4936a3b2554c2c8ae341a6366dde7..442fe41f82b8581314883598d7680e5295007400 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 @@ -55,26 +55,46 @@ function FreeFormTableController(sample, isEnabled) { this.save(); } + this._updateChangesOnDOMandView = function(tableIdx) { + this.save(); + var tableModel = this._freeFormTableModel.tables[tableIdx]; + var $tableContainer = $(this._freeFormTableView._tableContainers[tableIdx].children()[1]); + $tableContainer.empty(); + var isMini = $('#' + 'SwitchFreeFormTable_' + tableIdx).children()[0].checked; + if(isMini) { + tableView = this._freeFormTableView._getMiniTable(tableIdx, tableModel.modelMini); + } else { + tableView = this._freeFormTableView._getDetailedTable(tableIdx, tableModel.modelDetailed); + } + $tableContainer.append(tableView); + } + this.addRow = function(tableIdx, rowIdx) { var tableModel = this._freeFormTableModel.tables[tableIdx]; + + //Detailed Model var numColumns = tableModel.modelDetailed[0].length; - tableModel.modelDetailed.splice(rowIdx, 0, [numColumns]); + tableModel.modelDetailed.splice(rowIdx, 0, new Array(numColumns)); + //Mini Model + tableModel.modelMini.rows.splice(rowIdx, 0, ''); - this.save(); + this._updateChangesOnDOMandView(tableIdx); } this.delRow = function(tableIdx, rowIdx) { tableModel.modelDetailed.splice(rowIdx, 1); - this.save(); + this._updateChangesOnDOMandView(tableIdx); } this.addColumn = function(tableIdx, colIdx) { + this._updateChangesOnDOMandView(tableIdx); } this.delColumn = function(tableIdx, colIdx) { + this._updateChangesOnDOMandView(tableIdx); } this.importCSV = 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 78045a483b0d50532063fb6eb9373ac3d3f31eb3..828256f118ffb4369cfa0f63365608a3cefcbaca 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 @@ -21,7 +21,7 @@ function FreeFormTableView(freeFormTableController, freeFormTableModel) { this._getSwitchForTable = function(tableIdx, $wrappedTable) { var _this = this; - var $switch = $("<div>", {"class" : "switch-toggle well", "style" : "width:33%; margin-left: auto; margin-right: auto; min-height: 38px !important;"}); + var $switch = $("<div>", {'id' : 'SwitchFreeFormTable_' + tableIdx, "class" : "switch-toggle well", "style" : "width:33%; margin-left: auto; margin-right: auto; min-height: 38px !important;"}); var changeEvent = function(index, $tableContainer) { return function(event) { var isMini = $(this).children()[0].checked;