Skip to content

Commit

Permalink
editor visual queues added
Browse files Browse the repository at this point in the history
  • Loading branch information
stevewirts committed Aug 19, 2015
1 parent 776a125 commit 83f249e
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 18 deletions.
6 changes: 3 additions & 3 deletions examples/bclys/fin-hypergrid.min.html

Large diffs are not rendered by default.

49 changes: 38 additions & 11 deletions examples/bclys/fin.data-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ com.dataProviders.JSDataProvider = (function (_super) {
return typeof value === "function"? value(): value;
};

JSDataProvider.prototype.getRow = function(y){

return this.data[y];
};

JSDataProvider.prototype.setValue = function(x, y, value){

this.data[y][this.fields[x]] = value;
Expand Down Expand Up @@ -128,9 +133,9 @@ com.dataProviders.JSDataProvider = (function (_super) {
return (a < b ? -1: 1) * type;
});
};

JSDataProvider.prototype.getFields = function(){

return this.fields;
};

Expand Down Expand Up @@ -292,7 +297,7 @@ com.AggregationFunctions = {

var AggregationFunctions = com.AggregationFunctions;


function DataGroup(name, dataProvider){

this.name = name;
Expand Down Expand Up @@ -324,7 +329,7 @@ com.AggregationFunctions = {
return this.dataProvider.totalColumns;
};


DataGroup.prototype.getGroup = function(columnIndex){

var groupsByName = {}, groups = [];
Expand Down Expand Up @@ -352,7 +357,7 @@ com.AggregationFunctions = {
return groups;
};


DataGroup.prototype.applyFunctionsToColumn = function(customFunctions){

var length = this.getRowCount();
Expand Down Expand Up @@ -408,14 +413,14 @@ com.DataBrowser = (function(){
}

DataBrowser.prototype.getGroup = function(columnIndex){

var groupsByName = {}, groups = [];
var dataProvider = this.dataProvider;
var length = dataProvider.getRowCount();
var group = null;

for(var i = 0; i < length; i++){

var columnValue = dataProvider.getValue(columnIndex, i);
if(!groupsByName[columnValue]){

Expand Down Expand Up @@ -448,7 +453,7 @@ com.DataBrowser = (function(){

return this.dataProvider.getColumnCount();
};

DataBrowser.prototype.getValue = function(x, y){

if(this.groups){
Expand All @@ -470,7 +475,7 @@ com.DataBrowser = (function(){

return this.dataProvider.getValue(x, y);
};

DataBrowser.prototype.setValue = function(x, y, value){

if(this.filteredData){
Expand Down Expand Up @@ -529,10 +534,33 @@ com.DataBrowser = (function(){
};

DataBrowser.prototype.setGroups = function(columnIndexes){

this.groups = this.getGroup(columnIndexes[0]);
};

DataBrowser.prototype.setGroups = function(){

var groups = this.getGroup(arguments.shift());
for(var i = 0; i < arguments.length; i++){


}
};

DataBrowser.prototype._applyGrouping = function(groups, indexes){

var currentGroupingIndex = indexes[0];
for(var i = 0 ; i < groups.length; i++){

var current = groups[i];
for(var j = 1; j < indexes.length; j++){

current.groups = current.getGroup(currentGroupingIndex);
this._applyGrouping(current.groups, indexes);
}
}
};

DataBrowser.prototype.getFields = function(){

return this.dataProvider.getFields();
Expand All @@ -546,4 +574,3 @@ com.DataBrowser;
com.AggregationFunctions;
com.dataProviders.CSVDataProvider;
com.dataProviders.JSDataProvider;

28 changes: 24 additions & 4 deletions examples/bclys/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@

var onFilterImage = jsonModel.getImage('filter-on');
var offFilterImage = jsonModel.getImage('filter-off');
var upDown = jsonModel.getImage('up-down');
var upDownSpin = jsonModel.getImage('up-down-spin');
var downArrow = jsonModel.getImage('down-rectangle');
//all formatting and rendering per cell can be overridden in here
cellProvider.getCell = function(config) {
var renderer = cellProvider.cellCache.simpleCellRenderer;
Expand Down Expand Up @@ -106,12 +109,18 @@
config.backgroundColor = '#aaaaff';
config.color = '#ffffff';
}
if ([0,1,4,5].indexOf(x) > -1) {
//we are a dropdown, lets provide a visual queue
config.value = [null, config.value, upDown];
}
if (x === 1) {
renderer = cellProvider.cellCache.linkCellRenderer;
} else if (x === 2) {
config.halign = 'center';
config.halign = 'left';
config.value = [null, config.value, upDownSpin];
} else if (x === 3) {
config.halign = 'center';
config.halign = 'left';
config.value = [null, config.value, downArrow];
} else if (x === 6) {
renderer = cellProvider.cellCache.buttonRenderer;
} else if (x === 7) {
Expand Down Expand Up @@ -196,14 +205,25 @@
}
});

jsonGrid.addFinEventListener('fin-mousedown', function(e){
jsonGrid.addFinEventListener('fin-click', function(e){
var cell = e.detail.gridCell;
if(cell.y > 2 && cell.x === 7) {
jsonGrid.toggleSelectRow(cell.y, []);
}
if (cell.y === 1 && cell.x !== -1) {
jsonGrid.activateEditor(cell.x, cell.y);
if (jsonGrid.isEditing()) {
jsonGrid.stopEditing();
} else {
jsonGrid.activateEditor(cell.x, cell.y);
}
} else if (cell.y > 2 && cell.x !== -1) {
if (jsonGrid.isEditing()) {
jsonGrid.stopEditing();
} else {
jsonGrid.activateEditor(cell.x, cell.y);
}
}

});

jsonGrid.addFinEventListener('fin-button-pressed', function(e){
Expand Down

0 comments on commit 83f249e

Please sign in to comment.