mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixing the lint error messages in javascript using 'eslint --fix'
command.
This commit is contained in:
parent
ea82d92e41
commit
d54c35d74f
@ -1,132 +1,132 @@
|
||||
define(['sources/selection/range_selection_helper'],
|
||||
function (RangeSelectionHelper) {
|
||||
return {
|
||||
getUnion: function (allRanges) {
|
||||
if (_.isEmpty(allRanges)) {
|
||||
return [];
|
||||
}
|
||||
function (RangeSelectionHelper) {
|
||||
return {
|
||||
getUnion: function (allRanges) {
|
||||
if (_.isEmpty(allRanges)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
allRanges.sort(firstElementNumberComparator);
|
||||
var unionedRanges = [allRanges[0]];
|
||||
allRanges.sort(firstElementNumberComparator);
|
||||
var unionedRanges = [allRanges[0]];
|
||||
|
||||
allRanges.forEach(function (range) {
|
||||
var maxBeginningOfRange = _.last(unionedRanges);
|
||||
if (isStartInsideRange(range, maxBeginningOfRange)) {
|
||||
if (!isEndInsideRange(range, maxBeginningOfRange)) {
|
||||
maxBeginningOfRange[1] = range[1];
|
||||
allRanges.forEach(function (range) {
|
||||
var maxBeginningOfRange = _.last(unionedRanges);
|
||||
if (isStartInsideRange(range, maxBeginningOfRange)) {
|
||||
if (!isEndInsideRange(range, maxBeginningOfRange)) {
|
||||
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) {
|
||||
return [range.fromRow, range.toRow];
|
||||
});
|
||||
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;
|
||||
function firstElementNumberComparator(a, b) {
|
||||
return a[0] - b[0];
|
||||
}
|
||||
}
|
||||
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 || '"';
|
||||
function isStartInsideRange(range, surroundingRange) {
|
||||
return range[0] <= surroundingRange[1] + 1;
|
||||
}
|
||||
|
||||
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 = '';
|
||||
function isEndInsideRange(range, surroundingRange) {
|
||||
return range[1] <= surroundingRange[1];
|
||||
}
|
||||
}
|
||||
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 = '';
|
||||
},
|
||||
|
||||
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) {
|
||||
|
||||
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() {
|
||||
return (
|
||||
<SplitPane defaultSize='50%' split='vertical' pane1Style={queryEntryListDivStyle}
|
||||
pane2Style={queryDetailDivStyle}>
|
||||
pane2Style={queryDetailDivStyle}>
|
||||
<QueryHistoryEntries historyEntries={this.state.history}
|
||||
selectedEntry={this.state.selectedEntry}
|
||||
onSelectEntry={this.selectHistoryEntry}
|
||||
selectedEntry={this.state.selectedEntry}
|
||||
onSelectEntry={this.selectHistoryEntry}
|
||||
/>
|
||||
<QueryHistoryDetail historyEntry={this.state.currentHistoryDetail}/>
|
||||
</SplitPane>);
|
||||
|
@ -91,10 +91,10 @@ export default class QueryHistoryEntries extends React.Component {
|
||||
return (
|
||||
entriesGroupedByDate[key].map((entry, index) =>
|
||||
<li key={`group-${parentIndex}-entry-${index}`}
|
||||
className='list-item'
|
||||
tabIndex={0}
|
||||
onClick={() => this.props.onSelectEntry(startingEntryIndex + index)}
|
||||
onKeyDown={this.navigateUpAndDown}>
|
||||
className='list-item'
|
||||
tabIndex={0}
|
||||
onClick={() => this.props.onSelectEntry(startingEntryIndex + index)}
|
||||
onKeyDown={this.navigateUpAndDown}>
|
||||
<QueryHistoryEntry
|
||||
historyEntry={entry}
|
||||
isSelected={(startingEntryIndex + index) === this.props.selectedEntry}/>
|
||||
@ -143,7 +143,7 @@ export default class QueryHistoryEntries extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div id='query_list'
|
||||
className="query-history">
|
||||
className="query-history">
|
||||
{this.retrieveGroups()}
|
||||
</div>
|
||||
);
|
||||
|
@ -23,8 +23,8 @@ describe('copyData', function () {
|
||||
beforeEach(function () {
|
||||
SlickGrid = Slick.Grid;
|
||||
var data = [{'id': 1, 'brand':'leopord', 'size':12, '__temp_PK': '123'},
|
||||
{'id': 2, 'brand':'lion', 'size':13, '__temp_PK': '456'},
|
||||
{'id': 3, 'brand':'puma', 'size':9, '__temp_PK': '789'}],
|
||||
{'id': 2, 'brand':'lion', 'size':13, '__temp_PK': '456'},
|
||||
{'id': 3, 'brand':'puma', 'size':9, '__temp_PK': '789'}],
|
||||
dataView = new Slick.Data.DataView();
|
||||
|
||||
var CSVOptions = {'quoting': 'strings', 'quote_char': '"', 'field_separator': ','};
|
||||
|
@ -135,19 +135,19 @@ describe('RangeBoundaryNavigator', function () {
|
||||
var data, columnDefinitions, ranges, CSVOptions;
|
||||
beforeEach(function () {
|
||||
data = [{'id':1, 'animal':'leopard', 'size':'12'},
|
||||
{'id':2, 'animal':'lion', 'size':'13'},
|
||||
{'id':3, 'animal':'cougar', 'size':'9'},
|
||||
{'id':4, 'animal':'tiger', 'size':'10'}];
|
||||
{'id':2, 'animal':'lion', 'size':'13'},
|
||||
{'id':3, 'animal':'cougar', 'size':'9'},
|
||||
{'id':4, 'animal':'tiger', 'size':'10'}];
|
||||
|
||||
columnDefinitions = [{name: 'id', field: 'id', pos: 0},
|
||||
{name: 'animal', field: 'animal', pos: 1},
|
||||
{name: 'size', field: 'size', pos: 2}];
|
||||
{name: 'animal', field: 'animal', pos: 1},
|
||||
{name: 'size', field: 'size', pos: 2}];
|
||||
ranges = [new Slick.Range(0, 0, 0, 2), new Slick.Range(3, 0, 3, 2)];
|
||||
|
||||
CSVOptions = [{'quoting': 'all', 'quote_char': '"', 'field_separator': ','},
|
||||
{'quoting': 'strings', 'quote_char': '"', 'field_separator': ';'},
|
||||
{'quoting': 'strings', 'quote_char': '\'', 'field_separator': '|'},
|
||||
{'quoting': 'none', 'quote_char': '"', 'field_separator': '\t'}];
|
||||
{'quoting': 'strings', 'quote_char': '"', 'field_separator': ';'},
|
||||
{'quoting': 'strings', 'quote_char': '\'', 'field_separator': '|'},
|
||||
{'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 () {
|
||||
|
@ -200,9 +200,9 @@ describe('set_staged_rows', function () {
|
||||
describe('selected rows missing primary key', function () {
|
||||
beforeEach(function () {
|
||||
var data = [{'a pk column': 'one', 'some column': 'two', '__temp_PK': '123'},
|
||||
{'some column': 'four', '__temp_PK': '456'},
|
||||
{'some column': 'six', '__temp_PK': '789'},
|
||||
{'a pk column': 'seven', 'some column': 'eight', '__temp_PK': '432'}],
|
||||
{'some column': 'four', '__temp_PK': '456'},
|
||||
{'some column': 'six', '__temp_PK': '789'},
|
||||
{'a pk column': 'seven', 'some column': 'eight', '__temp_PK': '432'}],
|
||||
dataView = new Slick.Data.DataView();
|
||||
|
||||
dataView.setItems(data, '__temp_PK');
|
||||
|
Loading…
Reference in New Issue
Block a user