Skip to content

Commit

Permalink
Merge pull request #28 from martinRenou/clean_logs
Browse files Browse the repository at this point in the history
Clean logs
  • Loading branch information
SylvainCorlay committed Feb 13, 2019
2 parents d1c64d3 + 828a1ac commit f93da92
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions js/src/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ let SheetModel = widgets.DOMWidgetModel.extend({

},
on_change_cells: function() {
console.log('change cells');
this._updating_grid = true;
try {
let previous_cells = this.previous('cells');
let cells = this.get('cells');
for(let i = 0; i < cells.length; i++) {
let cell = cells[i];
if(!contains(previous_cells, cell)) {
console.log('adding cell', cell);
this.cell_bind(cell);
}
}
Expand All @@ -100,7 +98,6 @@ let SheetModel = widgets.DOMWidgetModel.extend({
this.save_changes()
},
cell_to_grid: function(cell, save) {
console.log('cell to grid', cell);
let data = cloneDeep(this.get('data'));
this._cell_data_to_grid(cell, data)
this.set('data', data);
Expand All @@ -118,8 +115,6 @@ let SheetModel = widgets.DOMWidgetModel.extend({
let value = cell.get('value');
let cell_row = i - cell.get('row_start');
let cell_col = j - cell.get('column_start');
//console.log(cell.get('value'), i, j, cell_row, cell_col, ',', data.length, data[0].length, data, value)
//console.log(value[cell_row][cell_col])
if((i >= data.length) || (j >= data[i].length))
continue; // skip cells that are out of the sheet
let cell_data = data[i][j];
Expand All @@ -136,7 +131,6 @@ let SheetModel = widgets.DOMWidgetModel.extend({
}
if(value != null)
cell_data.value = value;
//console.log(i, j, cell.get('style'), value)
cell_data.options['type'] = cell.get('type') || cell_data.options['type'];
cell_data.options['style'] = extend({}, cell_data.options['style'], cell.get('style'));
cell_data.options['renderer'] = cell.get('renderer') || cell_data.options['renderer'];
Expand All @@ -148,10 +142,8 @@ let SheetModel = widgets.DOMWidgetModel.extend({
},
grid_to_cell: function() {
if(this._updating_grid) {
console.log('grid to cell skipped');
return;
}
console.log('grid to cell HELL YOO', this._massive_update);
this._updating_grid = true;
try {
let data = this.get('data');
Expand Down Expand Up @@ -205,7 +197,6 @@ let SheetModel = widgets.DOMWidgetModel.extend({
let empty_row = () => {
return times(this.get('columns'), empty_cell);
};
//console.log('data<', data)
if(rows < data.length) {
data = data.slice(0, rows);
} else if(rows > data.length) {
Expand All @@ -224,7 +215,6 @@ let SheetModel = widgets.DOMWidgetModel.extend({
}
data[i] = row;
}
//console.log('data>', data)
this.set('data', data);
this.save_changes();
}
Expand Down Expand Up @@ -257,14 +247,10 @@ let put_values2d = function(grid, values) {
Handsontable.renderers.registerRenderer('styled', function customRenderer(hotInstance, td, row, column, prop, value, cellProperties) {
let name = cellProperties.original_renderer || cellProperties.type || 'text';
let original_renderer = Handsontable.renderers.getRenderer(name);
if(!original_renderer) {
console.error('could not find renderer: ' + original_renderer)
} else {
original_renderer.apply(this, arguments);
each(cellProperties.style, function(value, key) {
td.style[key] = value;
});
}
original_renderer.apply(this, arguments);
each(cellProperties.style, function(value, key) {
td.style[key] = value;
});
});

let testing = false;
Expand Down Expand Up @@ -320,7 +306,6 @@ let SheetView = widgets.DOMWidgetView.extend({
}, this._hot_settings())));
},
_update_hot_settings: function() {
console.log('update', this._hot_settings());
this.hot.updateSettings(this._hot_settings());
},
_hot_settings: function() {
Expand Down Expand Up @@ -349,22 +334,18 @@ let SheetView = widgets.DOMWidgetView.extend({
if('renderer' in cellProperties)
cellProperties.original_renderer = cellProperties['renderer'];
cellProperties.renderer = 'styled';
//console.log(row, col, prop, cellProperties)
return cellProperties;
},
_on_change_grid: function(changes, source) {
let data = this.hot.getSourceDataArray();
console.log('table altered, make sure this is reflected in the model', data.length, data[0].length);
this.model.set({'rows': data.length, 'columns': data[0].length});
this.model.save_changes();
},
_on_change: function(changes, source) {
console.log('table altered...', changes, source);
//*
if(source == 'loadData')
return; // ignore loadData
if(source == 'alter') {
console.log('table altered, make sure this is reflected in the model');
let data = this.hot.getSourceDataArray();
this.model.set({'rows': data.length, 'columns': data[0].length});
this.model.save_changes();
Expand Down

0 comments on commit f93da92

Please sign in to comment.