From 74b124100f8886e196764b15cd3fb1a825679a3a Mon Sep 17 00:00:00 2001 From: andreiggr Date: Thu, 21 Apr 2022 16:02:27 +0300 Subject: [PATCH] Expandable table updates --- .../templates/expandable/Edit.jsx | 1 + .../templates/expandable/PopupRow.jsx | 11 ++- .../templates/expandable/View.jsx | 73 ++++++++++++++----- .../templates/expandable/schema.js | 15 ++++ .../templates/expandable/style.less | 48 +++++++++--- 5 files changed, 116 insertions(+), 32 deletions(-) diff --git a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/Edit.jsx b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/Edit.jsx index 1c36587..b19b488 100644 --- a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/Edit.jsx +++ b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/Edit.jsx @@ -68,6 +68,7 @@ class Edit extends Component { schema.properties.popupTitle.choices = choices; schema.properties.popupDescription.choices = choices; schema.properties.popupUrl.choices = choices; + schema.properties.defaultSortColumn.choices = choices; //set choices for the popup table columns schema.properties.popupTableColumns.schema.properties.column.choices = tableChoices; diff --git a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/PopupRow.jsx b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/PopupRow.jsx index 5b1efb0..dac4c59 100644 --- a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/PopupRow.jsx +++ b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/PopupRow.jsx @@ -175,16 +175,21 @@ const PopupRow = ({ ); } }; - return ( handleClose()} onOpen={() => handleExpand()} open={expand} trigger={ - +
- +

+ {rowData && + tableData && + tableData.popupTitle && + rowData[tableData.popupTitle]} +

+
} > {popupSchema.title} diff --git a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/View.jsx b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/View.jsx index a7c66e4..54c0e4e 100644 --- a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/View.jsx +++ b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/View.jsx @@ -95,6 +95,16 @@ const View = (props) => { [filteredTableData, selectedColumns], ); + React.useEffect(() => { + if (data.defaultSortColumn && data.defaultSortOrder) { + if (data.defaultSortOrder === 'ascending') { + setSortBy([data.defaultSortColumn, true]); + } else { + setSortBy([data.defaultSortColumn, false]); + } + } + }, [data.defaultSortColumn, data.defaultSortOrder]); + React.useEffect(() => { const newTableData = []; if (provider_data_length) { @@ -139,9 +149,10 @@ const View = (props) => { }, []); return ( -
+
{}} showNoResults={false} @@ -158,11 +169,6 @@ const View = (props) => { return ''; }} /> - {data.searchDescription ? ( -

{data.searchDescription}

- ) : ( - '' - )} { {show_header ? ( - + + + {selectedColumns && selectedColumns.length > 0 && selectedColumns.map((colDef, j) => ( @@ -180,8 +210,8 @@ const View = (props) => { key={getNameOfColumn(colDef)} className={getAlignmentOfColumn(colDef, j)} > - + + {getTitleOfColumn(colDef)} + {sortBy[0] === colDef.column ? ( + + ) : ( + + )} + +

))}
diff --git a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/schema.js b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/schema.js index c3ec7e3..1aaab1f 100644 --- a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/schema.js +++ b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/schema.js @@ -124,6 +124,8 @@ export default () => ({ 'popupTitle', 'popupDescription', 'popupUrl', + 'defaultSortColumn', + 'defaultSortOrder', 'popup_table_provider_url', 'popupTableColumns', 'popup_map_provider_url', @@ -137,6 +139,18 @@ export default () => ({ title: 'Search description', widget: 'textarea', }, + defaultSortColumn: { + title: 'Default Sort Column', + description: 'Automatic sorting of table by selected column', + choices: [], + }, + defaultSortOrder: { + title: 'Default Sort Order', + choices: [ + ['ascending', 'ascending'], + ['descending', 'descending'], + ], + }, popup_table_provider_url: { title: 'Popup Table provider', widget: 'object_by_path', @@ -158,6 +172,7 @@ export default () => ({ popupTitle: { title: 'Popup Title', choices: [], + description: 'Title for main table and popup', }, popupDescription: { title: 'Popup description', diff --git a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/style.less b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/style.less index 0b92948..91b3946 100644 --- a/src/components/manage/Blocks/SimpleDataTable/templates/expandable/style.less +++ b/src/components/manage/Blocks/SimpleDataTable/templates/expandable/style.less @@ -1,4 +1,4 @@ -.smart-table { +.expandable-table { .ui.search .ui.icon.input { width: 100%; @@ -13,12 +13,11 @@ } .sortable-th { - display: flex; - align-items: center; - justify-content: center; border: none; background: none; cursor: pointer; + font-weight: 400; + // width: fit-content; > * { font-size: 1rem; @@ -26,6 +25,10 @@ } } + .ui.table thead { + background: #72b38e; + } + table { overflow: hidden; border: 1px solid #e8e8e8 !important; @@ -75,13 +78,10 @@ } .expand-row-icon { + width: 120px !important; cursor: pointer; } - .expand-row-icon:hover { - fill: #058373 !important; - } - .expand-row-img { width: 120px; max-width: 100% !important; @@ -89,11 +89,8 @@ padding: 5px; cursor: pointer; object-fit: contain; - } - .expand-row-img:hover { - border-radius: 5px; - box-shadow: 0px 0px 13px -7px #564535; + border: 1px solid transparent; } } } @@ -162,3 +159,30 @@ height: 400px; min-height: 400px; } + +.popup-trigger-container { + display: flex; + align-items: center; + cursor: pointer; +} + +.popup-trigger-title { + font-weight: 500; + margin: 0 0 0 15px !important; +} + +.popup-trigger-container:hover { + .popup-trigger-title { + color: #ca4300 !important; + font-weight: 500; + } + + .expand-row-img { + border-radius: 5px; + border: 1px solid #ca4300; + } + + .expand-row-icon { + fill: #ca4300 !important; + } +}