Fixing the lint error messages in javascript using 'eslint --fix'
command.pull/6/head
parent
ea82d92e41
commit
d54c35d74f
|
@ -1,132 +1,132 @@
|
||||||
define(['sources/selection/range_selection_helper'],
|
define(['sources/selection/range_selection_helper'],
|
||||||
function (RangeSelectionHelper) {
|
function (RangeSelectionHelper) {
|
||||||
return {
|
return {
|
||||||
getUnion: function (allRanges) {
|
getUnion: function (allRanges) {
|
||||||
if (_.isEmpty(allRanges)) {
|
if (_.isEmpty(allRanges)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
allRanges.sort(firstElementNumberComparator);
|
allRanges.sort(firstElementNumberComparator);
|
||||||
var unionedRanges = [allRanges[0]];
|
var unionedRanges = [allRanges[0]];
|
||||||
|
|
||||||
allRanges.forEach(function (range) {
|
allRanges.forEach(function (range) {
|
||||||
var maxBeginningOfRange = _.last(unionedRanges);
|
var maxBeginningOfRange = _.last(unionedRanges);
|
||||||
if (isStartInsideRange(range, maxBeginningOfRange)) {
|
if (isStartInsideRange(range, maxBeginningOfRange)) {
|
||||||
if (!isEndInsideRange(range, maxBeginningOfRange)) {
|
if (!isEndInsideRange(range, maxBeginningOfRange)) {
|
||||||
maxBeginningOfRange[1] = range[1];
|
maxBeginningOfRange[1] = range[1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unionedRanges.push(range);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
unionedRanges.push(range);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return unionedRanges;
|
|
||||||
|
|
||||||
function firstElementNumberComparator(a, b) {
|
|
||||||
return a[0] - b[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
function isStartInsideRange(range, surroundingRange) {
|
|
||||||
return range[0] <= surroundingRange[1] + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isEndInsideRange(range, surroundingRange) {
|
|
||||||
return range[1] <= surroundingRange[1];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
mapDimensionBoundaryUnion: function (unionedDimensionBoundaries, iteratee) {
|
|
||||||
var mapResult = [];
|
|
||||||
unionedDimensionBoundaries.forEach(function (subrange) {
|
|
||||||
for (var index = subrange[0]; index <= subrange[1]; index += 1) {
|
|
||||||
mapResult.push(iteratee(index));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return mapResult;
|
|
||||||
},
|
|
||||||
|
|
||||||
mapOver2DArray: function (rowRangeBounds, colRangeBounds, processCell, rowCollector) {
|
|
||||||
var unionedRowRanges = this.getUnion(rowRangeBounds);
|
|
||||||
var unionedColRanges = this.getUnion(colRangeBounds);
|
|
||||||
|
|
||||||
return this.mapDimensionBoundaryUnion(unionedRowRanges, function (rowId) {
|
|
||||||
var rowData = this.mapDimensionBoundaryUnion(unionedColRanges, function (colId) {
|
|
||||||
return processCell(rowId, colId);
|
|
||||||
});
|
});
|
||||||
return rowCollector(rowData);
|
|
||||||
}.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
rangesToCsv: function (data, columnDefinitions, selectedRanges, CSVOptions) {
|
return unionedRanges;
|
||||||
|
|
||||||
var rowRangeBounds = selectedRanges.map(function (range) {
|
function firstElementNumberComparator(a, b) {
|
||||||
return [range.fromRow, range.toRow];
|
return a[0] - b[0];
|
||||||
});
|
|
||||||
var colRangeBounds = selectedRanges.map(function (range) {
|
|
||||||
return [range.fromCell, range.toCell];
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!RangeSelectionHelper.isFirstColumnData(columnDefinitions)) {
|
|
||||||
colRangeBounds = this.removeFirstColumn(colRangeBounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
var csvRows = this.mapOver2DArray(rowRangeBounds, colRangeBounds, this.csvCell.bind(this, data, columnDefinitions, CSVOptions), function (rowData) {
|
|
||||||
var field_separator = CSVOptions.field_separator || '\t';
|
|
||||||
return rowData.join(field_separator);
|
|
||||||
});
|
|
||||||
|
|
||||||
return csvRows.join('\n');
|
|
||||||
},
|
|
||||||
|
|
||||||
removeFirstColumn: function (colRangeBounds) {
|
|
||||||
var unionedColRanges = this.getUnion(colRangeBounds);
|
|
||||||
|
|
||||||
if(unionedColRanges.length == 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
var firstSubrangeStartsAt0 = function () {
|
|
||||||
return unionedColRanges[0][0] == 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
function firstSubrangeIsJustFirstColumn() {
|
|
||||||
return unionedColRanges[0][1] == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firstSubrangeStartsAt0()) {
|
|
||||||
if (firstSubrangeIsJustFirstColumn()) {
|
|
||||||
unionedColRanges.shift();
|
|
||||||
} else {
|
|
||||||
unionedColRanges[0][0] = 1;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return unionedColRanges;
|
|
||||||
},
|
|
||||||
|
|
||||||
csvCell: function (data, columnDefinitions, CSVOptions, rowId, colId) {
|
function isStartInsideRange(range, surroundingRange) {
|
||||||
var val = data[rowId][columnDefinitions[colId].field],
|
return range[0] <= surroundingRange[1] + 1;
|
||||||
quoting = CSVOptions.quoting || 'strings',
|
}
|
||||||
quote_char = CSVOptions.quote_char || '"';
|
|
||||||
|
|
||||||
if (quoting == 'all') {
|
function isEndInsideRange(range, surroundingRange) {
|
||||||
if (val && _.isObject(val)) {
|
return range[1] <= surroundingRange[1];
|
||||||
val = quote_char + JSON.stringify(val) + quote_char;
|
|
||||||
} else if (val) {
|
|
||||||
val = quote_char + val.toString() + quote_char;
|
|
||||||
} else if (_.isNull(val) || _.isUndefined(val)) {
|
|
||||||
val = '';
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
else if(quoting == 'strings') {
|
|
||||||
if (val && _.isObject(val)) {
|
mapDimensionBoundaryUnion: function (unionedDimensionBoundaries, iteratee) {
|
||||||
val = quote_char + JSON.stringify(val) + quote_char;
|
var mapResult = [];
|
||||||
} else if (val && typeof val != 'number' && typeof val != 'boolean') {
|
unionedDimensionBoundaries.forEach(function (subrange) {
|
||||||
val = quote_char + val.toString() + quote_char;
|
for (var index = subrange[0]; index <= subrange[1]; index += 1) {
|
||||||
} else if (_.isNull(val) || _.isUndefined(val)) {
|
mapResult.push(iteratee(index));
|
||||||
val = '';
|
}
|
||||||
|
});
|
||||||
|
return mapResult;
|
||||||
|
},
|
||||||
|
|
||||||
|
mapOver2DArray: function (rowRangeBounds, colRangeBounds, processCell, rowCollector) {
|
||||||
|
var unionedRowRanges = this.getUnion(rowRangeBounds);
|
||||||
|
var unionedColRanges = this.getUnion(colRangeBounds);
|
||||||
|
|
||||||
|
return this.mapDimensionBoundaryUnion(unionedRowRanges, function (rowId) {
|
||||||
|
var rowData = this.mapDimensionBoundaryUnion(unionedColRanges, function (colId) {
|
||||||
|
return processCell(rowId, colId);
|
||||||
|
});
|
||||||
|
return rowCollector(rowData);
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
rangesToCsv: function (data, columnDefinitions, selectedRanges, CSVOptions) {
|
||||||
|
|
||||||
|
var rowRangeBounds = selectedRanges.map(function (range) {
|
||||||
|
return [range.fromRow, range.toRow];
|
||||||
|
});
|
||||||
|
var colRangeBounds = selectedRanges.map(function (range) {
|
||||||
|
return [range.fromCell, range.toCell];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!RangeSelectionHelper.isFirstColumnData(columnDefinitions)) {
|
||||||
|
colRangeBounds = this.removeFirstColumn(colRangeBounds);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return val;
|
var csvRows = this.mapOver2DArray(rowRangeBounds, colRangeBounds, this.csvCell.bind(this, data, columnDefinitions, CSVOptions), function (rowData) {
|
||||||
},
|
var field_separator = CSVOptions.field_separator || '\t';
|
||||||
};
|
return rowData.join(field_separator);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return csvRows.join('\n');
|
||||||
|
},
|
||||||
|
|
||||||
|
removeFirstColumn: function (colRangeBounds) {
|
||||||
|
var unionedColRanges = this.getUnion(colRangeBounds);
|
||||||
|
|
||||||
|
if(unionedColRanges.length == 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstSubrangeStartsAt0 = function () {
|
||||||
|
return unionedColRanges[0][0] == 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
function firstSubrangeIsJustFirstColumn() {
|
||||||
|
return unionedColRanges[0][1] == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstSubrangeStartsAt0()) {
|
||||||
|
if (firstSubrangeIsJustFirstColumn()) {
|
||||||
|
unionedColRanges.shift();
|
||||||
|
} else {
|
||||||
|
unionedColRanges[0][0] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return unionedColRanges;
|
||||||
|
},
|
||||||
|
|
||||||
|
csvCell: function (data, columnDefinitions, CSVOptions, rowId, colId) {
|
||||||
|
var val = data[rowId][columnDefinitions[colId].field],
|
||||||
|
quoting = CSVOptions.quoting || 'strings',
|
||||||
|
quote_char = CSVOptions.quote_char || '"';
|
||||||
|
|
||||||
|
if (quoting == 'all') {
|
||||||
|
if (val && _.isObject(val)) {
|
||||||
|
val = quote_char + JSON.stringify(val) + quote_char;
|
||||||
|
} else if (val) {
|
||||||
|
val = quote_char + val.toString() + quote_char;
|
||||||
|
} else if (_.isNull(val) || _.isUndefined(val)) {
|
||||||
|
val = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(quoting == 'strings') {
|
||||||
|
if (val && _.isObject(val)) {
|
||||||
|
val = quote_char + JSON.stringify(val) + quote_char;
|
||||||
|
} else if (val && typeof val != 'number' && typeof val != 'boolean') {
|
||||||
|
val = quote_char + val.toString() + quote_char;
|
||||||
|
} else if (_.isNull(val) || _.isUndefined(val)) {
|
||||||
|
val = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
|
@ -92,10 +92,10 @@ export default class QueryHistory extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<SplitPane defaultSize='50%' split='vertical' pane1Style={queryEntryListDivStyle}
|
<SplitPane defaultSize='50%' split='vertical' pane1Style={queryEntryListDivStyle}
|
||||||
pane2Style={queryDetailDivStyle}>
|
pane2Style={queryDetailDivStyle}>
|
||||||
<QueryHistoryEntries historyEntries={this.state.history}
|
<QueryHistoryEntries historyEntries={this.state.history}
|
||||||
selectedEntry={this.state.selectedEntry}
|
selectedEntry={this.state.selectedEntry}
|
||||||
onSelectEntry={this.selectHistoryEntry}
|
onSelectEntry={this.selectHistoryEntry}
|
||||||
/>
|
/>
|
||||||
<QueryHistoryDetail historyEntry={this.state.currentHistoryDetail}/>
|
<QueryHistoryDetail historyEntry={this.state.currentHistoryDetail}/>
|
||||||
</SplitPane>);
|
</SplitPane>);
|
||||||
|
|
|
@ -91,10 +91,10 @@ export default class QueryHistoryEntries extends React.Component {
|
||||||
return (
|
return (
|
||||||
entriesGroupedByDate[key].map((entry, index) =>
|
entriesGroupedByDate[key].map((entry, index) =>
|
||||||
<li key={`group-${parentIndex}-entry-${index}`}
|
<li key={`group-${parentIndex}-entry-${index}`}
|
||||||
className='list-item'
|
className='list-item'
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
onClick={() => this.props.onSelectEntry(startingEntryIndex + index)}
|
onClick={() => this.props.onSelectEntry(startingEntryIndex + index)}
|
||||||
onKeyDown={this.navigateUpAndDown}>
|
onKeyDown={this.navigateUpAndDown}>
|
||||||
<QueryHistoryEntry
|
<QueryHistoryEntry
|
||||||
historyEntry={entry}
|
historyEntry={entry}
|
||||||
isSelected={(startingEntryIndex + index) === this.props.selectedEntry}/>
|
isSelected={(startingEntryIndex + index) === this.props.selectedEntry}/>
|
||||||
|
@ -143,7 +143,7 @@ export default class QueryHistoryEntries extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div id='query_list'
|
<div id='query_list'
|
||||||
className="query-history">
|
className="query-history">
|
||||||
{this.retrieveGroups()}
|
{this.retrieveGroups()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,8 +23,8 @@ describe('copyData', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
SlickGrid = Slick.Grid;
|
SlickGrid = Slick.Grid;
|
||||||
var data = [{'id': 1, 'brand':'leopord', 'size':12, '__temp_PK': '123'},
|
var data = [{'id': 1, 'brand':'leopord', 'size':12, '__temp_PK': '123'},
|
||||||
{'id': 2, 'brand':'lion', 'size':13, '__temp_PK': '456'},
|
{'id': 2, 'brand':'lion', 'size':13, '__temp_PK': '456'},
|
||||||
{'id': 3, 'brand':'puma', 'size':9, '__temp_PK': '789'}],
|
{'id': 3, 'brand':'puma', 'size':9, '__temp_PK': '789'}],
|
||||||
dataView = new Slick.Data.DataView();
|
dataView = new Slick.Data.DataView();
|
||||||
|
|
||||||
var CSVOptions = {'quoting': 'strings', 'quote_char': '"', 'field_separator': ','};
|
var CSVOptions = {'quoting': 'strings', 'quote_char': '"', 'field_separator': ','};
|
||||||
|
|
|
@ -135,19 +135,19 @@ describe('RangeBoundaryNavigator', function () {
|
||||||
var data, columnDefinitions, ranges, CSVOptions;
|
var data, columnDefinitions, ranges, CSVOptions;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
data = [{'id':1, 'animal':'leopard', 'size':'12'},
|
data = [{'id':1, 'animal':'leopard', 'size':'12'},
|
||||||
{'id':2, 'animal':'lion', 'size':'13'},
|
{'id':2, 'animal':'lion', 'size':'13'},
|
||||||
{'id':3, 'animal':'cougar', 'size':'9'},
|
{'id':3, 'animal':'cougar', 'size':'9'},
|
||||||
{'id':4, 'animal':'tiger', 'size':'10'}];
|
{'id':4, 'animal':'tiger', 'size':'10'}];
|
||||||
|
|
||||||
columnDefinitions = [{name: 'id', field: 'id', pos: 0},
|
columnDefinitions = [{name: 'id', field: 'id', pos: 0},
|
||||||
{name: 'animal', field: 'animal', pos: 1},
|
{name: 'animal', field: 'animal', pos: 1},
|
||||||
{name: 'size', field: 'size', pos: 2}];
|
{name: 'size', field: 'size', pos: 2}];
|
||||||
ranges = [new Slick.Range(0, 0, 0, 2), new Slick.Range(3, 0, 3, 2)];
|
ranges = [new Slick.Range(0, 0, 0, 2), new Slick.Range(3, 0, 3, 2)];
|
||||||
|
|
||||||
CSVOptions = [{'quoting': 'all', 'quote_char': '"', 'field_separator': ','},
|
CSVOptions = [{'quoting': 'all', 'quote_char': '"', 'field_separator': ','},
|
||||||
{'quoting': 'strings', 'quote_char': '"', 'field_separator': ';'},
|
{'quoting': 'strings', 'quote_char': '"', 'field_separator': ';'},
|
||||||
{'quoting': 'strings', 'quote_char': '\'', 'field_separator': '|'},
|
{'quoting': 'strings', 'quote_char': '\'', 'field_separator': '|'},
|
||||||
{'quoting': 'none', 'quote_char': '"', 'field_separator': '\t'}];
|
{'quoting': 'none', 'quote_char': '"', 'field_separator': '\t'}];
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns csv for the provided ranges for CSV options quoting All with char " with field separator ,', function () {
|
it('returns csv for the provided ranges for CSV options quoting All with char " with field separator ,', function () {
|
||||||
|
|
|
@ -200,9 +200,9 @@ describe('set_staged_rows', function () {
|
||||||
describe('selected rows missing primary key', function () {
|
describe('selected rows missing primary key', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var data = [{'a pk column': 'one', 'some column': 'two', '__temp_PK': '123'},
|
var data = [{'a pk column': 'one', 'some column': 'two', '__temp_PK': '123'},
|
||||||
{'some column': 'four', '__temp_PK': '456'},
|
{'some column': 'four', '__temp_PK': '456'},
|
||||||
{'some column': 'six', '__temp_PK': '789'},
|
{'some column': 'six', '__temp_PK': '789'},
|
||||||
{'a pk column': 'seven', 'some column': 'eight', '__temp_PK': '432'}],
|
{'a pk column': 'seven', 'some column': 'eight', '__temp_PK': '432'}],
|
||||||
dataView = new Slick.Data.DataView();
|
dataView = new Slick.Data.DataView();
|
||||||
|
|
||||||
dataView.setItems(data, '__temp_PK');
|
dataView.setItems(data, '__temp_PK');
|
||||||
|
|
Loading…
Reference in New Issue