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

SSDM-2293 : Backwards compatible grid with multiple selected positions available.

SVN: 34490
parent 644a5788
No related branches found
No related tags found
No related merge requests found
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
function GridController() { function GridController(isSelectMultiple) {
this._gridModel = new GridModel(); this._gridModel = new GridModel(isSelectMultiple);
this._gridView = new GridView(this._gridModel); this._gridView = new GridView(this._gridModel);
this.init = function($container) { this.init = function($container) {
......
...@@ -14,8 +14,12 @@ ...@@ -14,8 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
function GridModel() { function GridModel(isSelectMultiple) {
this.isDisabled = false; this.isDisabled = false;
this.isSelectMultiple = false;
if(isSelectMultiple) {
this.isSelectMultiple = true;
}
this.numRows = null; this.numRows = null;
this.numColumns = null; this.numColumns = null;
this.labels = null; this.labels = null;
......
...@@ -105,11 +105,21 @@ function GridView(gridModel) { ...@@ -105,11 +105,21 @@ function GridView(gridModel) {
this._selectPosition = function(posX, posY, label) { //To give user feedback so he knows what he have selected this._selectPosition = function(posX, posY, label) { //To give user feedback so he knows what he have selected
if(this._gridTable && posX > 0 && posY > 0) {//API only available if the table is loaded and 0 positions are labels that can't be selected if(this._gridTable && posX > 0 && posY > 0) {//API only available if the table is loaded and 0 positions are labels that can't be selected
this._gridTable.find("td").removeClass("rackSelected"); if(!this._gridModel.isSelectMultiple) {
this._gridTable.find("td").removeClass("rackSelected");
}
var rows = this._gridTable.find("tr"); var rows = this._gridTable.find("tr");
var columns = $(rows[posX]).find("td"); var columns = $(rows[posX]).find("td");
var cell = $(columns[posY-1]); //-1 because the th tag is skipped by the selector var cell = $(columns[posY-1]); //-1 because the th tag is skipped by the selector
cell.addClass("rackSelected"); var cellClasses = cell.attr("class");
if(this._gridModel.isSelectMultiple && cellClasses && cellClasses.indexOf("rackSelected") !== -1) {
cell.removeClass("rackSelected");
} else {
cell.addClass("rackSelected");
}
} }
} }
......
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