diff --git a/.eslintignore b/.eslintignore index b06bed02c..0a0c46456 100644 --- a/.eslintignore +++ b/.eslintignore @@ -136,7 +136,6 @@ src/Explorer/Panes/Tables/AddTableEntityPane.ts src/Explorer/Panes/Tables/EditTableEntityPane.ts src/Explorer/Panes/Tables/EntityPropertyViewModel.ts src/Explorer/Panes/Tables/QuerySelectPane.ts -src/Explorer/Panes/Tables/TableColumnOptionsPane.ts src/Explorer/Panes/Tables/TableEntityPane.ts src/Explorer/Panes/Tables/Validators/EntityPropertyNameValidator.ts src/Explorer/Panes/Tables/Validators/EntityPropertyValidationCommon.ts diff --git a/src/Explorer/ComponentRegisterer.ts b/src/Explorer/ComponentRegisterer.ts index c1653f012..4476d22be 100644 --- a/src/Explorer/ComponentRegisterer.ts +++ b/src/Explorer/ComponentRegisterer.ts @@ -67,7 +67,6 @@ ko.components.register("graph-new-vertex-pane", new PaneComponents.GraphNewVerte ko.components.register("graph-styling-pane", new PaneComponents.GraphStylingPaneComponent()); ko.components.register("table-add-entity-pane", new PaneComponents.TableAddEntityPaneComponent()); ko.components.register("table-edit-entity-pane", new PaneComponents.TableEditEntityPaneComponent()); -ko.components.register("table-column-options-pane", new PaneComponents.TableColumnOptionsPaneComponent()); ko.components.register("table-query-select-pane", new PaneComponents.TableQuerySelectPaneComponent()); ko.components.register("cassandra-add-collection-pane", new PaneComponents.CassandraAddCollectionPaneComponent()); ko.components.register("string-input-pane", new PaneComponents.StringInputPaneComponent()); diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index 5bd16d33b..e2b4bd1a9 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -262,31 +262,6 @@ exports[`SettingsComponent renders 1`] = ` "title": [Function], "visible": [Function], }, - TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, QuerySelectPane { "allSelected": [Function], "anyColumnSelected": [Function], @@ -867,31 +842,6 @@ exports[`SettingsComponent renders 1`] = ` "visible": [Function], }, "subscriptionType": [Function], - "tableColumnOptionsPane": TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, "tabsManager": TabsManager { "activeTab": [Function], "openedTabs": [Function], @@ -1152,31 +1102,6 @@ exports[`SettingsComponent renders 1`] = ` "title": [Function], "visible": [Function], }, - TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, QuerySelectPane { "allSelected": [Function], "anyColumnSelected": [Function], @@ -1757,31 +1682,6 @@ exports[`SettingsComponent renders 1`] = ` "visible": [Function], }, "subscriptionType": [Function], - "tableColumnOptionsPane": TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, "tabsManager": TabsManager { "activeTab": [Function], "openedTabs": [Function], @@ -2055,31 +1955,6 @@ exports[`SettingsComponent renders 1`] = ` "title": [Function], "visible": [Function], }, - TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, QuerySelectPane { "allSelected": [Function], "anyColumnSelected": [Function], @@ -2660,31 +2535,6 @@ exports[`SettingsComponent renders 1`] = ` "visible": [Function], }, "subscriptionType": [Function], - "tableColumnOptionsPane": TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, "tabsManager": TabsManager { "activeTab": [Function], "openedTabs": [Function], @@ -2945,31 +2795,6 @@ exports[`SettingsComponent renders 1`] = ` "title": [Function], "visible": [Function], }, - TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, QuerySelectPane { "allSelected": [Function], "anyColumnSelected": [Function], @@ -3550,31 +3375,6 @@ exports[`SettingsComponent renders 1`] = ` "visible": [Function], }, "subscriptionType": [Function], - "tableColumnOptionsPane": TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, "tabsManager": TabsManager { "activeTab": [Function], "openedTabs": [Function], diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 3e2e39143..50861453b 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -67,7 +67,6 @@ import { StringInputPane } from "./Panes/StringInputPane"; import AddTableEntityPane from "./Panes/Tables/AddTableEntityPane"; import EditTableEntityPane from "./Panes/Tables/EditTableEntityPane"; import { QuerySelectPane } from "./Panes/Tables/QuerySelectPane"; -import { TableColumnOptionsPane } from "./Panes/Tables/TableColumnOptionsPane"; import { UploadFilePane } from "./Panes/UploadFilePane"; import { UploadItemsPane } from "./Panes/UploadItemsPane"; import { CassandraAPIDataClient, TableDataClient, TablesAPIDataClient } from "./Tables/TableDataClient"; @@ -206,7 +205,6 @@ export default class Explorer { public graphStylingPane: GraphStylingPane; public addTableEntityPane: AddTableEntityPane; public editTableEntityPane: EditTableEntityPane; - public tableColumnOptionsPane: TableColumnOptionsPane; public querySelectPane: QuerySelectPane; public newVertexPane: NewVertexPane; public cassandraAddCollectionPane: CassandraAddCollectionPane; @@ -580,13 +578,6 @@ export default class Explorer { container: this, }); - this.tableColumnOptionsPane = new TableColumnOptionsPane({ - id: "tablecolumnoptionspane", - visible: ko.observable(false), - - container: this, - }); - this.querySelectPane = new QuerySelectPane({ id: "queryselectpane", visible: ko.observable(false), @@ -631,7 +622,6 @@ export default class Explorer { this.graphStylingPane, this.addTableEntityPane, this.editTableEntityPane, - this.tableColumnOptionsPane, this.querySelectPane, this.newVertexPane, this.cassandraAddCollectionPane, diff --git a/src/Explorer/Panes/PaneComponents.ts b/src/Explorer/Panes/PaneComponents.ts index e128c4dd4..c73492b03 100644 --- a/src/Explorer/Panes/PaneComponents.ts +++ b/src/Explorer/Panes/PaneComponents.ts @@ -8,7 +8,6 @@ import GraphStylingPaneTemplate from "./GraphStylingPane.html"; import SetupNotebooksPaneTemplate from "./SetupNotebooksPane.html"; import StringInputPaneTemplate from "./StringInputPane.html"; import TableAddEntityPaneTemplate from "./Tables/TableAddEntityPane.html"; -import TableColumnOptionsPaneTemplate from "./Tables/TableColumnOptionsPane.html"; import TableEditEntityPaneTemplate from "./Tables/TableEditEntityPane.html"; import TableQuerySelectPaneTemplate from "./Tables/TableQuerySelectPane.html"; @@ -81,15 +80,6 @@ export class TableEditEntityPaneComponent { } } -export class TableColumnOptionsPaneComponent { - constructor() { - return { - viewModel: PaneComponent, - template: TableColumnOptionsPaneTemplate, - }; - } -} - export class TableQuerySelectPaneComponent { constructor() { return { diff --git a/src/Explorer/Panes/SettingsPane/__snapshots__/index.test.tsx.snap b/src/Explorer/Panes/SettingsPane/__snapshots__/index.test.tsx.snap index 765f02152..39940921f 100644 --- a/src/Explorer/Panes/SettingsPane/__snapshots__/index.test.tsx.snap +++ b/src/Explorer/Panes/SettingsPane/__snapshots__/index.test.tsx.snap @@ -238,31 +238,6 @@ exports[`Settings Pane should render Default properly 1`] = ` "title": [Function], "visible": [Function], }, - TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, QuerySelectPane { "allSelected": [Function], "anyColumnSelected": [Function], @@ -843,31 +818,6 @@ exports[`Settings Pane should render Default properly 1`] = ` "visible": [Function], }, "subscriptionType": [Function], - "tableColumnOptionsPane": TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, "tabsManager": TabsManager { "activeTab": [Function], "openedTabs": [Function], @@ -1216,31 +1166,6 @@ exports[`Settings Pane should render Gremlin properly 1`] = ` "title": [Function], "visible": [Function], }, - TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, QuerySelectPane { "allSelected": [Function], "anyColumnSelected": [Function], @@ -1821,31 +1746,6 @@ exports[`Settings Pane should render Gremlin properly 1`] = ` "visible": [Function], }, "subscriptionType": [Function], - "tableColumnOptionsPane": TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, "tabsManager": TabsManager { "activeTab": [Function], "openedTabs": [Function], diff --git a/src/Explorer/Panes/Tables/TableColumnOptionsPane.html b/src/Explorer/Panes/Tables/TableColumnOptionsPane.html deleted file mode 100644 index a0e289976..000000000 --- a/src/Explorer/Panes/Tables/TableColumnOptionsPane.html +++ /dev/null @@ -1,78 +0,0 @@ -
-
-
- -
-
- -
- Column Options -
- Close -
-
- -
-
Choose the columns and the order in which you want to display them in the table.
-
-
- - - - Move down - - - Move up - -
-
-
-
    -
  • - - -
  • -
-
-
-
- -
- -
-
-
-
-
-
-
- -
-
diff --git a/src/Explorer/Panes/Tables/TableColumnOptionsPane.ts b/src/Explorer/Panes/Tables/TableColumnOptionsPane.ts deleted file mode 100644 index 0da321ab2..000000000 --- a/src/Explorer/Panes/Tables/TableColumnOptionsPane.ts +++ /dev/null @@ -1,195 +0,0 @@ -import * as ko from "knockout"; -import * as ViewModels from "../../../Contracts/ViewModels"; -import * as DataTableOperations from "../../Tables/DataTable/DataTableOperations"; -import TableEntityListViewModel from "../../Tables/DataTable/TableEntityListViewModel"; -import { ContextualPaneBase } from "../ContextualPaneBase"; -import _ from "underscore"; - -/** - * Represents an item shown in the available columns. - * columnName: the name of the column. - * selected: indicate whether user wants to display the column in the table. - * order: the order in the initial table. E.g., - * Order array of initial table: I = [0, 1, 2, 3, 4, 5, 6, 7, 8] <----> {prop0, prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8} - * Order array of current table: C = [0, 1, 2, 6, 7, 3, 4, 5, 8] <----> {prop0, prop1, prop2, prop6, prop7, prop3, prop4, prop5, prop8} - * if order = 6, then this column will be the one with column name prop6 - * index: index in the observable array, this used for selection and moving up/down. - */ -interface IColumnOption { - columnName: ko.Observable; - selected: ko.Observable; - order: number; - index: number; -} - -export interface IColumnSetting { - columnNames: string[]; - visible?: boolean[]; - order?: number[]; -} - -export class TableColumnOptionsPane extends ContextualPaneBase { - public titleLabel: string = "Column Options"; - public instructionLabel: string = "Choose the columns and the order in which you want to display them in the table."; - public availableColumnsLabel: string = "Available Columns"; - public moveUpLabel: string = "Move Up"; - public moveDownLabel: string = "Move Down"; - public noColumnSelectedWarning: string = "At least one column should be selected."; - - public columnOptions: ko.ObservableArray; - public allSelected: ko.Computed; - public anyColumnSelected: ko.Computed; - public canSelectAll: ko.Computed; - public canMoveUp: ko.Observable; - public canMoveDown: ko.Observable; - - public tableViewModel: TableEntityListViewModel; - public parameters: IColumnSetting; - - private selectedColumnOption: IColumnOption = null; - - constructor(options: ViewModels.PaneOptions) { - super(options); - - this.columnOptions = ko.observableArray(); - this.anyColumnSelected = ko.computed(() => { - return _.some(this.columnOptions(), (value: IColumnOption) => { - return value.selected(); - }); - }); - - this.canSelectAll = ko.computed(() => { - return _.some(this.columnOptions(), (value: IColumnOption) => { - return !value.selected(); - }); - }); - - this.canMoveUp = ko.observable(false); - this.canMoveDown = ko.observable(false); - - this.allSelected = ko.pureComputed({ - read: () => { - return !this.canSelectAll(); - }, - write: (value) => { - if (value) { - this.selectAll(); - } else { - this.clearAll(); - } - }, - owner: this, - }); - } - - public submit() { - var newColumnSetting = this.getParameters(); - DataTableOperations.reorderColumns(this.tableViewModel.table, newColumnSetting.order).then(() => { - DataTableOperations.filterColumns(this.tableViewModel.table, newColumnSetting.visible); - this.visible(false); - }); - } - public open() { - this.setDisplayedColumns(this.parameters.columnNames, this.parameters.order, this.parameters.visible); - super.open(); - } - - private getParameters(): IColumnSetting { - var newColumnSettings: IColumnSetting = { - columnNames: [], - order: [], - visible: [], - }; - this.columnOptions().map((value: IColumnOption) => { - newColumnSettings.columnNames.push(value.columnName()); - newColumnSettings.order.push(value.order); - newColumnSettings.visible.push(value.selected()); - }); - return newColumnSettings; - } - - public setDisplayedColumns(columnNames: string[], order: number[], visible: boolean[]): void { - var options: IColumnOption[] = order.map((value: number, index: number) => { - var columnOption: IColumnOption = { - columnName: ko.observable(columnNames[index]), - order: value, - selected: ko.observable(visible[index]), - index: index, - }; - return columnOption; - }); - this.columnOptions(options); - } - - public selectAll(): void { - const columnOptions = this.columnOptions && this.columnOptions(); - columnOptions && - columnOptions.forEach((value: IColumnOption) => { - value.selected(true); - }); - } - - public clearAll(): void { - const columnOptions = this.columnOptions && this.columnOptions(); - columnOptions && - columnOptions.forEach((value: IColumnOption) => { - value.selected(false); - }); - - if (columnOptions && columnOptions.length > 0) { - columnOptions[0].selected(true); - } - } - - public moveUp(): void { - if (this.selectedColumnOption) { - var currentSelectedIndex: number = this.selectedColumnOption.index; - var swapTargetIndex: number = currentSelectedIndex - 1; - //Debug.assert(currentSelectedIndex > 0); - - this.swapColumnOption(this.columnOptions(), swapTargetIndex, currentSelectedIndex); - this.selectTargetItem($(`div.column-options li:eq(${swapTargetIndex})`), this.columnOptions()[swapTargetIndex]); - } - } - - public moveDown(): void { - if (this.selectedColumnOption) { - var currentSelectedIndex: number = this.selectedColumnOption.index; - var swapTargetIndex: number = currentSelectedIndex + 1; - //Debug.assert(currentSelectedIndex < (this.columnOptions().length - 1)); - - this.swapColumnOption(this.columnOptions(), swapTargetIndex, currentSelectedIndex); - this.selectTargetItem($(`div.column-options li:eq(${swapTargetIndex})`), this.columnOptions()[swapTargetIndex]); - } - } - - public handleClick = (data: IColumnOption, event: KeyboardEvent): boolean => { - this.selectTargetItem($(event.currentTarget), data); - return true; - }; - - private selectTargetItem($target: JQuery, targetColumn: IColumnOption): void { - this.selectedColumnOption = targetColumn; - - this.canMoveUp(targetColumn.index !== 0); - this.canMoveDown(targetColumn.index !== this.columnOptions().length - 1); - - $(".list-item.selected").removeClass("selected"); - $target.addClass("selected"); - } - - private swapColumnOption(options: IColumnOption[], indexA: number, indexB: number): void { - var tempColumnName: string = options[indexA].columnName(); - var tempSelected: boolean = options[indexA].selected(); - var tempOrder: number = options[indexA].order; - - options[indexA].columnName(options[indexB].columnName()); - options[indexB].columnName(tempColumnName); - - options[indexA].selected(options[indexB].selected()); - options[indexB].selected(tempSelected); - - options[indexA].order = options[indexB].order; - options[indexB].order = tempOrder; - } -} diff --git a/src/Explorer/Panes/UploadItemsPane/__snapshots__/index.test.tsx.snap b/src/Explorer/Panes/UploadItemsPane/__snapshots__/index.test.tsx.snap index a2e0a52f9..f5b51c529 100644 --- a/src/Explorer/Panes/UploadItemsPane/__snapshots__/index.test.tsx.snap +++ b/src/Explorer/Panes/UploadItemsPane/__snapshots__/index.test.tsx.snap @@ -238,31 +238,6 @@ exports[`Upload Items Pane should render Default properly 1`] = ` "title": [Function], "visible": [Function], }, - TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, QuerySelectPane { "allSelected": [Function], "anyColumnSelected": [Function], @@ -843,31 +818,6 @@ exports[`Upload Items Pane should render Default properly 1`] = ` "visible": [Function], }, "subscriptionType": [Function], - "tableColumnOptionsPane": TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, "tabsManager": TabsManager { "activeTab": [Function], "openedTabs": [Function], diff --git a/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap b/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap index da7aa5996..a515e5a65 100644 --- a/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap +++ b/src/Explorer/Panes/__snapshots__/DeleteDatabaseConfirmationPanel.test.tsx.snap @@ -239,31 +239,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database "title": [Function], "visible": [Function], }, - TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, QuerySelectPane { "allSelected": [Function], "anyColumnSelected": [Function], @@ -848,31 +823,6 @@ exports[`Delete Database Confirmation Pane submit() Should call delete database "visible": [Function], }, "subscriptionType": [Function], - "tableColumnOptionsPane": TableColumnOptionsPane { - "allSelected": [Function], - "anyColumnSelected": [Function], - "availableColumnsLabel": "Available Columns", - "canMoveDown": [Function], - "canMoveUp": [Function], - "canSelectAll": [Function], - "columnOptions": [Function], - "container": [Circular], - "firstFieldHasFocus": [Function], - "formErrors": [Function], - "formErrorsDetails": [Function], - "handleClick": [Function], - "id": "tablecolumnoptionspane", - "instructionLabel": "Choose the columns and the order in which you want to display them in the table.", - "isExecuting": [Function], - "isTemplateReady": [Function], - "moveDownLabel": "Move Down", - "moveUpLabel": "Move Up", - "noColumnSelectedWarning": "At least one column should be selected.", - "selectedColumnOption": null, - "title": [Function], - "titleLabel": "Column Options", - "visible": [Function], - }, "tabsManager": TabsManager { "activeTab": [Function], "openedTabs": [Function], diff --git a/src/Explorer/Tables/DataTable/TableCommands.ts b/src/Explorer/Tables/DataTable/TableCommands.ts index c52c296d3..a84dc9008 100644 --- a/src/Explorer/Tables/DataTable/TableCommands.ts +++ b/src/Explorer/Tables/DataTable/TableCommands.ts @@ -1,12 +1,8 @@ -import _ from "underscore"; import Q from "q"; -import * as DataTableUtilities from "./DataTableUtilities"; -import * as DataTableOperations from "./DataTableOperations"; -import TableEntityListViewModel from "./TableEntityListViewModel"; -import * as Entities from "../Entities"; -import * as ViewModels from "../../../Contracts/ViewModels"; -import * as TableColumnOptionsPane from "../../Panes/Tables/TableColumnOptionsPane"; import Explorer from "../../Explorer"; +import * as Entities from "../Entities"; +import * as DataTableUtilities from "./DataTableUtilities"; +import TableEntityListViewModel from "./TableEntityListViewModel"; export default class TableCommands { // Command Ids @@ -92,64 +88,6 @@ export default class TableCommands { return null; } - public customizeColumnsCommand(viewModel: TableEntityListViewModel): Q.Promise { - var table: DataTables.DataTable = viewModel.table; - var displayedColumnNames: string[] = DataTableOperations.getDataTableHeaders(table); - var columnsCount: number = displayedColumnNames.length; - var currentOrder: number[] = DataTableOperations.getInitialOrder(columnsCount); - //Debug.assert(!!table && !!currentOrder && displayedColumnNames.length === currentOrder.length); - - var currentSettings: boolean[]; - try { - currentSettings = currentOrder.map((value: number, index: number) => { - return table.column(index).visible(); - }); - } catch (err) { - // Error - } - - let parameters: TableColumnOptionsPane.IColumnSetting = { - columnNames: displayedColumnNames, - order: currentOrder, - visible: currentSettings, - }; - - this._container.tableColumnOptionsPane.tableViewModel = viewModel; - this._container.tableColumnOptionsPane.parameters = parameters; - this._container.tableColumnOptionsPane.open(); - return null; - } - - public reorderColumnsBasedOnSelectedEntities(viewModel: TableEntityListViewModel): Q.Promise { - var selected = viewModel.selected(); - if (!selected || !selected.length) { - return null; - } - - var table = viewModel.table; - var currentColumnNames: string[] = DataTableOperations.getDataTableHeaders(table); - var headersCount: number = currentColumnNames.length; - - var headersUnion: string[] = DataTableUtilities.getPropertyIntersectionFromTableEntities( - selected, - viewModel.queryTablesTab.container.isPreferredApiCassandra() - ); - - // An array with elements representing indexes of selected entities' header union out of initial headers. - var orderOfLeftHeaders: number[] = headersUnion.map((item: string) => currentColumnNames.indexOf(item)); - - // An array with elements representing initial order of the table. - var initialOrder: number[] = DataTableOperations.getInitialOrder(headersCount); - - // An array with elements representing indexes of headers not present in selected entities' header union. - var orderOfRightHeaders: number[] = _.difference(initialOrder, orderOfLeftHeaders); - - // This will be the target order, with headers in selected entities on the left while others on the right, both in the initial order, respectively. - var targetOrder: number[] = orderOfLeftHeaders.concat(orderOfRightHeaders); - - return DataTableOperations.reorderColumns(table, targetOrder); - } - public resetColumns(viewModel: TableEntityListViewModel): void { viewModel.reloadTable(); } diff --git a/src/Main.tsx b/src/Main.tsx index 91b772de2..d829e897b 100644 --- a/src/Main.tsx +++ b/src/Main.tsx @@ -236,7 +236,6 @@ const App: React.FunctionComponent = () => {
-