From 33b66bf8d179fffd5aa3749be6eb686017542076 Mon Sep 17 00:00:00 2001 From: Artyom Date: Tue, 6 Jul 2021 10:18:17 +0300 Subject: [PATCH 1/3] [ADD] added AntdList, fixed cards heights --- src/cells/AntdCellG2.tsx | 3 +-- src/data-controls/GridRenderer.tsx | 31 ++++-------------------------- stories/AntdCardCell.stories.tsx | 1 + 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/cells/AntdCellG2.tsx b/src/cells/AntdCellG2.tsx index 76b906a..d4b31e6 100644 --- a/src/cells/AntdCellG2.tsx +++ b/src/cells/AntdCellG2.tsx @@ -11,8 +11,7 @@ const template: any = { 'https://www.wildberries.ru/catalog/18247707/detail.aspx': '/img/chart_4.png', }; export const AntdCellG2 = (props: any) => { - console.log('PROPS', props); - return ; + return ; }; /** diff --git a/src/data-controls/GridRenderer.tsx b/src/data-controls/GridRenderer.tsx index 74a8dc7..f60c5db 100644 --- a/src/data-controls/GridRenderer.tsx +++ b/src/data-controls/GridRenderer.tsx @@ -8,7 +8,7 @@ * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ import React, { useState, useEffect } from 'react'; -import { Row, Col, Pagination } from 'antd'; +import { List, Row, Col, Pagination } from 'antd'; import { ViewElement } from '../models/uischema'; import { DispatchCell } from '../DispatchCell'; @@ -21,6 +21,8 @@ const divStyle: React.CSSProperties = { export const GridRenderer: React.FC = (props) => { const { child, onSelect, viewElement, uischema, view, schema } = props; + const grid = viewElement?.options?.grid || { gutter: 16, column: 4 }; + console.log('UISCEMA', uischema); const template = viewElement?.options?.elementTemplate || null; const createCell = (data: any, id: string | number) => template ? ( @@ -39,32 +41,7 @@ export const GridRenderer: React.FC = (props) => { ) : ( {data['@id']} ); - const createCol = (data: any, idx: number) => ( - - {createCell(data, idx)} - - ); - const createGrid = () => - child.reduce((acc: any, e: any, idx: number) => { - const remainder = (idx + 1) % 4; - if (remainder === 0 || idx === child.length - 1) { - const newColl = createCol(e, idx); - const colls = remainder === 1 ? [] : acc.splice(remainder === 0 ? -3 : 1 - remainder); - colls.push(newColl); - acc.push( - - {colls} - , - ); - } else { - acc.push(createCol(e, idx)); - } - return acc; - }, []); return ( - - {createGrid()} - - + {createCell(item, idx)}} /> ); }; diff --git a/stories/AntdCardCell.stories.tsx b/stories/AntdCardCell.stories.tsx index 891fdba..fcd4586 100644 --- a/stories/AntdCardCell.stories.tsx +++ b/stories/AntdCardCell.stories.tsx @@ -62,6 +62,7 @@ const viewDescrs = [ resultsScope: 'rm:Cards_Coll', options: { renderType: 'grid', + grid: { gutter: 16, column: 4 }, elementTemplate: [ { type: 'CardLayout', From 1b1578e130c92773e15b12d5001c20f639a5b5d1 Mon Sep 17 00:00:00 2001 From: artkrygin Date: Tue, 6 Jul 2021 16:31:38 +0300 Subject: [PATCH 2/3] [ADD] added some layout options --- stories/AntdCardCell.stories.tsx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/stories/AntdCardCell.stories.tsx b/stories/AntdCardCell.stories.tsx index fcd4586..3587b9f 100644 --- a/stories/AntdCardCell.stories.tsx +++ b/stories/AntdCardCell.stories.tsx @@ -62,7 +62,15 @@ const viewDescrs = [ resultsScope: 'rm:Cards_Coll', options: { renderType: 'grid', - grid: { gutter: 16, column: 4 }, + grid: { + gutter: 16, + xs: 2, + sm: 2, + md: 3, + lg: 3, + xl: 4, + xxl: 5, + }, elementTemplate: [ { type: 'CardLayout', @@ -75,6 +83,7 @@ const viewDescrs = [ type: 'Control', scope: 'name', options: { + editable: false, style: { height: '3.5em', textAlign: 'left', @@ -88,6 +97,9 @@ const viewDescrs = [ { type: 'Rate', scope: 'starsValue', + options: { + editable: false, + }, }, { type: 'CellHorizontalLayout', @@ -100,6 +112,7 @@ const viewDescrs = [ scope: 'price', options: { formater: 'labeledValue', + editable: false, label: 'Цена', specialChar: '₽', style: { @@ -114,6 +127,7 @@ const viewDescrs = [ scope: 'totalSales', options: { formater: 'labeledValue', + editable: false, label: 'Всего продано', style: { textAlign: 'right', @@ -128,6 +142,7 @@ const viewDescrs = [ type: 'Control', scope: 'lastMonthSalesAmount', options: { + editable: false, formater: 'сomparison', dataToFormater: { prevValue: 'prevMonthSalesAmount', @@ -145,6 +160,7 @@ const viewDescrs = [ scope: 'lastMonthSalesValue', options: { formater: 'сomparison', + editable: false, dataToFormater: { prevValue: 'prevMonthSalesValue', }, @@ -265,8 +281,8 @@ export const Empty: Story<{}> = () => (
Date: Tue, 6 Jul 2021 20:52:01 +0300 Subject: [PATCH 3/3] Fix grid xxl --- stories/AntdCardCell.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stories/AntdCardCell.stories.tsx b/stories/AntdCardCell.stories.tsx index 3587b9f..319a580 100644 --- a/stories/AntdCardCell.stories.tsx +++ b/stories/AntdCardCell.stories.tsx @@ -69,7 +69,7 @@ const viewDescrs = [ md: 3, lg: 3, xl: 4, - xxl: 5, + xxl: 7, }, elementTemplate: [ {