mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Fix eslint issues for ClauseGroup and ClauseGroupViewModel files (#1127)
This commit is contained in:
parent
ff498b51e2
commit
734ee1e436
@ -87,8 +87,8 @@ src/Explorer/Tables/DataTable/TableCommands.ts
|
|||||||
src/Explorer/Tables/DataTable/TableEntityCache.ts
|
src/Explorer/Tables/DataTable/TableEntityCache.ts
|
||||||
src/Explorer/Tables/DataTable/TableEntityListViewModel.ts
|
src/Explorer/Tables/DataTable/TableEntityListViewModel.ts
|
||||||
src/Explorer/Tables/Entities.ts
|
src/Explorer/Tables/Entities.ts
|
||||||
src/Explorer/Tables/QueryBuilder/ClauseGroup.ts
|
# src/Explorer/Tables/QueryBuilder/ClauseGroup.ts
|
||||||
src/Explorer/Tables/QueryBuilder/ClauseGroupViewModel.ts
|
# src/Explorer/Tables/QueryBuilder/ClauseGroupViewModel.ts
|
||||||
src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts
|
src/Explorer/Tables/QueryBuilder/CustomTimestampHelper.ts
|
||||||
src/Explorer/Tables/QueryBuilder/QueryBuilderViewModel.ts
|
src/Explorer/Tables/QueryBuilder/QueryBuilderViewModel.ts
|
||||||
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import QueryClauseViewModel from "./QueryClauseViewModel";
|
|
||||||
import * as Utilities from "../Utilities";
|
import * as Utilities from "../Utilities";
|
||||||
|
import QueryClauseViewModel from "./QueryClauseViewModel";
|
||||||
|
|
||||||
export default class ClauseGroup {
|
export default class ClauseGroup {
|
||||||
public isRootGroup: boolean;
|
public isRootGroup: boolean;
|
||||||
|
//eslint-disable-next-line
|
||||||
public children = new Array();
|
public children = new Array();
|
||||||
public parentGroup: ClauseGroup;
|
public parentGroup: ClauseGroup;
|
||||||
private _id: string;
|
private _id: string;
|
||||||
@ -17,7 +18,7 @@ export default class ClauseGroup {
|
|||||||
* Flattens the clause tree into an array, depth-first, left to right.
|
* Flattens the clause tree into an array, depth-first, left to right.
|
||||||
*/
|
*/
|
||||||
public flattenClauses(targetArray: ko.ObservableArray<QueryClauseViewModel>): void {
|
public flattenClauses(targetArray: ko.ObservableArray<QueryClauseViewModel>): void {
|
||||||
var tempArray = new Array<QueryClauseViewModel>();
|
const tempArray = new Array<QueryClauseViewModel>();
|
||||||
|
|
||||||
this.flattenClausesImpl(this, tempArray);
|
this.flattenClausesImpl(this, tempArray);
|
||||||
targetArray.removeAll();
|
targetArray.removeAll();
|
||||||
@ -31,10 +32,10 @@ export default class ClauseGroup {
|
|||||||
newClause.clauseGroup = this;
|
newClause.clauseGroup = this;
|
||||||
this.children.push(newClause);
|
this.children.push(newClause);
|
||||||
} else {
|
} else {
|
||||||
var targetGroup = insertBefore.clauseGroup;
|
const targetGroup = insertBefore.clauseGroup;
|
||||||
|
|
||||||
if (targetGroup) {
|
if (targetGroup) {
|
||||||
var insertBeforeIndex = targetGroup.children.indexOf(insertBefore);
|
const insertBeforeIndex = targetGroup.children.indexOf(insertBefore);
|
||||||
newClause.clauseGroup = targetGroup;
|
newClause.clauseGroup = targetGroup;
|
||||||
targetGroup.children.splice(insertBeforeIndex, 0, newClause);
|
targetGroup.children.splice(insertBeforeIndex, 0, newClause);
|
||||||
}
|
}
|
||||||
@ -42,19 +43,19 @@ export default class ClauseGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public deleteClause(clause: QueryClauseViewModel): void {
|
public deleteClause(clause: QueryClauseViewModel): void {
|
||||||
var targetGroup = clause.clauseGroup;
|
const targetGroup = clause.clauseGroup;
|
||||||
|
|
||||||
if (targetGroup) {
|
if (targetGroup) {
|
||||||
var index = targetGroup.children.indexOf(clause);
|
const index = targetGroup.children.indexOf(clause);
|
||||||
targetGroup.children.splice(index, 1);
|
targetGroup.children.splice(index, 1);
|
||||||
clause.dispose();
|
clause.dispose();
|
||||||
|
|
||||||
if (targetGroup.children.length <= 1 && !targetGroup.isRootGroup) {
|
if (targetGroup.children.length <= 1 && !targetGroup.isRootGroup) {
|
||||||
var parent = targetGroup.parentGroup;
|
const parent = targetGroup.parentGroup;
|
||||||
var targetGroupIndex = parent.children.indexOf(targetGroup);
|
const targetGroupIndex = parent.children.indexOf(targetGroup);
|
||||||
|
|
||||||
if (targetGroup.children.length === 1) {
|
if (targetGroup.children.length === 1) {
|
||||||
var orphan = targetGroup.children.shift();
|
const orphan = targetGroup.children.shift();
|
||||||
|
|
||||||
if (orphan instanceof QueryClauseViewModel) {
|
if (orphan instanceof QueryClauseViewModel) {
|
||||||
(<QueryClauseViewModel>orphan).clauseGroup = parent;
|
(<QueryClauseViewModel>orphan).clauseGroup = parent;
|
||||||
@ -71,14 +72,14 @@ export default class ClauseGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public removeAll(): void {
|
public removeAll(): void {
|
||||||
var allClauses: QueryClauseViewModel[] = new Array<QueryClauseViewModel>();
|
const allClauses: QueryClauseViewModel[] = new Array<QueryClauseViewModel>();
|
||||||
|
|
||||||
this.flattenClausesImpl(this, allClauses);
|
this.flattenClausesImpl(this, allClauses);
|
||||||
|
|
||||||
while (allClauses.length > 0) {
|
while (allClauses.length > 0) {
|
||||||
allClauses.shift().dispose();
|
allClauses.shift().dispose();
|
||||||
}
|
}
|
||||||
|
//eslint-disable-next-line
|
||||||
this.children = new Array<any>();
|
this.children = new Array<any>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,12 +88,12 @@ export default class ClauseGroup {
|
|||||||
*/
|
*/
|
||||||
public groupSelectedItems(): boolean {
|
public groupSelectedItems(): boolean {
|
||||||
// Find the selection start & end, also check for gaps between selected items (if found, cannot proceed).
|
// Find the selection start & end, also check for gaps between selected items (if found, cannot proceed).
|
||||||
var selection = this.getCheckedItemsInfo();
|
const selection = this.getCheckedItemsInfo();
|
||||||
|
|
||||||
if (selection.canGroup) {
|
if (selection.canGroup) {
|
||||||
var newGroup = new ClauseGroup(false, this);
|
const newGroup = new ClauseGroup(false, this);
|
||||||
// Replace the selected items with the new group, and then move the selected items into the new group.
|
// Replace the selected items with the new group, and then move the selected items into the new group.
|
||||||
var groupedItems = this.children.splice(selection.begin, selection.end - selection.begin + 1, newGroup);
|
const groupedItems = this.children.splice(selection.begin, selection.end - selection.begin + 1, newGroup);
|
||||||
|
|
||||||
groupedItems &&
|
groupedItems &&
|
||||||
groupedItems.forEach((element) => {
|
groupedItems.forEach((element) => {
|
||||||
@ -118,13 +119,13 @@ export default class ClauseGroup {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parentGroup = this.parentGroup;
|
const parentGroup = this.parentGroup;
|
||||||
var index = parentGroup.children.indexOf(this);
|
let index = parentGroup.children.indexOf(this);
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
parentGroup.children.splice(index, 1);
|
parentGroup.children.splice(index, 1);
|
||||||
|
|
||||||
var toPromote = this.children.splice(0, this.children.length);
|
const toPromote = this.children.splice(0, this.children.length);
|
||||||
|
|
||||||
// Move all children one level up.
|
// Move all children one level up.
|
||||||
toPromote &&
|
toPromote &&
|
||||||
@ -146,16 +147,16 @@ export default class ClauseGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public findDeepestGroupInChildren(skipIndex?: number): ClauseGroup {
|
public findDeepestGroupInChildren(skipIndex?: number): ClauseGroup {
|
||||||
var deepest: ClauseGroup = this;
|
let deepest = <ClauseGroup>this;
|
||||||
var level: number = 0;
|
let level = 0;
|
||||||
var func = (currentGroup: ClauseGroup): void => {
|
const func = (currentGroup: ClauseGroup): void => {
|
||||||
level++;
|
level++;
|
||||||
if (currentGroup.getCurrentGroupDepth() > deepest.getCurrentGroupDepth()) {
|
if (currentGroup.getCurrentGroupDepth() > deepest.getCurrentGroupDepth()) {
|
||||||
deepest = currentGroup;
|
deepest = currentGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < currentGroup.children.length; i++) {
|
for (let i = 0; i < currentGroup.children.length; i++) {
|
||||||
var currentItem = currentGroup.children[i];
|
const currentItem = currentGroup.children[i];
|
||||||
|
|
||||||
if ((i !== skipIndex || level > 1) && currentItem instanceof ClauseGroup) {
|
if ((i !== skipIndex || level > 1) && currentItem instanceof ClauseGroup) {
|
||||||
func(currentItem);
|
func(currentItem);
|
||||||
@ -170,16 +171,16 @@ export default class ClauseGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getCheckedItemsInfo(): { canGroup: boolean; begin: number; end: number } {
|
private getCheckedItemsInfo(): { canGroup: boolean; begin: number; end: number } {
|
||||||
var beginIndex = -1;
|
let beginIndex = -1;
|
||||||
var endIndex = -1;
|
let endIndex = -1;
|
||||||
// In order to perform group, all selected items must be next to each other.
|
// In order to perform group, all selected items must be next to each other.
|
||||||
// If one or more items are not selected between the first and the last selected item, the gapFlag will be set to True, meaning cannot perform group.
|
// If one or more items are not selected between the first and the last selected item, the gapFlag will be set to True, meaning cannot perform group.
|
||||||
var gapFlag = false;
|
let gapFlag = false;
|
||||||
var count = 0;
|
let count = 0;
|
||||||
|
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
for (let i = 0; i < this.children.length; i++) {
|
||||||
var currentItem = this.children[i];
|
const currentItem = this.children[i];
|
||||||
var subGroupSelectionState: { allSelected: boolean; partiallySelected: boolean; nonSelected: boolean };
|
let subGroupSelectionState: { allSelected: boolean; partiallySelected: boolean; nonSelected: boolean };
|
||||||
|
|
||||||
if (currentItem instanceof ClauseGroup) {
|
if (currentItem instanceof ClauseGroup) {
|
||||||
subGroupSelectionState = (<ClauseGroup>currentItem).getSelectionState();
|
subGroupSelectionState = (<ClauseGroup>currentItem).getSelectionState();
|
||||||
@ -235,10 +236,10 @@ export default class ClauseGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getSelectionState(): { allSelected: boolean; partiallySelected: boolean; nonSelected: boolean } {
|
private getSelectionState(): { allSelected: boolean; partiallySelected: boolean; nonSelected: boolean } {
|
||||||
var selectedCount = 0;
|
let selectedCount = 0;
|
||||||
|
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
for (let i = 0; i < this.children.length; i++) {
|
||||||
var currentItem = this.children[i];
|
const currentItem = this.children[i];
|
||||||
|
|
||||||
if (currentItem instanceof ClauseGroup && (<ClauseGroup>currentItem).getSelectionState().allSelected) {
|
if (currentItem instanceof ClauseGroup && (<ClauseGroup>currentItem).getSelectionState().allSelected) {
|
||||||
selectedCount++;
|
selectedCount++;
|
||||||
@ -260,8 +261,8 @@ export default class ClauseGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private unselectAll(): void {
|
private unselectAll(): void {
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
for (let i = 0; i < this.children.length; i++) {
|
||||||
var currentItem = this.children[i];
|
const currentItem = this.children[i];
|
||||||
|
|
||||||
if (currentItem instanceof ClauseGroup) {
|
if (currentItem instanceof ClauseGroup) {
|
||||||
(<ClauseGroup>currentItem).unselectAll();
|
(<ClauseGroup>currentItem).unselectAll();
|
||||||
@ -278,8 +279,8 @@ export default class ClauseGroup {
|
|||||||
targetArray.splice(0, targetArray.length);
|
targetArray.splice(0, targetArray.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < queryGroup.children.length; i++) {
|
for (let i = 0; i < queryGroup.children.length; i++) {
|
||||||
var currentItem = queryGroup.children[i];
|
const currentItem = queryGroup.children[i];
|
||||||
|
|
||||||
if (currentItem instanceof ClauseGroup) {
|
if (currentItem instanceof ClauseGroup) {
|
||||||
this.flattenClausesImpl(currentItem, targetArray);
|
this.flattenClausesImpl(currentItem, targetArray);
|
||||||
@ -292,13 +293,13 @@ export default class ClauseGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getTreeDepth(): number {
|
public getTreeDepth(): number {
|
||||||
var currentDepth = this.getCurrentGroupDepth();
|
let currentDepth = this.getCurrentGroupDepth();
|
||||||
|
|
||||||
for (var i = 0; i < this.children.length; i++) {
|
for (let i = 0; i < this.children.length; i++) {
|
||||||
var currentItem = this.children[i];
|
const currentItem = this.children[i];
|
||||||
|
|
||||||
if (currentItem instanceof ClauseGroup) {
|
if (currentItem instanceof ClauseGroup) {
|
||||||
var newDepth = (<ClauseGroup>currentItem).getTreeDepth();
|
const newDepth = (<ClauseGroup>currentItem).getTreeDepth();
|
||||||
|
|
||||||
if (newDepth > currentDepth) {
|
if (newDepth > currentDepth) {
|
||||||
currentDepth = newDepth;
|
currentDepth = newDepth;
|
||||||
@ -310,8 +311,8 @@ export default class ClauseGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getCurrentGroupDepth(): number {
|
public getCurrentGroupDepth(): number {
|
||||||
var group = <ClauseGroup>this;
|
let group = <ClauseGroup>this;
|
||||||
var depth = 0;
|
let depth = 0;
|
||||||
|
|
||||||
while (!group.isRootGroup) {
|
while (!group.isRootGroup) {
|
||||||
depth++;
|
depth++;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
|
import * as Constants from "../Constants";
|
||||||
import ClauseGroup from "./ClauseGroup";
|
import ClauseGroup from "./ClauseGroup";
|
||||||
import QueryBuilderViewModel from "./QueryBuilderViewModel";
|
import QueryBuilderViewModel from "./QueryBuilderViewModel";
|
||||||
import * as Constants from "../Constants";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View model for showing group indicators on UI, contains information such as group color and border styles.
|
* View model for showing group indicators on UI, contains information such as group color and border styles.
|
||||||
@ -38,7 +38,7 @@ export default class ClauseGroupViewModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private getGroupBackgroundColor(group: ClauseGroup): string {
|
private getGroupBackgroundColor(group: ClauseGroup): string {
|
||||||
var colorCount = Constants.clauseGroupColors.length;
|
const colorCount = Constants.clauseGroupColors.length;
|
||||||
|
|
||||||
if (group.isRootGroup) {
|
if (group.isRootGroup) {
|
||||||
return Constants.transparentColor;
|
return Constants.transparentColor;
|
||||||
|
Loading…
Reference in New Issue
Block a user