From fa4612e7dfeaecc09e205c5d6fa37743d23f9298 Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Sat, 27 Jun 2020 02:37:22 -0500 Subject: moved sorting into header --- src/client/views/collections/SchemaTable.tsx | 51 ++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'src/client/views/collections/SchemaTable.tsx') diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx index 5df0a676e..5d1dcf199 100644 --- a/src/client/views/collections/SchemaTable.tsx +++ b/src/client/views/collections/SchemaTable.tsx @@ -80,6 +80,7 @@ export interface SchemaTableProps { reorderColumns: (toMove: SchemaHeaderField, relativeTo: SchemaHeaderField, before: boolean, columnsValues: SchemaHeaderField[]) => void; changeColumns: (oldKey: string, newKey: string, addNew: boolean) => void; setHeaderIsEditing: (isEditing: boolean) => void; + changeColumnSort: (columnField: SchemaHeaderField, descending: boolean | undefined) => void; } @observer @@ -132,7 +133,22 @@ export class SchemaTable extends React.Component { } @action - changeDropdown = () => { console.log("header clicked"); this._showTitleDropdown = !this._showTitleDropdown; } + changeSorting = (col: any) => { + console.log(col.heading); + if (col.desc === undefined) { + // no sorting + this.props.changeColumnSort(col, true); + } else if (col.desc === true) { + // descending sort + this.props.changeColumnSort(col, false); + } else if (col.desc === false) { + // ascending sort + this.props.changeColumnSort(col, undefined); + } + } + + @action + changeTitleMode = () => { console.log("header clicked"); this._showTitleDropdown = !this._showTitleDropdown; } @computed get borderWidth() { return Number(COLLECTION_BORDER_WIDTH); } @computed get tableColumns(): Column[] { @@ -180,7 +196,17 @@ export class SchemaTable extends React.Component { this.getColumnType(col) === ColumnType.Boolean ? "check-square" : this.getColumnType(col) === ColumnType.Doc ? "file" : this.getColumnType(col) === ColumnType.Image ? "image" : this.getColumnType(col) === ColumnType.List ? "list-ul" : "align-justify"; - const headerText = this._showTitleDropdown ? keysDropdown : col.heading; + const headerText = this._showTitleDropdown ? keysDropdown :
+ {col.heading}
; + + const sortIcon = col.desc === undefined ? "circle" : col.desc === true ? "caret-down" : "caret-up"; const menuContent =
{ const header =
this.props.openHeader(col, menuContent, e.clientX, e.clientY)} - className="collectionSchemaView-menuOptions" + className="collectionSchemaView-menuOptions-wrapper" style={{ background: col.color, padding: "2px", - // letterSpacing: "2px", - // textTransform: "uppercase", display: "flex" }}> - {menuContent} + +
+
+
+ {keysDropdown} +
+ +
this.changeSorting(col)} + style={{ paddingRight: "6px" }}> + +
this.props.openHeader(col, e.clientX, e.clientY)} style={{ float: "right", paddingRight: "6px" }}> - +
; -- cgit v1.2.3-70-g09d2