Skip to content

Commit

Permalink
Refactor to work with @plone/volto#8.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Oct 7, 2020
1 parent 461360b commit 26bd6a5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 46 deletions.
5 changes: 3 additions & 2 deletions src/ColumnsBlock/ColumnsBlockEdit.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { Grid, Segment } from 'semantic-ui-react';
import { isEmpty } from 'lodash';
import { SidebarPortal, Icon, InlineForm } from '@plone/volto/components'; // BlocksForm, Icon,
import { emptyBlocksForm } from '@plone/volto/helpers';
import { SidebarPortal, Icon } from '@plone/volto/components'; // BlocksForm, Icon,
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
import { emptyBlocksForm } from '@eeacms/volto-blocks-form/helpers';
import { setSidebarTab } from '@plone/volto/actions';
import { connect } from 'react-redux';
import { BlocksForm } from '@eeacms/volto-blocks-form/components';
Expand Down
2 changes: 1 addition & 1 deletion src/ColumnsBlock/ColumnsBlockView.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Grid } from 'semantic-ui-react';
import { RenderBlocks } from '@plone/volto/components';
import { RenderBlocks } from '@eeacms/volto-blocks-form/components';
import { blocks } from '~/config';
import { COLUMNSBLOCK } from '@eeacms/volto-columns-block/constants';

Expand Down
2 changes: 1 addition & 1 deletion src/ColumnsBlock/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v4 as uuid } from 'uuid';
import { emptyBlocksForm } from '@plone/volto/helpers';
import { emptyBlocksForm } from '@eeacms/volto-blocks-form/helpers';

export const getColumns = (coldata) => {
return (coldata?.columns_layout?.items || []).map((id) => [
Expand Down
89 changes: 47 additions & 42 deletions src/Widgets/ColumnsWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';
import { v4 as uuid } from 'uuid';
import { omit, without } from 'lodash';
import move from 'lodash-move';
import { DragDropList, Icon, FormFieldWrapper } from '@plone/volto/components';
import { emptyBlocksForm } from '@plone/volto/helpers';
import { Icon, FormFieldWrapper } from '@plone/volto/components';
import { DragDropList } from '@eeacms/volto-blocks-form/components';
import { emptyBlocksForm } from '@eeacms/volto-blocks-form/helpers';

import dragSVG from '@plone/volto/icons/drag.svg';
import trashSVG from '@plone/volto/icons/delete.svg';
Expand Down Expand Up @@ -53,48 +54,52 @@ const ColumnsWidget = (props) => {
onChange(id, newFormData);
return true;
}}
renderChild={(child, childId, index, draginfo) => (
<div ref={draginfo.innerRef} {...draginfo.draggableProps}>
<div style={{ position: 'relative' }}>
<div
style={{
visibility: 'visible',
display: 'inline-block',
}}
{...draginfo.dragHandleProps}
className="drag handle wrapper"
>
<Icon name={dragSVG} size="18px" />
</div>
<div className="column-area">
<div className="label">Column {index}</div>
{value.columns_layout?.items?.length > 1 ? (
<button
onClick={() => {
const newFormData = {
...value,
columns: omit({ ...value.columns }, [childId]),
columns_layout: {
...value.columns_layout,
items: without(
[...value.columns_layout?.items],
childId,
),
},
};
onChange(id, newFormData);
}}
>
<Icon name={trashSVG} size="18px" />
</button>
) : (
''
)}
>
{(dragProps) => {
const { childId, index, draginfo } = dragProps;
return (
<div ref={draginfo.innerRef} {...draginfo.draggableProps}>
<div style={{ position: 'relative' }}>
<div
style={{
visibility: 'visible',
display: 'inline-block',
}}
{...draginfo.dragHandleProps}
className="drag handle wrapper"
>
<Icon name={dragSVG} size="18px" />
</div>
<div className="column-area">
<div className="label">Column {index}</div>
{value.columns_layout?.items?.length > 1 ? (
<button
onClick={() => {
const newFormData = {
...value,
columns: omit({ ...value.columns }, [childId]),
columns_layout: {
...value.columns_layout,
items: without(
[...value.columns_layout?.items],
childId,
),
},
};
onChange(id, newFormData);
}}
>
<Icon name={trashSVG} size="18px" />
</button>
) : (
''
)}
</div>
</div>
</div>
</div>
)}
/>
);
}}
</DragDropList>
{showAdd ? (
<button
onClick={() => {
Expand Down

0 comments on commit 26bd6a5

Please sign in to comment.