Skip to content

Commit

Permalink
GH-38 Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Artkrygin committed Oct 12, 2021
1 parent 396937e commit d9e63a7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/layouts/AntdFormLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const AntdFormLayout: React.FC<any> = ({
<AutoSizer>
{({ width, height }: any) => (
<div style={{ width, height, overflow: 'auto', position: 'relative', ...style }} onClick={() => onEdit()}>
<span style={{ padding: '7px', fontSize: '2em' }}>{title}</span>
{title && <span style={{ padding: '7px', fontSize: '2em' }}>{title}</span>}
{readOnly ? null : <LogicalButton form={id} onSave={onSave} onCancel={onCancel} />}
<Form labelAlign={'left'}>
<AntdVerticalLayoutWithStore
Expand Down
9 changes: 5 additions & 4 deletions src/layouts/AntdVerticalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
********************************************************************************/
import React from 'react';
import { Row, Col } from 'antd';

import { getSnapshot } from 'mobx-state-tree';
import { FormsDispatchProps, FormsDispatch } from '../Form';
import { rankWith, uiTypeIs, RankedTester } from '../testers';
import { withLayoutProps } from '../util/ContextToProps';
Expand All @@ -30,7 +30,8 @@ export const AntdVerticalLayoutRenderer: React.FC<LayoutComponent> = ({
}) => {
const style = viewKindElement.options?.style;
const Render: React.FC<FormsDispatchProps & Idx> = ({ idx, viewKind, viewKindElement, viewDescr, enabled }) => {
const options = viewKindElement.options || {};
const height = viewKindElement.options?.style?.height;
console.log('OPT', viewKindElement, height);
const newViewKindElement = { ...viewKindElement };
if (newViewKindElement.options) {
newViewKindElement.options.style = {};
Expand All @@ -39,8 +40,8 @@ export const AntdVerticalLayoutRenderer: React.FC<LayoutComponent> = ({
<Row
style={{
position: 'relative',
width: '100%',
height: '100%',
width: '100%', //
height,
//flex: viewKindElement.options && viewKindElement.options.height === 'all-empty-space' ? '1 1 auto' : '',
}}>
<Col span={24} style={{ position: 'relative' }}>
Expand Down
2 changes: 1 addition & 1 deletion src/util/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const renderLayoutElements = ({
//const sort = id ? viewKind.properties && viewKind.properties[id] && viewKind.properties[id].order : undefined;
if (!elements || elements.length === 0) return <></>;
return elements.map((el: IViewKindElement, idx: number) => {
el = { ...el, options: { ...el.options, readOnly } };
el = { ...el, options: { readOnly, ...el.options } };
return (
<Render key={idx} idx={idx} viewKind={viewKind} viewKindElement={el} viewDescr={viewDescr} enabled={enabled} />
);
Expand Down
7 changes: 5 additions & 2 deletions stories/FormWithColumns.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ const viewKinds = [
},
elements: [
{
'@id': 'rm:_83hd7f',
'@id': 'rm:_834hd7f',
'@type': 'aldkg:FormLayout',
options: {
readOnly: false,
style: {
height: '100%',
},
readOnly: true,
},
elements: [
{
Expand Down

0 comments on commit d9e63a7

Please sign in to comment.